aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-08 03:03:49 +0100
committerMarkus Reiter2017-03-08 08:16:16 +0100
commit17bd6fe3cafaa018c61a51b3b86ead40d6d28014 (patch)
tree5f902d359d083dfe13f1b56261c40b13bf0b1cce /Library/Homebrew/cask/lib
parent2691eb6f6501cb34f2e62656418922733b111696 (diff)
downloadbrew-17bd6fe3cafaa018c61a51b3b86ead40d6d28014.tar.bz2
Refactor Cask `pkg` artifact.
Diffstat (limited to 'Library/Homebrew/cask/lib')
-rw-r--r--Library/Homebrew/cask/lib/hbc/container/dmg.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/pkg.rb35
-rw-r--r--Library/Homebrew/cask/lib/hbc/system_command.rb4
3 files changed, 24 insertions, 17 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)