Fix linked keg-only check when only directories are linked

This commit is contained in:
Jack Nagel 2015-06-12 20:37:20 -04:00
parent aad4ed7faa
commit c4dfacaf0c

View File

@ -913,38 +913,25 @@ def check_for_autoconf
end
def __check_linked_brew f
links_found = []
prefix = f.prefix
prefix.find do |src|
next if src == prefix
dst = HOMEBREW_PREFIX + src.relative_path_from(prefix)
next if !dst.symlink? || !dst.exist? || src != dst.resolved_path
if src.directory?
Find.prune
else
links_found << dst
end
return true if dst.symlink? && src == dst.resolved_path
end
return links_found
false
end
def check_for_linked_keg_only_brews
return unless HOMEBREW_CELLAR.exist?
warnings = Hash.new
linked = Formula.select { |f|
f.keg_only? && f.installed? && __check_linked_brew(f)
}
Formula.each do |f|
next unless f.keg_only? and f.installed?
links = __check_linked_brew f
warnings[f.full_name] = links unless links.empty?
end
unless warnings.empty?
unless linked.empty?
s = <<-EOS.undent
Some keg-only formula are linked into the Cellar.
Linking a keg-only formula, such as gettext, into the cellar with
@ -958,7 +945,7 @@ def check_for_linked_keg_only_brews
You may wish to `brew unlink` these brews:
EOS
warnings.each_key { |f| s << " #{f}\n" }
linked.each { |f| s << " #{f.full_name}\n" }
s
end
end