Always link symlinks directly

This commit is contained in:
Jack Nagel 2014-07-12 19:56:58 -05:00
parent 1fb1677532
commit 7b26c885bd
2 changed files with 19 additions and 10 deletions

View File

@ -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

View File

@ -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