Browse files

keg: allow selective linking at the file level

Some parts of a keg's tree are not subject to the cleaner, and sometimes
we still want to remove things in directories marked skip_clean; this
allows us that freedom.

If 'lib' is marked skip_clean, we still want to avoid linking the
charset.alias file into the top of the tree. The same needs to be done
for the locale.alias file in share/locale.

Signed-off-by: Jack Nagel <>
  • Loading branch information...
1 parent 71a53dc commit ed1a674c6256cdeb1089c1b1028199eac9249337 @jacknagel jacknagel committed Feb 27, 2012
Showing with 21 additions and 13 deletions.
  1. +0 −2 Library/Homebrew/cleaner.rb
  2. +21 −11 Library/Homebrew/keg.rb
2 Library/Homebrew/cleaner.rb
@@ -78,8 +78,6 @@ def clean_dir d
elsif path.extname == '.la'
# *.la files are stupid
path.unlink unless @f.skip_clean? path
- elsif path == @f.lib+'charset.alias'
- path.unlink unless @f.skip_clean? path
elsif not path.symlink?
clean_file path
32 Library/Homebrew/keg.rb
@@ -9,7 +9,7 @@ def initialize path
# locale-specific directories have the form language[_territory][.codeset][@modifier]
LOCALEDIR_RX = /(locale|man)\/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?/
- INFOFILE_RX = %r[/share/info/[^.].*?\.info$]
+ INFOFILE_RX = %r[info/[^.].*?\.info$]
# if path is a file in a keg then this will return the containing Keg object
def self.for path
@@ -68,20 +68,23 @@ def link
# 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
link_dir('etc') {:mkpath}
- link_dir('bin') {:skip}
- link_dir('sbin') {:link}
+ link_dir('bin') { |path| :skip if }
keithw Mar 11, 2012

Unfortunately this doesn't work -- the block is passed a RELATIVE pathname, so the result is to evaluate whether there is a directory by this name in the user's cwd from where they ran "brew install", not whether the file to be linked (from within bin) is a directory.

As a consequence, post this commit brew will skip linking files that have the same name as a directory in the user's cwd.

+ link_dir('sbin') { |path| :skip if }
link_dir('include') {:link}
link_dir('share') do |path|
- if path.to_s =~ LOCALEDIR_RX
- :mkpath
- elsif share_mkpaths.include? path.to_s
- :mkpath
+ case path.to_s
+ when 'locale/locale.alias' then :skip
+ when INFOFILE_RX then :info if ENV['HOMEBREW_KEEP_INFO']
+ when LOCALEDIR_RX then :mkpath
+ when *share_mkpaths then :mkpath
+ else :link
link_dir('lib') do |path|
case path.to_s
+ when 'charset.alias' then :skip
# pkg-config database gets explicitly created
when 'pkgconfig' then :mkpath
# lib/language folders also get explicitly created
@@ -131,10 +134,17 @@ def link_dir foo
dst.extend ObserverPathnameExtension
if src.file?
- # Do the symlink.
- dst.make_relative_symlink src unless File.basename(src) == '.DS_Store'
- # Install info file entries in the info directory file
- dst.install_info if dst.to_s =~ INFOFILE_RX and ENV['HOMEBREW_KEEP_INFO']
+ Find.prune if File.basename(src) == '.DS_Store'
+ case yield src.relative_path_from(root)
+ when :skip
+ Find.prune
+ when :info
+ dst.make_relative_symlink(src)
+ dst.install_info
+ else
+ dst.make_relative_symlink(src)
+ end
# if the dst dir already exists, then great! walk the rest of the tree tho
next if and not dst.symlink?

0 comments on commit ed1a674

Please sign in to comment.