More useful Macports/Fink detection function

This commit is contained in:
Max Howell 2009-10-26 18:14:39 +00:00
parent adf8d30a92
commit e046e1e640
2 changed files with 13 additions and 20 deletions

View File

@ -262,45 +262,37 @@ def diy
end end
end end
def macports_or_fink_installed?
def warn_about_macports_or_fink
# See these issues for some history: # See these issues for some history:
# http://github.com/mxcl/homebrew/issues/#issue/13 # http://github.com/mxcl/homebrew/issues/#issue/13
# http://github.com/mxcl/homebrew/issues/#issue/41 # http://github.com/mxcl/homebrew/issues/#issue/41
# http://github.com/mxcl/homebrew/issues/#issue/48 # http://github.com/mxcl/homebrew/issues/#issue/48
%w[port fink].each do |ponk| %w[port fink].each do |ponk|
path = `/usr/bin/which -s #{ponk}` path = `/usr/bin/which -s #{ponk}`
unless path.empty? return ponk unless path.empty?
opoo "It appears you have Macports or Fink in your PATH"
puts "If formula fail to build try renaming or uninstalling these tools."
end
end end
# we do the above check because macports can be relocated and fink may be # we do the above check because macports can be relocated and fink may be
# able to be relocated in the future. This following check is because if # able to be relocated in the future. This following check is because if
# fink and macports are not in the PATH but are still installed it can # fink and macports are not in the PATH but are still installed it can
# *still* break the build -- because some build scripts hardcode these paths: # *still* break the build -- because some build scripts hardcode these paths:
%w[/sw/bin/fink /opt/local/bin/port].each do |ponk| %w[/sw/bin/fink /opt/local/bin/port].each do |ponk|
if File.exist? ponk return ponk if File.exist? ponk
opoo "It appears you have MacPorts or Fink installed"
puts "If formula fail to build, consider renaming: %s" % Pathname.new(ponk).dirname.parent
end
end end
# finally sometimes people make their MacPorts or Fink read-only so they # finally, sometimes people make their MacPorts or Fink read-only so they
# can quickly test Homebrew out, but still in theory obey the README's # can quickly test Homebrew out, but still in theory obey the README's
# advise to rename the root directory. This doesn't work, many build scripts # advise to rename the root directory. This doesn't work, many build scripts
# error out when they try to read from these now unreadable directories. # error out when they try to read from these now unreadable directories.
%w[/sw /opt/local].each do |path| %w[/sw /opt/local].each do |path|
if File.exist? path and not File.readable? path path = Pathname.new(path)
opoo "It appears you have MacPorts or Fink installed" return path if path.exist? and not path.readable?
puts "This has been known to cause build fails and other more subtle problems."
end
end end
false
end end
def versions_of(keg_name) def versions_of(keg_name)
`ls #{HOMEBREW_CELLAR}/#{keg_name}`.collect { |version| version.strip }.reverse `ls #{HOMEBREW_CELLAR}/#{keg_name}`.collect { |version| version.strip }.reverse
end end

View File

@ -296,7 +296,8 @@ rescue Exception => e
puts "Please report this bug at: #{HOMEBREW_WWW}" puts "Please report this bug at: #{HOMEBREW_WWW}"
puts "Please include the following information:" puts "Please include the following information:"
ohai "Environment" ohai "Environment"
puts "Mac OS X: "+`sw_vers -productVersion` puts "Mac OS X #{MACOS_VERSION}"
puts "Macports or Fink? #{macports_or_fink_installed?}"
ohai e.inspect ohai e.inspect
puts e.backtrace puts e.backtrace
exit 1 exit 1