Class: Fastlane::Helper::RepackIosHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::RepackIosHelper
- Defined in:
- lib/fastlane/plugin/repack_ios/helper/repack_ios_helper.rb
Class Method Summary collapse
- .get_signing_identity_from_provision_profile(provisioning_profile) ⇒ Object
- .patch_ipa_contents(src, dest, preserve = false, dereference_root = false) ⇒ Object
- .unpack_and_repack(output_name, ipa_path, contents) ⇒ Object
Class Method Details
.get_signing_identity_from_provision_profile(provisioning_profile) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/fastlane/plugin/repack_ios/helper/repack_ios_helper.rb', line 53 def self.get_signing_identity_from_provision_profile(provisioning_profile) parsed_provision = FastlaneCore::ProvisioningProfile.parse(provisioning_profile) cert = OpenSSL::X509::Certificate.new(parsed_provision["DeveloperCertificates"].first.string) cert_info = cert.subject.to_s.gsub(/\s*subject=\s*/, "").tr("/", "\n") out_array = cert_info.split("\n") cert_info_map = out_array.each_with_object({}) do |str, h| k, v = str.split("=") h[k] = v end return cert_info_map['CN'] end |
.patch_ipa_contents(src, dest, preserve = false, dereference_root = false) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/fastlane/plugin/repack_ios/helper/repack_ios_helper.rb', line 69 def self.patch_ipa_contents(src, dest, preserve = false, dereference_root = false) FileUtils::Entry_.new(src, nil, dereference_root).wrap_traverse(proc do |ent| destent = FileUtils::Entry_.new(dest, ent.rel, false) UI.important("Overriding file #{destent.path.sub!(File.dirname(dest), '<NEW-IPA>')}") unless !ent.file? || !File.exist?(destent.path) ent.copy(destent.path) end, proc do |ent| destent = FileUtils::Entry_.new(dest, ent.rel, false) ent.(destent.path) if preserve end) end |
.unpack_and_repack(output_name, ipa_path, contents) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/fastlane/plugin/repack_ios/helper/repack_ios_helper.rb', line 81 def self.unpack_and_repack(output_name, ipa_path, contents) ipa_original_path = File.join(File.dirname(ipa_path), "#{File.basename(ipa_path, '.ipa')}-original-#{Time.now.to_i}.ipa") ipa_tmp_path = Dir.mktmpdir begin UI.("Unpacking the ipa package...") Zip::File.open(ipa_path) do |zipfile| zipfile.each do |entry| extraction_path = File.join(ipa_tmp_path, entry.name) zipfile.extract(entry, extraction_path) end end ipa_new_payload_path = "#{ipa_tmp_path}/Payload/#{output_name}.app/" UI.("Re-generating the ipa package with new contents...") patch_ipa_contents(contents, ipa_new_payload_path, true) UI.("Backing-up the original ipa package...") File.rename(ipa_path, ipa_original_path) ZipFileGenerator.new(ipa_tmp_path, ipa_path).write ensure FileUtils.rm_rf(ipa_tmp_path) end return ipa_original_path end |