From 20ecb8d032c9c0a60a671605443fece3172315d3 Mon Sep 17 00:00:00 2001 From: Mark Imbriaco Date: Fri, 2 Oct 2009 16:57:48 -0400 Subject: [PATCH] Fix brew if it's symlinked from elsewhere Follow symlinks when trying to find HOMEBREW_RUBYLIB. Signed-off-by: Max Howell 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 --- bin/brew | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/bin/brew b/bin/brew index 60496dd540..b1d54fdcb6 100755 --- a/bin/brew +++ b/bin/brew @@ -1,7 +1,20 @@ #!/usr/bin/ruby # -*- 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 'brew.h' @@ -11,10 +24,8 @@ if %w[/ /usr].include? HOMEBREW_PREFIX.to_s then abort <<-EOS #{HOMEBREW_WWW} EOS end - if MACOS_VERSION < 10.5 - onoe "Homebrew currently requires Leopard or higher" - abort "Sorry about that, but thanks for your interest anyway!" + abort "Homebrew requires Leopard or higher, but you could fork it and fix that..." end case Hardware.cpu_type when :ppc, :dunno abort "Sorry, Homebrew does not support your computer's CPU architecture." @@ -144,7 +155,7 @@ begin # to make the formula script the executed script pid=fork 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 Process.wait pid end