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.
This commit is contained in:
parent
535c02674c
commit
592b5d91a0
@ -96,7 +96,7 @@ module Homebrew extend self
|
|||||||
keg.lock do
|
keg.lock do
|
||||||
# Relocate bottle library references before testing for built-in
|
# Relocate bottle library references before testing for built-in
|
||||||
# references to the Cellar e.g. Qt's QMake annoyingly does this.
|
# 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'
|
if prefix == '/usr/local'
|
||||||
prefix_check = HOMEBREW_PREFIX/'opt'
|
prefix_check = HOMEBREW_PREFIX/'opt'
|
||||||
|
|||||||
@ -470,7 +470,7 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fix_install_names
|
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
|
if @poured_bottle and f.bottle
|
||||||
old_prefix = f.bottle.prefix
|
old_prefix = f.bottle.prefix
|
||||||
new_prefix = HOMEBREW_PREFIX.to_s
|
new_prefix = HOMEBREW_PREFIX.to_s
|
||||||
@ -479,7 +479,7 @@ class FormulaInstaller
|
|||||||
|
|
||||||
if old_prefix != new_prefix or old_cellar != new_cellar
|
if old_prefix != new_prefix or old_cellar != new_cellar
|
||||||
Keg.new(f.prefix).relocate_install_names \
|
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
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
class Keg
|
class Keg
|
||||||
def fix_install_names
|
def fix_install_names options={}
|
||||||
return unless MACOS
|
return unless MACOS
|
||||||
mach_o_files.each do |file|
|
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
|
file.ensure_writable do
|
||||||
install_name_tool("-id", id, file) if file.dylib?
|
install_name_tool("-id", id, file) if file.dylib?
|
||||||
|
|
||||||
bad_names.each do |bad_name|
|
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
|
unless new_name == bad_name
|
||||||
install_name_tool("-change", bad_name, new_name, file)
|
install_name_tool("-change", bad_name, new_name, file)
|
||||||
end
|
end
|
||||||
@ -17,9 +17,9 @@ class Keg
|
|||||||
end
|
end
|
||||||
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|
|
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
|
file.ensure_writable do
|
||||||
new_prefix_id = id.to_s.gsub old_prefix, new_prefix
|
new_prefix_id = id.to_s.gsub old_prefix, new_prefix
|
||||||
install_name_tool("-id", new_prefix_id, file) if file.dylib?
|
install_name_tool("-id", new_prefix_id, file) if file.dylib?
|
||||||
@ -31,7 +31,7 @@ class Keg
|
|||||||
end
|
end
|
||||||
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
|
file.ensure_writable do
|
||||||
old_cellar_names.each do |old_cellar_name|
|
old_cellar_names.each do |old_cellar_name|
|
||||||
new_cellar_name = old_cellar_name.to_s.gsub old_cellar, new_cellar
|
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) }
|
Proc.new { |fn| not fn.start_with?(path) }
|
||||||
end
|
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
|
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"
|
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
|
# the shortpath ensures that library upgrades don’t break installed tools
|
||||||
relative_path = Pathname.new(file).relative_path_from(self)
|
relative_path = Pathname.new(file).relative_path_from(self)
|
||||||
shortpath = HOMEBREW_PREFIX.join(relative_path)
|
shortpath = HOMEBREW_PREFIX.join(relative_path)
|
||||||
id = if shortpath.exist?
|
id = if shortpath.exist? and not options[:keg_only]
|
||||||
shortpath
|
shortpath
|
||||||
else
|
else
|
||||||
"#{HOMEBREW_PREFIX}/opt/#{fname}/#{relative_path}"
|
"#{HOMEBREW_PREFIX}/opt/#{fname}/#{relative_path}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user