From a8cbc14ca34c55a9dfc3de865bb0cb420deb3adb Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Wed, 5 May 2021 21:37:02 +0100 Subject: [PATCH] os/mac/keg: add change_rpath method --- Library/Homebrew/os/mac/keg.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Library/Homebrew/os/mac/keg.rb b/Library/Homebrew/os/mac/keg.rb index 901c4dc7ee..72a3b85908 100644 --- a/Library/Homebrew/os/mac/keg.rb +++ b/Library/Homebrew/os/mac/keg.rb @@ -34,6 +34,22 @@ class Keg raise end + def change_rpath(old, new, file) + return if old == new + + @require_relocation = true + odebug "Changing rpath in #{file}\n from #{old}\n to #{new}" + MachO::Tools.change_rpath(file, old, new, strict: false) + apply_ad_hoc_signature(file) + rescue MachO::MachOError + onoe <<~EOS + Failed changing rpath in #{file} + from #{old} + to #{new} + EOS + raise + end + def apply_ad_hoc_signature(file) return if MacOS.version < :big_sur return unless Hardware::CPU.arm?