From 6b728bf3bde98cf2b10624c528174f2439d5b78b Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Wed, 26 Jul 2023 11:15:19 +0800 Subject: [PATCH] Implement ruby-macho TODOs We now have the new release of ruby-macho (#15758), so we can now finish off the remaining work from #15731. --- Library/Homebrew/extend/os/mac/keg_relocate.rb | 2 -- Library/Homebrew/os/mac/mach.rb | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb index 89e56a6f4c..47ebe2e265 100644 --- a/Library/Homebrew/extend/os/mac/keg_relocate.rb +++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb @@ -59,8 +59,6 @@ class Keg new_name = opt_name_for(bad_name) loader_name = loader_name_for(file, new_name) next if loader_name == bad_name - # TODO: Remove the line below on the next release of ruby-macho. See Homebrew/ruby-macho@e9eaa75. - next if file.rpaths(resolve_variable_references: false).include?(loader_name) change_rpath(bad_name, loader_name, file) end diff --git a/Library/Homebrew/os/mac/mach.rb b/Library/Homebrew/os/mac/mach.rb index 35776c8610..f9818d6f84 100644 --- a/Library/Homebrew/os/mac/mach.rb +++ b/Library/Homebrew/os/mac/mach.rb @@ -64,11 +64,11 @@ module MachOShim resolve_variable_name(r.path.to_s) == resolve_variable_name(rpath) end - # TODO: Add `last: true` to `options` and replace `delete_command` with `delete_rpath` - # when the PR linked below is merged and release for ruby-macho. - # https://github.com/Homebrew/ruby-macho/pull/555 - command_to_delete = candidates.last # .path.to_s (when switching to `MachOFile#delete_rpath`) - macho.delete_command(command_to_delete, options) + # Delete the last instance to avoid changing the order in which rpaths are searched. + rpath_to_delete = candidates.last.path.to_s + options[:last] = true + + macho.delete_rpath(rpath_to_delete, options) macho.write! end