SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require 'fileutils'
  2. require 'tmpdir'
  3. require 'English'
  4.  
  5. prov_profiles_install_path = '~/Library/MobileDevice/Provisioning Profiles'
  6.  
  7. prov_profiles_archive_url = ENV['ADDITIONAL_PROVISIONING_PROFILES_ARCHIVE_URL']
  8.  
  9. temporary_dir = File.join(Dir.tmpdir, "additional_prov_profiles")
  10.  
  11. FileUtils.mkdir_p(temporary_dir)
  12.  
  13. begin
  14.     archive_path = File.join(temporary_dir, 'prov_profiles.zip')
  15.     archive_data = `curl -s -L #{prov_profiles_archive_url}`
  16.     raise "Failed to download archive at #{prov_profiles_archive_url}; aborting" unless $CHILD_STATUS.success?
  17.  
  18.     File.write(archive_path, archive_data)
  19.  
  20.     prov_profiles_dir = File.join(temporary_dir, 'prov_profiles')
  21.  
  22.     raise "Couldn't unzip #{prov_profiles_archive_url}; aborting" unless system('unzip', '-q', archive_path, '-d', prov_profiles_dir)
  23.  
  24.     FileUtils.mkdir_p(prov_profiles_install_path)
  25.  
  26.     plist_dir = File.join(temporary_dir, 'prov_profile_plists')
  27.     FileUtils.mkdir_p(plist_dir)
  28.  
  29.     Dir.glob(File.join(prov_profiles_dir, '**/*.mobileprovision')) do |prov_profile|
  30.         basename = File.basename(prov_profile)
  31.         name = File.basename(prov_profile, '.mobileprovision')
  32.         puts "Installing #{name}..."
  33.  
  34.         plist_info_base_path = File.join(plist_dir, basename)
  35.         plist_info_path = "#{plist_info_base_path}.plist"
  36.         File.write(plist_info_path, `security cms -D -i '#{prov_profile}'`)
  37.         raise "Couldn't parse provisioning profile; aborting" unless $CHILD_STATUS.success?
  38.  
  39.         uuid = `defaults read '#{File.expand_path(plist_info_base_path)}' UUID`
  40.         raise "Couldn't read UUID from prov profile; aborting" unless $CHILD_STATUS.success?
  41.  
  42.         FileUtils.mv(prov_profile, File.join(prov_profiles_install_path, "#{uuid}.mobileprovision"))
  43.         puts "Successfully installed #{name}."
  44.     end
  45. ensure
  46.     FileUtils.rm_rf(temporary_dir)
  47. end
  48.  
  49. puts 'Successfully installed provisioning profiles.'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top