From 7b26c885bd4cdb6ae50331082b368118c6c81ed1 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 12 Jul 2014 19:56:58 -0500 Subject: [PATCH] Always link symlinks directly --- Library/Homebrew/keg.rb | 11 +---------- Library/Homebrew/test/test_keg.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 6a00ed16b1..45aab7eb46 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -384,7 +384,7 @@ class Keg dst = HOMEBREW_PREFIX + src.relative_path_from(path) dst.extend ObserverPathnameExtension - if src.file? + if src.symlink? || src.file? Find.prune if File.basename(src) == '.DS_Store' # Don't link pyc files because Python overwrites these cached object # files and next time brew wants to link, the pyc file is in the way. @@ -403,15 +403,6 @@ class Keg make_relative_symlink dst, src, mode end elsif src.directory? - # If the `src` in the Cellar is a symlink itself, link it directly. - # For example Qt has `Frameworks/QtGui.framework -> lib/QtGui.framework` - # Not making a link here, would result in an empty dir because the - # `src` is not followed by `find`. - if src.symlink? && !dst.exist? - make_relative_symlink dst, src, mode - Find.prune - end - # if the dst dir already exists, then great! walk the rest of the tree tho next if dst.directory? and not dst.symlink? # no need to put .app bundles in the path, the user can just use diff --git a/Library/Homebrew/test/test_keg.rb b/Library/Homebrew/test/test_keg.rb index c30096ea39..e415be4334 100644 --- a/Library/Homebrew/test/test_keg.rb +++ b/Library/Homebrew/test/test_keg.rb @@ -199,4 +199,22 @@ class LinkTests < Homebrew::TestCase @dst.delete assert_equal 3, @keg.unlink end + + def test_pkgconfig_is_mkpathed + link = HOMEBREW_PREFIX.join("lib", "pkgconfig") + @keg.join("lib", "pkgconfig").mkpath + @keg.link + assert_predicate link.lstat, :directory? + end + + def test_symlinks_are_linked_directly + link = HOMEBREW_PREFIX.join("lib", "pkgconfig") + + @keg.join("lib", "example").mkpath + @keg.join("lib", "pkgconfig").make_symlink "example" + @keg.link + + assert_predicate link.resolved_path, :symlink? + assert_predicate link.lstat, :symlink? + end end