From d618e574fb641de7d820208dec51bebe460cf32f Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Mon, 28 Aug 2017 17:33:57 -0400 Subject: mach: Avoid reopening the file for relocation This commit allows the relocation code to perform install name and dylib ID changes without reopening the file separately. --- Library/Homebrew/extend/os/mac/keg_relocate.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Library/Homebrew/extend/os') diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb index 707710be6..7a1f42f8b 100644 --- a/Library/Homebrew/extend/os/mac/keg_relocate.rb +++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb @@ -2,7 +2,10 @@ class Keg def fix_dynamic_linkage mach_o_files.each do |file| file.ensure_writable do - change_dylib_id(dylib_id_for(file), file) if file.dylib? + if file.dylib? + @require_relocation = true + file.change_dylib_id(dylib_id_for(file)) + end each_install_name_for(file) do |bad_name| # Don't fix absolute paths unless they are rooted in the build directory @@ -11,7 +14,9 @@ class Keg !bad_name.start_with?(HOMEBREW_TEMP.realpath.to_s) new_name = fixed_name(file, bad_name) - change_install_name(bad_name, new_name, file) unless new_name == bad_name + + @require_relocation = true + file.change_install_name(bad_name, new_name, file) end end end @@ -23,8 +28,9 @@ class Keg mach_o_files.each do |file| file.ensure_writable do if file.dylib? + @require_relocation = true id = dylib_id_for(file).sub(relocation.old_prefix, relocation.new_prefix) - change_dylib_id(id, file) + file.change_dylib_id(id) end each_install_name_for(file) do |old_name| @@ -34,7 +40,8 @@ class Keg new_name = old_name.sub(relocation.old_prefix, relocation.new_prefix) end - change_install_name(old_name, new_name, file) if new_name + @require_relocation = true + file.change_install_name(old_name, new_name) if new_name end end end -- cgit v1.2.3