aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/pkg.rb8
-rw-r--r--Library/Homebrew/cask/test/cask/pkg_test.rb17
2 files changed, 25 insertions, 0 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/pkg.rb b/Library/Homebrew/cask/lib/hbc/pkg.rb
index 2fb634f24..497a7b6dd 100644
--- a/Library/Homebrew/cask/lib/hbc/pkg.rb
+++ b/Library/Homebrew/cask/lib/hbc/pkg.rb
@@ -26,6 +26,7 @@ module Hbc
_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)
@@ -97,6 +98,13 @@ module Hbc
end
end
+ # Some pkgs (microsoft office for one) leave files (generally nibs) but
+ # report them as directories. We remove these as files instead.
+ def _delete_broken_file_dir(path)
+ return unless path.file? && !path.symlink?
+ @command.run!("/bin/rm", args: ["-f", "--", path], sudo: true)
+ end
+
# Some pkgs leave broken symlinks hanging around; we clean them out before
# attempting to rmdir to prevent extra cruft from lying around after
# uninstall
diff --git a/Library/Homebrew/cask/test/cask/pkg_test.rb b/Library/Homebrew/cask/test/cask/pkg_test.rb
index 85a42356e..b99d49ddd 100644
--- a/Library/Homebrew/cask/test/cask/pkg_test.rb
+++ b/Library/Homebrew/cask/test/cask/pkg_test.rb
@@ -68,6 +68,23 @@ describe Hbc::Pkg do
fake_dir.must_be :exist?
end
+ it "chokes on directories that are really files" do
+ pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand)
+
+ fake_dir = Pathname(Dir.mktmpdir)
+ fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) }
+
+ pkg.stubs(:pkgutil_bom_specials).returns([])
+ pkg.stubs(:pkgutil_bom_files).returns([])
+ pkg.stubs(:pkgutil_bom_dirs).returns([fake_file, fake_dir])
+ pkg.stubs(:forget)
+
+ pkg.uninstall
+
+ fake_file.wont_be :exist?
+ fake_dir.wont_be :exist?
+ end
+
it "snags permissions on ornery dirs, but returns them afterwords" do
pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand)