aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2012-08-27 12:02:57 -0400
committerMax Howell2012-08-29 12:41:36 -0400
commit7116a5bd3d9d1cb8866a7bb0650f85cbaf6a1dc5 (patch)
tree6e18b89beea5e32de9abe1bca540bc2a7b09303e /Library
parent1392cd40f83d4e67c34bf840bbac815c28332833 (diff)
downloadhomebrew-7116a5bd3d9d1cb8866a7bb0650f85cbaf6a1dc5.tar.bz2
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.
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Homebrew/build.rb20
1 files changed, 16 insertions, 4 deletions
diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb
index eb3431b9c..3c15be352 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