Fix brew if it's symlinked from elsewhere

Follow symlinks when trying to find HOMEBREW_RUBYLIB.

Signed-off-by: Max Howell <max@methylblue.com>

This is now supported usage, it wasn't before. I amended the patch quite heavily because it broke our other supported usage, ie. complete symlinking of Homebrew into /usr/local
This commit is contained in:
Mark Imbriaco 2009-10-02 16:57:48 -04:00 committed by Max Howell
parent 65eac81ca9
commit 20ecb8d032

View File

@ -1,7 +1,20 @@
#!/usr/bin/ruby #!/usr/bin/ruby
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
ENV['RUBYLIB']=HOMEBREW_RUBYLIB=File.expand_path(__FILE__+'/../../Library/Homebrew')
$:.unshift HOMEBREW_RUBYLIB def homebrew_rubylib_path
lib_path = "/../../Library/Homebrew"
# we resolve off of Dir.getwd as otherwise the symlink gets resolved!
brew_path = if not File.symlink? __FILE__ or File.exist? Dir.getwd+'/'+__FILE__+lib_path
# standard 100% symlinked or non-symlinked installation
__FILE__
else
# non-standard installation -- just this script is symlinked
File.readlink(__FILE__)
end
return File.expand_path(brew_path+lib_path)
end
$:.unshift homebrew_rubylib_path
require 'global' require 'global'
require 'brew.h' require 'brew.h'
@ -11,10 +24,8 @@ if %w[/ /usr].include? HOMEBREW_PREFIX.to_s then abort <<-EOS
#{HOMEBREW_WWW} #{HOMEBREW_WWW}
EOS EOS
end end
if MACOS_VERSION < 10.5 if MACOS_VERSION < 10.5
onoe "Homebrew currently requires Leopard or higher" abort "Homebrew requires Leopard or higher, but you could fork it and fix that..."
abort "Sorry about that, but thanks for your interest anyway!"
end end
case Hardware.cpu_type when :ppc, :dunno case Hardware.cpu_type when :ppc, :dunno
abort "Sorry, Homebrew does not support your computer's CPU architecture." abort "Sorry, Homebrew does not support your computer's CPU architecture."
@ -144,7 +155,7 @@ begin
# to make the formula script the executed script # to make the formula script the executed script
pid=fork pid=fork
if pid.nil? if pid.nil?
exec 'ruby', '-r', "#{HOMEBREW_RUBYLIB}/install", f.path, '--', *ARGV.options exec 'ruby', '-I', homebrew_rubylib_path, '-rinstall', f.path, '--', *ARGV.options
else else
Process.wait pid Process.wait pid
end end