Sha256: 7a21875c6b299afcd61d03810e7d70810e49f01a72b613fd26f5daad21a7b674

Contents?: true

Size: 1.46 KB

Versions: 70

Compression:

Stored size: 1.46 KB

Contents

require 'rexml/document'

require_relative 'helper'

module FastlaneCore
  class PkgFileAnalyser
    def self.fetch_app_identifier(path)
      xml = self.fetch_distribution_xml_file(path)
      return xml.elements['installer-gui-script/product'].attributes['id'] if xml
      return nil
    end

    # Fetches the app version from the given pkg file.
    def self.fetch_app_version(path)
      xml = self.fetch_distribution_xml_file(path)
      return xml.elements['installer-gui-script/product'].attributes['version'] if xml
      return nil
    end

    # Fetches the app version from the given pkg file.
    def self.fetch_app_build(path)
      xml = self.fetch_distribution_xml_file(path)
      return xml.elements['installer-gui-script/pkg-ref/bundle-version/bundle'].attributes['CFBundleVersion'] if xml
      return nil
    end

    def self.fetch_distribution_xml_file(path)
      Dir.mktmpdir do |dir|
        Helper.backticks("xar -C #{dir.shellescape} -xf #{path.shellescape}")

        Dir.foreach(dir) do |file|
          next unless file.include?('Distribution')

          begin
            content = File.open(File.join(dir, file))
            xml = REXML::Document.new(content)

            if xml.elements['installer-gui-script/product']
              return xml
            end
          rescue => ex
            UI.error(ex)
            UI.error("Error parsing *.pkg distribution xml #{File.join(dir, file)}")
          end
        end

        nil
      end
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
fastlane-2.193.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.192.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.191.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.190.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.189.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.188.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.187.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.186.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.185.1 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.185.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.184.1 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.184.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.183.2 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.183.1 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.183.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.182.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.181.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.180.1 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.180.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.179.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb