From 0efd1b9efefe107f637784c90643d512bd060c2c Mon Sep 17 00:00:00 2001 From: Max Howell Date: Mon, 27 Aug 2012 12:02:57 -0400 Subject: [PATCH] Attempt to fix opt link if absent This is mainly to prevent errors when users for the transitionary period where most installed kegs do not have an opt link. --- Library/Homebrew/build.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index eb3431b9c1..3c15be352a 100755 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -67,10 +67,7 @@ def install f keg_only_deps.each do |dep| opt = HOMEBREW_PREFIX/:opt/dep.name - - #TODO try to fix, if only one key, easy, otherwise check formula.version - raise "#{opt} not present\nReinstall #{dep}. Sorry :(" unless opt.directory? - + fixopt(dep) unless opt.directory? if not superenv? ENV.prepend_path 'PATH', "#{opt}/bin" ENV.prepend_path 'PKG_CONFIG_PATH', "#{opt}/lib/pkgconfig" @@ -128,3 +125,18 @@ def install f end end end + +def fixopt f + path = if f.linked_keg.directory? and f.linked_keg.symlink? + f.linked_keg.readlink + elsif f.prefix.directory? + f.prefix + elsif (kids = f.rack.children).size == 1 + kids.first + else + raise + end + Keg.new(path).optlink +rescue StandardError + "#{opt} not present or broken\nPlease reinstall #{dep}. Sorry :(" +end