aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2011-06-16 15:11:41 +0100
committerMax Howell2011-06-17 09:30:25 +0100
commit215fcd32924d2c50fbe51e96002f7f48f2b4db0a (patch)
tree9d086f3fe0319b04cbae8a72f1f3fa16574db031 /Library
parent527c841f1cdcf1352187d63058acd7fdb304363f (diff)
downloadbrew-215fcd32924d2c50fbe51e96002f7f48f2b4db0a.tar.bz2
Fix upgrading libdeps breaking stuff after cleanups
Fixes Homebrew/homebrew#2709. By forcing dylibs to have an install_name id that is the HOMEBREW_PREFIX path, ie. the symlink’s path. Stuff that links to these dylibs will use this id and thus by immune to upgrades of underlying libraries. Thus whatever keg is "current" ie. linked, will be the library that is used by the tool. This fix is not retroactive. So there will still be breakage for existing installations of stuff. The fix_install step in install is moved after the link step as the symlinking is required to determine the eventual ids for each dylib.
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Homebrew/install.rb20
-rw-r--r--Library/Homebrew/keg_fix_install_names.rb11
2 files changed, 18 insertions, 13 deletions
diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb
index d436fb853..ca4e6663b 100755
--- a/Library/Homebrew/install.rb
+++ b/Library/Homebrew/install.rb
@@ -120,16 +120,6 @@ def install f
keg = Keg.new f.prefix
begin
- keg.fix_install_names
- rescue Exception => e
- onoe "Failed to fix install names"
- puts "The formula built, but you may encounter issues using it or linking other"
- puts "formula against it."
- ohai e, e.backtrace if ARGV.debug?
- show_summary_heading = true
- end
-
- begin
require 'cleaner'
Cleaner.new f if not f.pouring
rescue Exception => e
@@ -204,6 +194,16 @@ def install f
end
show_summary_heading = true
end
+
+ begin
+ keg.fix_install_names
+ rescue Exception => e
+ onoe "Failed to fix install names"
+ puts "The formula built, but you may encounter issues using it or linking other"
+ puts "formula against it."
+ ohai e, e.backtrace if ARGV.debug?
+ show_summary_heading = true
+ end
end
ohai "Summary" if ARGV.verbose? or show_summary_heading
diff --git a/Library/Homebrew/keg_fix_install_names.rb b/Library/Homebrew/keg_fix_install_names.rb
index 55cc09395..c23f04adb 100644
--- a/Library/Homebrew/keg_fix_install_names.rb
+++ b/Library/Homebrew/keg_fix_install_names.rb
@@ -2,6 +2,9 @@ class Keg
def fix_install_names
dylibs.each do |dylib|
bad_install_names_for dylib do |id, bad_names|
+ # avoid the chmod change if unecessary—I'm not convinced it reverses right
+ next if bad_names.empty? and id.to_s == dylib.to_s
+
dylib.ensure_writable do
system "install_name_tool", "-id", id, dylib
bad_names.each do |bad_name|
@@ -30,9 +33,11 @@ class Keg
install_names.reject!{ |fn| fn =~ /^@(loader|executable)_path/ }
install_names.reject!{ |fn| fn[0,1] == '/' }
- unless install_names.empty? and id == dylib # avoid the work if possible
- yield dylib, install_names
- end
+ # the shortpath ensures that library upgrades don’t break installed tools
+ shortpath = HOMEBREW_PREFIX + Pathname.new(dylib).relative_path_from(self)
+ id = if shortpath.exist? then shortpath else dylib end
+
+ yield id, install_names
end
def dylibs