aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/os/mac
diff options
context:
space:
mode:
authorWilliam Woodruff2017-08-28 17:33:57 -0400
committerWilliam Woodruff2017-09-25 17:46:23 -0400
commitd618e574fb641de7d820208dec51bebe460cf32f (patch)
treec980489c68d44fb34f65c09afa9ae8ca9cb5e4e3 /Library/Homebrew/os/mac
parent551e5dd94578062e0ab42bc56e0fdd106807839b (diff)
downloadbrew-d618e574fb641de7d820208dec51bebe460cf32f.tar.bz2
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.
Diffstat (limited to 'Library/Homebrew/os/mac')
-rw-r--r--Library/Homebrew/os/mac/keg.rb29
-rw-r--r--Library/Homebrew/os/mac/mach.rb28
2 files changed, 28 insertions, 29 deletions
diff --git a/Library/Homebrew/os/mac/keg.rb b/Library/Homebrew/os/mac/keg.rb
deleted file mode 100644
index 6caadb1d7..000000000
--- a/Library/Homebrew/os/mac/keg.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-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
diff --git a/Library/Homebrew/os/mac/mach.rb b/Library/Homebrew/os/mac/mach.rb
index 9b53c4979..29273cbaa 100644
--- a/Library/Homebrew/os/mac/mach.rb
+++ b/Library/Homebrew/os/mac/mach.rb
@@ -61,6 +61,34 @@ module MachOShim
macho.dylib_id
end
+ def change_dylib_id(id)
+ return if dylib_id == id
+ puts "Changing dylib ID of #{self}\n from #{dylib_id}\n to #{id}" if ARGV.debug?
+ macho.change_dylib_id(id, strict: false)
+ macho.write!
+ rescue MachO::MachOError
+ odie <<-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
+ puts "Changing install name in #{self}\n from #{old}\n to #{new}" if ARGV.debug?
+ macho.change_install_name(old, new, strict: false)
+ macho.write!
+ rescue MachO::MachOError
+ odie <<-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