diff options
| author | Claudia | 2017-10-02 00:26:58 +0200 |
|---|---|---|
| committer | Claudia | 2017-10-02 13:34:57 +0200 |
| commit | fbd526ffe6a619d538193fbc7eb93b6e74c44b00 (patch) | |
| tree | 8d9385a7f5bb2edbba64c1d21e1a941c1aa2cabf | |
| parent | e86c79fbc01d08f73841a525d29c03c5243081fa (diff) | |
| download | brew-fbd526ffe6a619d538193fbc7eb93b6e74c44b00.tar.bz2 | |
Unshadow `allow_untrusted` option for pkg artifact
The pkg stanza has an option called `allow_untrusted`, which is
supposed to cause `/usr/sbin/installer` to be called with the
`-allowUntrusted` switch.
PR #3141 seems to have renamed the `pkg_install_opts` field to
`options`. At the same time, it introduces an `options` parameter for
the `run_installer` method, which shadows the `options` getter
method, causing the `allow_untrusted` option to be silently ignored.
The issue affects just the `pkg` stanza because `Hbc::Artifact::Pkg`
is the only artifact class that has an `options` method.
This commit removes the shadowing by renaming the field to
`stanza_options`; in one case, it uses `_options` for a parameter
name (instead of the more canonical `_`) for the sake of clarity.
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/artifact/pkg.rb | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb index 0967fd99d..b4bdf3de6 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb @@ -9,17 +9,19 @@ module Hbc 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 @@ -32,7 +34,7 @@ module Hbc 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? @@ -43,7 +45,9 @@ module Hbc "-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) @@ -51,7 +55,7 @@ module Hbc 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| |
