Add brew doctor check for Cellar and TMP on separate volumes.

Add a brew doctor check for this issue:
http://github.com/mxcl/homebrew/issues/issue/1238
This commit is contained in:
Adam Vandenberg 2010-06-28 09:39:14 -07:00
parent 0152384487
commit 480accdd47

View File

@ -1,3 +1,34 @@
class Volumes
def initialize
@volumes = []
raw_mounts=`mount`
raw_mounts.split("\n").each do |line|
case line
when /^(.+) on (\S+) \(/
@volumes << [$1, $2]
end
end
# Sort volumes by longest path prefix first
@volumes.sort! {|a,b| b[1].length <=> a[1].length}
end
def which path
@volumes.each_index do |i|
vol = @volumes[i]
return i if is_prefix?(vol[1], path)
end
return -1
end
end
def is_prefix? prefix, longer_string
p = prefix.to_s
longer_string.to_s[0,p.length] == p
end
def check_for_stray_dylibs
bad_dylibs = Dir['/usr/local/lib/*.dylib'].select { |f| File.file? f and not File.symlink? f }
if bad_dylibs.length > 0
@ -291,6 +322,35 @@ def check_for_symlinked_cellar
end
end
def check_for_multiple_volumes
volumes = Volumes.new
# Find the volumes for the TMP folder & HOMEBREW_CELLAR
real_cellar = HOMEBREW_CELLAR.realpath
tmp=Pathname.new `/usr/bin/mktemp -d /tmp/homebrew-brew-doctor-XXXX`.strip
real_temp = tmp.realpath.parent
where_cellar = volumes.which real_cellar
where_temp = volumes.which real_temp
unless where_cellar == where_temp
puts <<-EOS.undent
Your Cellar and TMP folders are on different volumes.
Putting your Cellar and TMP folders on different volumes causes problems
for brews that install symlinks, such as Git.
Please post the details of your setup to this existing issue, if the comments
there don't already capture them:
http://github.com/mxcl/homebrew/issues/issue/1238
A work-around is available in this branch:
http://github.com/adamv/homebrew/tree/temp
EOS
end
end
def brew_doctor
read, write = IO.pipe
@ -312,6 +372,7 @@ def brew_doctor
check_for_config_scripts
check_for_dyld_vars
check_for_symlinked_cellar
check_for_multiple_volumes
exit! 0
else