keg: handle the info directory file properly

If HOMEBREW_KEEP_INFO environment variable is set:
 - Do not symlink the info directory file (aka 'share/info/dir')
   otherwise it gets overwritten by next installed brew.
 - Install an entry in the directory for each linked info file when the
   brew is linked.
 - Uninstall the entry when the brew is unlinked.

Closes Homebrew/homebrew#9700.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Nicolas Despres 2012-01-21 00:51:20 +01:00 committed by Jack Nagel
parent 212927ee54
commit d0be4d692b
5 changed files with 45 additions and 4 deletions

View File

@ -366,7 +366,10 @@ creating your own can be found on the wiki:
* HOMEBREW\_KEEP\_INFO: * HOMEBREW\_KEEP\_INFO:
If set, Homebrew will not remove files from `share/info`, allowing them If set, Homebrew will not remove files from `share/info`, allowing them
to be linked from the Cellar. to be linked from the Cellar. To access these info files, prepend
`share/info` to your `INFOPATH` environment variable.
*Example:* `export INFOPATH='/usr/local/share/info:/usr/share/info'`
* HOMEBREW\_MAKE\_JOBS: * HOMEBREW\_MAKE\_JOBS:
If set, instructs Homebrew to use the value of `HOMEBREW_MAKE_JOBS` as If set, instructs Homebrew to use the value of `HOMEBREW_MAKE_JOBS` as

View File

@ -3,7 +3,14 @@ class Cleaner
@f = Formula.factory f @f = Formula.factory f
[f.bin, f.sbin, f.lib].select{ |d| d.exist? }.each{ |d| clean_dir d } [f.bin, f.sbin, f.lib].select{ |d| d.exist? }.each{ |d| clean_dir d }
unless ENV['HOMEBREW_KEEP_INFO'] if ENV['HOMEBREW_KEEP_INFO']
# Get rid of the directory file, so it no longer bother us at link stage.
info_dir_file = f.info + 'dir'
if info_dir_file.file? and not f.skip_clean? info_dir_file
puts "rm #{info_dir_file}" if ARGV.verbose?
info_dir_file.unlink
end
else
f.info.rmtree if f.info.directory? and not f.skip_clean? f.info f.info.rmtree if f.info.directory? and not f.skip_clean? f.info
end end

View File

@ -262,6 +262,20 @@ class Pathname
ensure ensure
chmod saved_perms if saved_perms chmod saved_perms if saved_perms
end end
def install_info
unless self.symlink?
raise "Cannot install info entry for unbrewed info file '#{self}'"
end
system '/usr/bin/install-info', self.to_s, (self.dirname+'dir').to_s
end
def uninstall_info
unless self.symlink?
raise "Cannot uninstall info entry for unbrewed info file '#{self}'"
end
system '/usr/bin/install-info', '--delete', '--quiet', self.to_s, (self.dirname+'dir').to_s
end
end end
# sets $n and $d so you can observe creation of stuff # sets $n and $d so you can observe creation of stuff
@ -286,6 +300,14 @@ module ObserverPathnameExtension
puts "ln #{to_s}" if ARGV.verbose? puts "ln #{to_s}" if ARGV.verbose?
$n+=1 $n+=1
end end
def install_info
super
puts "info #{to_s}" if ARGV.verbose?
end
def uninstall_info
super
puts "uninfo #{to_s}" if ARGV.verbose?
end
end end
$n=0 $n=0

View File

@ -7,6 +7,8 @@ class Keg < Pathname
raise "#{to_s} is not a directory" unless directory? raise "#{to_s} is not a directory" unless directory?
end end
INFOFILE_RX = %r[/share/info/[^.].*?\.info$]
# if path is a file in a keg then this will return the containing Keg object # if path is a file in a keg then this will return the containing Keg object
def self.for path def self.for path
path = path.realpath path = path.realpath
@ -29,6 +31,7 @@ class Keg < Pathname
next if src == self next if src == self
dst=HOMEBREW_PREFIX+src.relative_path_from(self) dst=HOMEBREW_PREFIX+src.relative_path_from(self)
next unless dst.symlink? next unless dst.symlink?
dst.uninstall_info if dst.to_s =~ INFOFILE_RX and ENV['HOMEBREW_KEEP_INFO']
dst.unlink dst.unlink
n+=1 n+=1
Find.prune if src.directory? Find.prune if src.directory?
@ -127,7 +130,10 @@ protected
dst.extend ObserverPathnameExtension dst.extend ObserverPathnameExtension
if src.file? if src.file?
# Do the symlink.
dst.make_relative_symlink src unless File.basename(src) == '.DS_Store' 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']
elsif src.directory? elsif src.directory?
# if the dst dir already exists, then great! walk the rest of the tree tho # if the dst dir already exists, then great! walk the rest of the tree tho
next if dst.directory? and not dst.symlink? next if dst.directory? and not dst.symlink?

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "BREW" "1" "January 2012" "Homebrew" "brew" .TH "BREW" "1" "February 2012" "Homebrew" "brew"
. .
.SH "NAME" .SH "NAME"
\fBbrew\fR \- The missing package manager for OS X \fBbrew\fR \- The missing package manager for OS X
@ -403,7 +403,10 @@ If set, Homebrew will use this editor when editing a single formula, or several
. .
.TP .TP
HOMEBREW_KEEP_INFO HOMEBREW_KEEP_INFO
If set, Homebrew will not remove files from \fBshare/info\fR, allowing them to be linked from the Cellar\. If set, Homebrew will not remove files from \fBshare/info\fR, allowing them to be linked from the Cellar\. To access these info files, prepend \fBshare/info\fR to your \fBINFOPATH\fR environment variable\.
.
.IP
\fIExample:\fR \fBexport INFOPATH=\'/usr/local/share/info:/usr/share/info\'\fR
. .
.TP .TP
HOMEBREW_MAKE_JOBS HOMEBREW_MAKE_JOBS