Skip to content

Commit

Permalink
Merge pull request Homebrew#3256 from claui/pkg-unshadow-options
Browse files Browse the repository at this point in the history
Unshadow `allow_untrusted` option for pkg artifact
  • Loading branch information
reitermarkus authored Oct 3, 2017
2 parents ec0d8fa + fbd526f commit 7ee86cf
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Library/Homebrew/cask/lib/hbc/artifact/pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ module Artifact
class Pkg < AbstractArtifact
attr_reader :pkg_relative_path

def self.from_args(cask, path, **options)
options.extend(HashValidator).assert_valid_keys(:allow_untrusted, :choices)
new(cask, path, **options)
def self.from_args(cask, path, **stanza_options)
stanza_options.extend(HashValidator).assert_valid_keys(
:allow_untrusted, :choices
)
new(cask, path, **stanza_options)
end

attr_reader :path, :options
attr_reader :path, :stanza_options

def initialize(cask, path, **options)
def initialize(cask, path, **stanza_options)
super(cask)
@path = cask.staged_path.join(path)
@options = options
@stanza_options = stanza_options
end

def summarize
Expand All @@ -32,7 +34,7 @@ def install_phase(**options)

private

def run_installer(command: nil, verbose: false, **options)
def run_installer(command: nil, verbose: false, **_options)
ohai "Running installer for #{cask}; your password may be necessary."
ohai "Package installers may write to any location; options such as --appdir are ignored."
unless path.exist?
Expand All @@ -43,15 +45,17 @@ def run_installer(command: nil, verbose: false, **options)
"-target", "/"
]
args << "-verboseR" if verbose
args << "-allowUntrusted" if options.fetch(:allow_untrusted, false)
if stanza_options.fetch(:allow_untrusted, false)
args << "-allowUntrusted"
end
with_choices_file do |choices_path|
args << "-applyChoiceChangesXML" << choices_path if choices_path
command.run!("/usr/sbin/installer", sudo: true, args: args, print_stdout: true)
end
end

def with_choices_file
choices = options.fetch(:choices, {})
choices = stanza_options.fetch(:choices, {})
return yield nil if choices.empty?

Tempfile.open(["choices", ".xml"]) do |file|
Expand Down

0 comments on commit 7ee86cf

Please sign in to comment.