bottle: auto detect any_skip_relocation

This commit is contained in:
Xu Cheng 2015-09-11 19:13:52 +08:00
parent d911b5689a
commit e23cca8d84
2 changed files with 17 additions and 1 deletions

View File

@ -164,6 +164,7 @@ module Homebrew
keg = Keg.new(f.prefix) keg = Keg.new(f.prefix)
relocatable = false relocatable = false
skip_relocation = false
keg.lock do keg.lock do
begin begin
@ -171,6 +172,7 @@ module Homebrew
cellar, Keg::CELLAR_PLACEHOLDER, :keg_only => f.keg_only? cellar, Keg::CELLAR_PLACEHOLDER, :keg_only => f.keg_only?
keg.relocate_text_files prefix, Keg::PREFIX_PLACEHOLDER, keg.relocate_text_files prefix, Keg::PREFIX_PLACEHOLDER,
cellar, Keg::CELLAR_PLACEHOLDER cellar, Keg::CELLAR_PLACEHOLDER
keg.delete_pyc_files! keg.delete_pyc_files!
cd cellar do cd cellar do
@ -196,6 +198,7 @@ module Homebrew
relocatable = !keg_contains(prefix_check, keg, ignores) relocatable = !keg_contains(prefix_check, keg, ignores)
relocatable = !keg_contains(cellar, keg, ignores) && relocatable relocatable = !keg_contains(cellar, keg, ignores) && relocatable
skip_relocation = relocatable && !keg.require_install_name_tool?
puts if !relocatable && ARGV.verbose? puts if !relocatable && ARGV.verbose?
rescue Interrupt rescue Interrupt
ignore_interrupts { bottle_path.unlink if bottle_path.exist? } ignore_interrupts { bottle_path.unlink if bottle_path.exist? }
@ -215,7 +218,15 @@ module Homebrew
bottle = BottleSpecification.new bottle = BottleSpecification.new
bottle.root_url(root_url) if root_url bottle.root_url(root_url) if root_url
bottle.prefix prefix bottle.prefix prefix
bottle.cellar relocatable ? :any : cellar if relocatable
if skip_relocation
bottle.cellar :any_skip_relocation
else
bottle.cellar :any
end
else
bottle.cellar cellar
end
bottle.revision bottle_revision bottle.revision bottle_revision
bottle.sha256 bottle_path.sha256 => bottle_tag bottle.sha256 bottle_path.sha256 => bottle_tag

View File

@ -109,10 +109,15 @@ class Keg
end end
def install_name_tool(*args) def install_name_tool(*args)
@require_install_name_tool = true
tool = MacOS.install_name_tool tool = MacOS.install_name_tool
system(tool, *args) || raise(ErrorDuringExecution.new(tool, args)) system(tool, *args) || raise(ErrorDuringExecution.new(tool, args))
end end
def require_install_name_tool?
!!@require_install_name_tool
end
# If file is a dylib or bundle itself, look for the dylib named by # If file is a dylib or bundle itself, look for the dylib named by
# bad_name relative to the lib directory, so that we can skip the more # bad_name relative to the lib directory, so that we can skip the more
# expensive recursive search if possible. # expensive recursive search if possible.