Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/krausefx/sigh
Browse files Browse the repository at this point in the history
  • Loading branch information
KrauseFx committed Jan 22, 2016
2 parents 952075f + 7fc3d2d commit 974baf4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/sigh/resign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ module Sigh
class Resign
def run(options, args)
# get the command line inputs and parse those into the vars we need...
ipa, signing_identity, provisioning_profiles = get_inputs(options, args)

ipa, signing_identity, provisioning_profiles, entitlements = get_inputs(options, args)
# ... then invoke our programmatic interface with these vars
resign(ipa, signing_identity, provisioning_profiles)
resign(ipa, signing_identity, provisioning_profiles, entitlements)
end

def self.resign(ipa, signing_identity, provisioning_profiles)
self.new.resign(ipa, signing_identity, provisioning_profiles)
def self.resign(ipa, signing_identity, provisioning_profiles, entitlements)
self.new.resign(ipa, signing_identity, provisioning_profiles, entitlements)
end

def resign(ipa, signing_identity, provisioning_profiles)
def resign(ipa, signing_identity, provisioning_profiles, entitlements)
resign_path = find_resign_path
signing_identity = find_signing_identity(signing_identity)

Expand All @@ -25,14 +25,15 @@ def resign(ipa, signing_identity, provisioning_profiles)

# validate that we have valid values for all these params, we don't need to check signing_identity because `find_signing_identity` will only ever return a valid value
validate_params(resign_path, ipa, provisioning_profiles)

entitlements = "-e #{entitlements}" if entitlements
provisioning_options = provisioning_profiles.map { |fst, snd| "-p #{[fst, snd].compact.map(&:shellescape).join('=')}" }.join(' ')

command = [
resign_path.shellescape,
ipa.shellescape,
signing_identity.shellescape,
provisioning_options, # we are aleady shellescaping this above, when we create the provisioning_options from the provisioning_profiles
entitlements,
ipa.shellescape
].join(' ')

Expand All @@ -52,8 +53,9 @@ def get_inputs(options, args)
ipa = args.first || find_ipa || ask('Path to ipa file: ')
signing_identity = options.signing_identity || ask_for_signing_identity
provisioning_profiles = options.provisioning_profile || find_provisioning_profile || ask('Path to provisioning file: ')
entitlements = options.entitlements || find_entitlements

return ipa, signing_identity, provisioning_profiles
return ipa, signing_identity, provisioning_profiles, entitlements
end

def find_resign_path
Expand All @@ -68,6 +70,10 @@ def find_provisioning_profile
Dir[File.join(Dir.pwd, '*.mobileprovision')].sort { |a, b| File.mtime(a) <=> File.mtime(b) }.first
end

def find_entitlements
Dir[File.join(Dir.pwd, '*.entitlements')].sort { |a, b| File.mtime(a) <=> File.mtime(b) }.first
end

def find_signing_identity(signing_identity)
until installed_identies.include?(signing_identity)
Helper.log.error "Couldn't find signing identity '#{signing_identity}'."
Expand Down

0 comments on commit 974baf4

Please sign in to comment.