extend/os/mac/keg_relocate: relocate rpaths on macOS

This commit is contained in:
Carlo Cabrera 2021-05-05 23:43:43 +01:00
parent 4d5971518d
commit 8f1cd1288d
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -35,6 +35,18 @@ class Keg
change_install_name(old_name, new_name, file) if new_name change_install_name(old_name, new_name, file) if new_name
end end
if ENV["HOMEBREW_RELOCATE_RPATHS"]
each_rpath_for(file) do |old_name|
if old_name.start_with? relocation.old_cellar
new_name = old_name.sub(relocation.old_cellar, relocation.new_cellar)
elsif old_name.start_with? relocation.old_prefix
new_name = old_name.sub(relocation.old_prefix, relocation.new_prefix)
end
change_rpath(old_name, new_name, file) if new_name
end
end
end end
end end
end end
@ -111,6 +123,12 @@ class Keg
dylibs.each(&block) dylibs.each(&block)
end end
def each_rpath_for(file, &block)
rpaths = file.rpaths
rpaths.reject! { |fn| fn =~ /^@(loader|executable)_path/ }
rpaths.each(&block)
end
def dylib_id_for(file) def dylib_id_for(file)
# The new dylib ID should have the same basename as the old dylib ID, not # The new dylib ID should have the same basename as the old dylib ID, not
# the basename of the file itself. # the basename of the file itself.