fix_PATH changed to warn_about_macports_or_fink

We shouldn't mess with the user's PATH anyway. So assume our users are smart and just warn them about potential issues instead.
This commit is contained in:
Max Howell 2009-09-27 23:55:40 +01:00
parent fab877de18
commit 1004df181e
2 changed files with 34 additions and 18 deletions

View File

@ -228,21 +228,40 @@ def diy
end end
def fix_PATH def warn_about_macports_or_fink
bad_paths = `/usr/bin/which -a port`.split # See these issues for some history:
bad_paths += `/usr/bin/which -a fink`.split # http://github.com/mxcl/homebrew/issues/#issue/13
# http://github.com/mxcl/homebrew/issues/#issue/48
# don't remove standard paths!
bad_paths.delete_if do |pn| %w[port fink].each do |ponk|
%w[/usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/X11/bin].include? pn or pn.empty? path = `/usr/bin/which -s #{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
bad_paths += %w[/opt/local/bin /opt/local/sbin /sw/bin /sw/sbin]
# we do the above check because macports can be relocated and fink may be
paths = ENV['PATH'].split(':').reject do |p| # able to be relocated in the future. This following check is because if
p.squeeze! '/' # fink and macports are not in the PATH but are still installed it can
bad_paths.find { |pn| p =~ /^#{pn}/ } and true # *still* break the build -- because some build scripts hardcode these paths:
%w[/sw/bin/fink /opt/local/bin/port].each do |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
# 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
# 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.
%w[/sw /opt/local].each do |path|
if File.exist? path and not File.readable? path
opoo "It appears you have MacPorts or Fink installed"
puts "This has been known to cause build fails and other more subtle problems."
end
end end
ENV['PATH'] = paths*':'
end end

View File

@ -12,11 +12,6 @@ if %w[/ /usr].include? HOMEBREW_PREFIX.to_s then abort <<-EOS
EOS EOS
end end
# remove MacPorts and Fink from the PATH, this prevents issues like:
# http://github.com/mxcl/homebrew/issues/#issue/13
# http://github.com/mxcl/homebrew/issues/#issue/48
fix_PATH
if MACOS_VERSION < 10.5 if MACOS_VERSION < 10.5
onoe "Homebrew currently requires Leopard or higher" onoe "Homebrew currently requires Leopard or higher"
abort "Sorry about that, but thanks for your interest anyway!" abort "Sorry about that, but thanks for your interest anyway!"
@ -95,6 +90,8 @@ begin
raise "Interactive mode can only be used with one formula argument" raise "Interactive mode can only be used with one formula argument"
end end
warn_about_macports_or_fink # keep warning before dependency resolution
unless ARGV.force? unless ARGV.force?
unless system "/usr/bin/which -s #{ENV.cc}" unless system "/usr/bin/which -s #{ENV.cc}"
raise "We cannot find a c compiler, have you installed the latest Xcode?" raise "We cannot find a c compiler, have you installed the latest Xcode?"