diff options
| author | Adam Vandenberg | 2010-06-28 09:39:14 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-06-28 17:26:16 -0700 |
| commit | c6e77569ca64016efc701e7bb34c0ad7812e958f (patch) | |
| tree | 52aae16c651123f1c015d8a21025f68e6effb2fb /Library | |
| parent | 427d9a5d2bea8343663962634a18a31176067306 (diff) | |
| download | homebrew-c6e77569ca64016efc701e7bb34c0ad7812e958f.tar.bz2 | |
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
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/brew_doctor.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Library/Homebrew/brew_doctor.rb b/Library/Homebrew/brew_doctor.rb index e27967701..ea907a177 100644 --- a/Library/Homebrew/brew_doctor.rb +++ b/Library/Homebrew/brew_doctor.rb @@ -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 |
