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

os/mac/keg_relocate: replace Cellar references in rpaths #15685

Merged
merged 1 commit into from
Jul 17, 2023
Merged
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
15 changes: 14 additions & 1 deletion Library/Homebrew/extend/os/mac/keg_relocate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
if rooted_in_build_directory?(bad_name) || (file.rpaths.count(bad_name) > 1)
delete_rpath(bad_name, file)
else
loader_name = loader_name_for(file, bad_name)
new_name = opt_name_for(bad_name)
loader_name = loader_name_for(file, new_name)

Check warning on line 64 in Library/Homebrew/extend/os/mac/keg_relocate.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/mac/keg_relocate.rb#L64

Added line #L64 was not covered by tests
change_rpath(bad_name, loader_name, file) if loader_name != bad_name
end
end
Expand Down Expand Up @@ -203,6 +204,18 @@

private

CELLAR_RX = %r{\A#{HOMEBREW_CELLAR}/(?<formula_name>[^/]+)/[^/]+}.freeze

# Replace HOMEBREW_CELLAR references with HOMEBREW_PREFIX/opt references
# if the Cellar reference is to a different keg.
def opt_name_for(filename)
return filename unless filename.start_with?(HOMEBREW_PREFIX.to_s)
return filename if filename.start_with?(path.to_s)
return filename if (matches = CELLAR_RX.match(filename)).blank?

filename.sub(CELLAR_RX, "#{HOMEBREW_PREFIX}/opt/#{matches[:formula_name]}")

Check warning on line 216 in Library/Homebrew/extend/os/mac/keg_relocate.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/mac/keg_relocate.rb#L216

Added line #L216 was not covered by tests
end

def rooted_in_build_directory?(filename)
# CMake normalises `/private/tmp` to `/tmp`.
# https://gitlab.kitware.com/cmake/cmake/-/issues/23251
Expand Down