Class: Match::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/match/utils.rb

Class Method Summary collapse

Class Method Details

.environment_variable_name(params) ⇒ Object



32
33
34
# File 'lib/match/utils.rb', line 32

def self.environment_variable_name(params)
  ["sigh", params[:app_identifier], params[:type]].join("_")
end

.fill_environment(params, uuid) ⇒ Object

Fill in the UUID of the profiles in environment variables, much recycling



25
26
27
28
29
30
# File 'lib/match/utils.rb', line 25

def self.fill_environment(params, uuid)
  # instead we specify the UUID of the profiles
  key = environment_variable_name(params)
  UI.important "Setting environment variable '#{key}' to '#{uuid}'" if $verbose
  ENV[key] = uuid
end

.import(item_path, keychain) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/match/utils.rb', line 3

def self.import(item_path, keychain)
  # Existing code expects that a keychain name will be expanded into a default path to Libary/Keychains
  # in the user's home directory. However, this will not allow the user to pass an absolute path
  # for the keychain value
  #
  # So, if the passed value can't be resolved as a file in Library/Keychains, just use it as-is
  # as the keychain path.
  keychain_paths = [File.join(Dir.home, 'Library', 'Keychains', keychain), keychain]

  keychain_path = keychain_paths.detect { |path| File.exist?(path) }

  UI.user_error!("Could not locate the provided keychain. Tried:\n\t#{keychain_paths.join("\n\t")}") unless keychain_path

  command = "security import #{item_path.shellescape} -k #{keychain_path.shellescape}"
  command << " -T /usr/bin/codesign" # to not be asked for permission when running a tool like `gym`
  command << " -T /usr/bin/security"
  command << " &> /dev/null" unless $verbose

  Helper.backticks(command, print: $verbose)
end