diff options
| author | Markus Reiter | 2016-11-21 10:25:30 +0100 |
|---|---|---|
| committer | GitHub | 2016-11-21 10:25:30 +0100 |
| commit | cc7541cbc43fed20626f654dcea74c2a4951706a (patch) | |
| tree | e3fd573f6a4d7d130d6280f09ce2907b7d92626e /Library/Homebrew/cask/lib | |
| parent | 6b2242822b30f7a0d4c4399d782dc3d091aba12b (diff) | |
| parent | df635c8259dffca891424352765088a3b88a87d2 (diff) | |
| download | brew-cc7541cbc43fed20626f654dcea74c2a4951706a.tar.bz2 | |
Merge pull request #1535 from umireon/cask-pkg-choice
Cask: Add the choices option to pkg stanza
Diffstat (limited to 'Library/Homebrew/cask/lib')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/artifact/pkg.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb index d5e63d8ef..0569d2a86 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb @@ -2,6 +2,8 @@ require "hbc/artifact/base" require "hbc/utils/hash_validator" +require "vendor/plist/plist" + module Hbc module Artifact class Pkg < Base @@ -16,7 +18,7 @@ module Hbc @pkg_install_opts = pkg_description.shift begin if @pkg_install_opts.respond_to?(:keys) - @pkg_install_opts.extend(HashValidator).assert_valid_keys(:allow_untrusted) + @pkg_install_opts.extend(HashValidator).assert_valid_keys(:allow_untrusted, :choices) elsif @pkg_install_opts raise end @@ -52,7 +54,24 @@ module Hbc ] args << "-verboseR" if Hbc.verbose args << "-allowUntrusted" if pkg_install_opts :allow_untrusted - @command.run!("/usr/sbin/installer", sudo: true, args: args, print_stdout: true) + 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 + return yield nil unless pkg_install_opts(:choices) + + Tempfile.open(["choices", ".xml"]) do |file| + begin + file.write Plist::Emit.dump(pkg_install_opts(:choices)) + file.close + yield file.path + ensure + file.unlink + end + end end end end |
