aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXiyue Deng2013-10-02 22:12:13 -0700
committerXiyue Deng2013-10-04 02:03:03 -0700
commit592b5d91a030f6925984cf19c3723ce7b601b576 (patch)
treeb90bc284c48d05cfa9a01cc1f5009fb88112ccab /Library
parent535c02674ca9a3841b7a90c65350b23ac3c07da3 (diff)
downloadbrew-592b5d91a030f6925984cf19c3723ce7b601b576.tar.bz2
Fix install_name_tool path for keg_only formulae
* When a versioned keg_only formula installs the same set of executables or libraries as a unversioned formula that links to $HOMEBREW_PREFIX, install_name_tool will prefer to use the linked paths for files in keg_only formula. This breaks software that should link to the keg_only formula but links to the unversioned one instead. * Add an additional "options" parameter with keg_only field to specify the correct install path for keg_only formulae.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/bottle.rb2
-rw-r--r--Library/Homebrew/formula_installer.rb4
-rw-r--r--Library/Homebrew/keg_fix_install_names.rb16
3 files changed, 11 insertions, 11 deletions
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb
index 607c4802a..0fe7fb836 100644
--- a/Library/Homebrew/cmd/bottle.rb
+++ b/Library/Homebrew/cmd/bottle.rb
@@ -96,7 +96,7 @@ module Homebrew extend self
keg.lock do
# Relocate bottle library references before testing for built-in
# references to the Cellar e.g. Qt's QMake annoyingly does this.
- keg.relocate_install_names prefix, tmp_prefix, cellar, tmp_cellar
+ keg.relocate_install_names prefix, tmp_prefix, cellar, tmp_cellar, :keg_only => f.keg_only?
if prefix == '/usr/local'
prefix_check = HOMEBREW_PREFIX/'opt'
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 9c0719448..f2f739c53 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -470,7 +470,7 @@ class FormulaInstaller
end
def fix_install_names
- Keg.new(f.prefix).fix_install_names
+ Keg.new(f.prefix).fix_install_names(:keg_only => f.keg_only?)
if @poured_bottle and f.bottle
old_prefix = f.bottle.prefix
new_prefix = HOMEBREW_PREFIX.to_s
@@ -479,7 +479,7 @@ class FormulaInstaller
if old_prefix != new_prefix or old_cellar != new_cellar
Keg.new(f.prefix).relocate_install_names \
- old_prefix, new_prefix, old_cellar, new_cellar
+ old_prefix, new_prefix, old_cellar, new_cellar, :keg_only => f.keg_only?
end
end
rescue Exception => e
diff --git a/Library/Homebrew/keg_fix_install_names.rb b/Library/Homebrew/keg_fix_install_names.rb
index c5a2ab9ea..e126890e7 100644
--- a/Library/Homebrew/keg_fix_install_names.rb
+++ b/Library/Homebrew/keg_fix_install_names.rb
@@ -1,13 +1,13 @@
class Keg
- def fix_install_names
+ def fix_install_names options={}
return unless MACOS
mach_o_files.each do |file|
- install_names_for file do |id, bad_names|
+ install_names_for(file, options) do |id, bad_names|
file.ensure_writable do
install_name_tool("-id", id, file) if file.dylib?
bad_names.each do |bad_name|
- new_name = fixed_name(file, bad_name)
+ new_name = fixed_name(file, bad_name, options)
unless new_name == bad_name
install_name_tool("-change", bad_name, new_name, file)
end
@@ -17,9 +17,9 @@ class Keg
end
end
- def relocate_install_names old_prefix, new_prefix, old_cellar, new_cellar
+ def relocate_install_names old_prefix, new_prefix, old_cellar, new_cellar, options={}
mach_o_files.each do |file|
- install_names_for(file, relocate_reject_proc(old_prefix)) do |id, old_prefix_names|
+ install_names_for(file, options, relocate_reject_proc(old_prefix)) do |id, old_prefix_names|
file.ensure_writable do
new_prefix_id = id.to_s.gsub old_prefix, new_prefix
install_name_tool("-id", new_prefix_id, file) if file.dylib?
@@ -31,7 +31,7 @@ class Keg
end
end
- install_names_for(file, relocate_reject_proc(old_cellar)) do |id, old_cellar_names|
+ install_names_for(file, options, relocate_reject_proc(old_cellar)) do |id, old_cellar_names|
file.ensure_writable do
old_cellar_names.each do |old_cellar_name|
new_cellar_name = old_cellar_name.to_s.gsub old_cellar, new_cellar
@@ -80,7 +80,7 @@ class Keg
Proc.new { |fn| not fn.start_with?(path) }
end
- def install_names_for file, reject_proc=default_reject_proc
+ def install_names_for file, options, reject_proc=default_reject_proc
ENV['HOMEBREW_MACH_O_FILE'] = file.to_s # solves all shell escaping problems
install_names = `#{MacOS.locate("otool")} -L "$HOMEBREW_MACH_O_FILE"`.split "\n"
@@ -97,7 +97,7 @@ class Keg
# the shortpath ensures that library upgrades don’t break installed tools
relative_path = Pathname.new(file).relative_path_from(self)
shortpath = HOMEBREW_PREFIX.join(relative_path)
- id = if shortpath.exist?
+ id = if shortpath.exist? and not options[:keg_only]
shortpath
else
"#{HOMEBREW_PREFIX}/opt/#{fname}/#{relative_path}"