From d4df9d44e09df6197275113b266df2b7d51a0339 Mon Sep 17 00:00:00 2001 From: Naoto Kaneko Date: Thu, 23 Feb 2017 16:49:14 +0900 Subject: [PATCH 1/3] Exclude executables from metafiles Exclude executables in #empty_installation? to avoid 'Empty Installation' error when only executable which name is the same as one of metafiles is installed. --- Library/Homebrew/keg.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 94e3ff55bf..9849a291ee 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -208,6 +208,7 @@ class Keg def empty_installation? Pathname.glob("#{path}/**/*") do |file| + return false if file.executable? next if file.directory? basename = file.basename.to_s next if Metafiles.copy?(basename) From 56a0afe5792d398d1682426bbebb1e53346b34d5 Mon Sep 17 00:00:00 2001 From: Naoto Kaneko Date: Fri, 24 Feb 2017 17:44:18 +0900 Subject: [PATCH 2/3] Extend #ds_file? in Pathname --- Library/Homebrew/extend/pathname.rb | 4 ++++ Library/Homebrew/test/pathname_test.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index cfb0287041..12dca4320a 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -457,6 +457,10 @@ class Pathname end end + def ds_store? + basename.to_s == ".DS_Store" + end + # https://bugs.ruby-lang.org/issues/9915 if RUBY_VERSION == "2.0.0" prepend Module.new { diff --git a/Library/Homebrew/test/pathname_test.rb b/Library/Homebrew/test/pathname_test.rb index b48a26fbd3..0107c8675a 100644 --- a/Library/Homebrew/test/pathname_test.rb +++ b/Library/Homebrew/test/pathname_test.rb @@ -166,6 +166,11 @@ class PathnameTests < Homebrew::TestCase @dir.cp_path_sub @src, @dst assert_predicate @dst/@dir.basename, :directory? end + + def test_ds_store + refute_predicate @file, :ds_store? + assert_predicate @src/".DS_Store", :ds_store? + end end class PathnameInstallTests < Homebrew::TestCase From ccc9b2dc6dc27026673db3c8871c691be9541342 Mon Sep 17 00:00:00 2001 From: Naoto Kaneko Date: Fri, 24 Feb 2017 17:44:27 +0900 Subject: [PATCH 3/3] Check for metafiles only in the root directory --- Library/Homebrew/keg.rb | 5 ++--- Library/Homebrew/test/keg_test.rb | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 9849a291ee..9ebfc3bc32 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -207,9 +207,8 @@ class Keg alias eql? == def empty_installation? - Pathname.glob("#{path}/**/*") do |file| - return false if file.executable? - next if file.directory? + Pathname.glob("#{path}/*") do |file| + return false if file.directory? && !file.children.reject(&:ds_store?).empty? basename = file.basename.to_s next if Metafiles.copy?(basename) next if %w[.DS_Store INSTALL_RECEIPT.json].include?(basename) diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index bd42320383..e8f99b7772 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -59,6 +59,10 @@ class LinkTests < LinkTestCase (@keg/"bin").rmtree assert_predicate @keg, :empty_installation? + + (@keg/"bin").mkpath + touch @keg.join("bin", "todo") + refute_predicate @keg, :empty_installation? end def test_linking_keg