Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "mach: Avoid reopening the file for relocation" #3138

Merged
merged 1 commit into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions Library/Homebrew/extend/os/mac/keg_relocate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Keg
def fix_dynamic_linkage
mach_o_files.each do |file|
file.ensure_writable do
file.change_dylib_id(dylib_id_for(file)) if file.dylib?
change_dylib_id(dylib_id_for(file), file) if file.dylib?

each_install_name_for(file) do |bad_name|
# Don't fix absolute paths unless they are rooted in the build directory
Expand All @@ -11,7 +11,7 @@ def fix_dynamic_linkage
!bad_name.start_with?(HOMEBREW_TEMP.realpath.to_s)

new_name = fixed_name(file, bad_name)
file.change_install_name(bad_name, new_name, file)
change_install_name(bad_name, new_name, file) unless new_name == bad_name
end
end
end
Expand All @@ -24,7 +24,7 @@ def relocate_dynamic_linkage(relocation)
file.ensure_writable do
if file.dylib?
id = dylib_id_for(file).sub(relocation.old_prefix, relocation.new_prefix)
file.change_dylib_id(id)
change_dylib_id(id, file)
end

each_install_name_for(file) do |old_name|
Expand All @@ -34,7 +34,7 @@ def relocate_dynamic_linkage(relocation)
new_name = old_name.sub(relocation.old_prefix, relocation.new_prefix)
end

file.change_install_name(old_name, new_name) if new_name
change_install_name(old_name, new_name, file) if new_name
end
end
end
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/os/mac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require "os/mac/xquartz"
require "os/mac/pathname"
require "os/mac/sdk"
require "os/mac/keg"

module OS
module Mac
Expand Down
29 changes: 29 additions & 0 deletions Library/Homebrew/os/mac/keg.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Keg
def change_dylib_id(id, file)
return if file.dylib_id == id
@require_relocation = true
puts "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}" if ARGV.debug?
MachO::Tools.change_dylib_id(file, id, strict: false)
rescue MachO::MachOError
onoe <<-EOS.undent
Failed changing dylib ID of #{file}
from #{file.dylib_id}
to #{id}
EOS
raise
end

def change_install_name(old, new, file)
return if old == new
@require_relocation = true
puts "Changing install name in #{file}\n from #{old}\n to #{new}" if ARGV.debug?
MachO::Tools.change_install_name(file, old, new, strict: false)
rescue MachO::MachOError
onoe <<-EOS.undent
Failed changing install name in #{file}
from #{old}
to #{new}
EOS
raise
end
end
28 changes: 0 additions & 28 deletions Library/Homebrew/os/mac/mach.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,6 @@ def dylib_id
macho.dylib_id
end

def change_dylib_id(id)
return if dylib_id == id
@require_relocation = true
puts "Changing dylib ID of #{self}\n from #{dylib_id}\n to #{id}" if ARGV.debug?
macho.change_dylib_id(id, strict: false)
rescue MachO::MachOError
onoe <<-EOS.undent
Failed changing dylib ID of #{self}
from #{file.dylib_id}
to #{id}
EOS
raise
end

def change_install_name(old, new)
return if old == new
@require_relocation = true
puts "Changing install name in #{self}\n from #{old}\n to #{new}" if ARGV.debug?
macho.change_install_name(old, new, strict: false)
rescue MachO::MachOError
onoe <<-EOS.undent
Failed changing install name in #{self}
from #{old}
to #{new}
EOS
raise
end

def archs
mach_data.map { |m| m.fetch :arch }.extend(ArchitectureListExtension)
end
Expand Down