keg: don't skip linking based on relative pathname

ed1a674c ("keg: allow selective linking at the file level") had a
regression which caused the link step to skip files with the same name
as a directory in the user's CWD.

Keg#link_dir yields a relative pathname, so assumptions cannot be made
about the nature of that pathname in the block.

Instead, introduce ":skip_dir" and ":skip_file" to replace the existing
":skip" directive. This way, we won't skip things marked ":skip_dir"
when linking a file, and vice-versa.

Fixes Homebrew/homebrew#10860.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jack Nagel 2012-03-11 10:18:12 -05:00
parent 27288547aa
commit 5b1957f13a

View File

@ -68,13 +68,13 @@ class Keg < Pathname
# yeah indeed, you have to force anything you need in the main tree into # yeah indeed, you have to force anything you need in the main tree into
# these dirs REMEMBER that *NOT* everything needs to be in the main tree # these dirs REMEMBER that *NOT* everything needs to be in the main tree
link_dir('etc') {:mkpath} link_dir('etc') {:mkpath}
link_dir('bin') { |path| :skip if path.directory? } link_dir('bin') {:skip_dir}
link_dir('sbin') { |path| :skip if path.directory? } link_dir('sbin') {:skip_dir}
link_dir('include') {:link} link_dir('include') {:link}
link_dir('share') do |path| link_dir('share') do |path|
case path.to_s case path.to_s
when 'locale/locale.alias' then :skip when 'locale/locale.alias' then :skip_file
when INFOFILE_RX then :info if ENV['HOMEBREW_KEEP_INFO'] when INFOFILE_RX then :info if ENV['HOMEBREW_KEEP_INFO']
when LOCALEDIR_RX then :mkpath when LOCALEDIR_RX then :mkpath
when *share_mkpaths then :mkpath when *share_mkpaths then :mkpath
@ -84,7 +84,7 @@ class Keg < Pathname
link_dir('lib') do |path| link_dir('lib') do |path|
case path.to_s case path.to_s
when 'charset.alias' then :skip when 'charset.alias' then :skip_file
# pkg-config database gets explicitly created # pkg-config database gets explicitly created
when 'pkgconfig' then :mkpath when 'pkgconfig' then :mkpath
# lib/language folders also get explicitly created # lib/language folders also get explicitly created
@ -138,7 +138,7 @@ protected
Find.prune if File.basename(src) == '.DS_Store' Find.prune if File.basename(src) == '.DS_Store'
case yield src.relative_path_from(root) case yield src.relative_path_from(root)
when :skip when :skip_file
Find.prune Find.prune
when :info when :info
dst.make_relative_symlink(src) dst.make_relative_symlink(src)
@ -155,7 +155,7 @@ protected
Find.prune if src.extname.to_s == '.app' Find.prune if src.extname.to_s == '.app'
case yield src.relative_path_from(root) case yield src.relative_path_from(root)
when :skip when :skip_dir
Find.prune Find.prune
when :mkpath when :mkpath
dst.mkpath unless resolve_any_conflicts(dst) dst.mkpath unless resolve_any_conflicts(dst)