Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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 <jacknagel@gmail.com>
  • Loading branch information...
commit ed1a674c6256cdeb1089c1b1028199eac9249337 1 parent 71a53dc
Jack Nagel jacknagel authored
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
View
@@ -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
end
32 Library/Homebrew/keg.rb
View
@@ -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 path.directory? }
Keith Winstein
keithw added a note

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ link_dir('sbin') { |path| :skip if path.directory? }
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
end
end
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
elsif src.directory?
# if the dst dir already exists, then great! walk the rest of the tree tho
next if dst.directory? and not dst.symlink?
Keith Winstein

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.

Please sign in to comment.
Something went wrong with that request. Please try again.