diff options
| author | Markus Reiter | 2017-03-08 03:03:49 +0100 |
|---|---|---|
| committer | Markus Reiter | 2017-03-08 08:16:16 +0100 |
| commit | 17bd6fe3cafaa018c61a51b3b86ead40d6d28014 (patch) | |
| tree | 5f902d359d083dfe13f1b56261c40b13bf0b1cce /Library/Homebrew | |
| parent | 2691eb6f6501cb34f2e62656418922733b111696 (diff) | |
| download | brew-17bd6fe3cafaa018c61a51b3b86ead40d6d28014.tar.bz2 | |
Refactor Cask `pkg` artifact.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/container/dmg.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/pkg.rb | 35 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/system_command.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/pkg_spec.rb | 2 |
4 files changed, 25 insertions, 18 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/container/dmg.rb b/Library/Homebrew/cask/lib/hbc/container/dmg.rb index 815f8f010..1b96df4ec 100644 --- a/Library/Homebrew/cask/lib/hbc/container/dmg.rb +++ b/Library/Homebrew/cask/lib/hbc/container/dmg.rb @@ -31,7 +31,7 @@ module Hbc plist = @command.run!("/usr/bin/hdiutil", # realpath is a failsafe against unusual filenames args: %w[mount -plist -nobrowse -readonly -noidme -mountrandom /tmp] + [Pathname.new(@path).realpath], - input: %w[y]) + input: "y\n") .plist @mounts = mounts_from_plist(plist) end diff --git a/Library/Homebrew/cask/lib/hbc/pkg.rb b/Library/Homebrew/cask/lib/hbc/pkg.rb index 39252b48a..87a87c3cc 100644 --- a/Library/Homebrew/cask/lib/hbc/pkg.rb +++ b/Library/Homebrew/cask/lib/hbc/pkg.rb @@ -14,24 +14,31 @@ module Hbc end def uninstall - odebug "Deleting pkg files" - pkgutil_bom_files.each_slice(500) do |file_slice| - @command.run("/bin/rm", args: file_slice.unshift("-f", "--"), sudo: true) + unless pkgutil_bom_files.empty? + odebug "Deleting pkg files" + @command.run("/usr/bin/xargs", args: ["-0", "--", "/bin/rm", "-f", "--"], input: pkgutil_bom_files.join("\0"), sudo: true) end - odebug "Deleting pkg symlinks and special files" - pkgutil_bom_specials.each_slice(500) do |file_slice| - @command.run("/bin/rm", args: file_slice.unshift("-f", "--"), sudo: true) + + unless pkgutil_bom_specials.empty? + odebug "Deleting pkg symlinks and special files" + @command.run("/usr/bin/xargs", args: ["-0", "--", "/bin/rm", "-f", "--"], input: pkgutil_bom_specials.join("\0"), sudo: true) end - odebug "Deleting pkg directories" - _deepest_path_first(pkgutil_bom_dirs).each do |dir| - next unless dir.exist? && !MacOS.undeletable?(dir) - _with_full_permissions(dir) do - _delete_broken_file_dir(dir) && next - _clean_broken_symlinks(dir) - _clean_ds_store(dir) - _rmdir(dir) + + unless pkgutil_bom_dirs.empty? + odebug "Deleting pkg directories" + _deepest_path_first(pkgutil_bom_dirs).each do |dir| + next if MacOS.undeletable?(dir) + next unless dir.exist? + + _with_full_permissions(dir) do + _delete_broken_file_dir(dir) && next + _clean_broken_symlinks(dir) + _clean_ds_store(dir) + _rmdir(dir) + end end end + forget end diff --git a/Library/Homebrew/cask/lib/hbc/system_command.rb b/Library/Homebrew/cask/lib/hbc/system_command.rb index 17658bdfa..c14079bc8 100644 --- a/Library/Homebrew/cask/lib/hbc/system_command.rb +++ b/Library/Homebrew/cask/lib/hbc/system_command.rb @@ -79,7 +79,7 @@ module Hbc raw_stdin, raw_stdout, raw_stderr, raw_wait_thr = Open3.popen3(*expanded_command) - write_input_to(raw_stdin) if options[:input] + write_input_to(raw_stdin) raw_stdin.close_write each_line_from [raw_stdout, raw_stderr], &b @@ -87,7 +87,7 @@ module Hbc end def write_input_to(raw_stdin) - Array(options[:input]).each { |line| raw_stdin.puts line } + [*options[:input]].each { |line| raw_stdin.print line } end def each_line_from(sources) diff --git a/Library/Homebrew/test/cask/pkg_spec.rb b/Library/Homebrew/test/cask/pkg_spec.rb index 78a2eb75e..a77ce85b9 100644 --- a/Library/Homebrew/test/cask/pkg_spec.rb +++ b/Library/Homebrew/test/cask/pkg_spec.rb @@ -1,5 +1,5 @@ describe Hbc::Pkg, :cask do - describe "uninstall" do + describe "#uninstall" do let(:fake_system_command) { Hbc::NeverSudoSystemCommand } let(:empty_response) { double(stdout: "") } let(:pkg) { described_class.new("my.fake.pkg", fake_system_command) } |
