os/linux/keg_relocate: skip ELF files with protodesc_cold only when bottling

We removed this exclusion in #20423 because it broke pouring of existing
bottles, which still need relocation.

Let's skip relocation only when bottling, to avoid breaking existing
bottles that need to be relocated when pouring.
This commit is contained in:
Carlo Cabrera 2025-08-13 00:25:53 +08:00 committed by Carlo Cabrera
parent 38485e365f
commit 6457770a59
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -20,6 +20,13 @@ class Keg
def change_rpath!(file, old_prefix, new_prefix)
return false if !file.elf? || !file.dynamic_elf?
bottling = old_prefix.to_s.start_with?(HOMEBREW_PREFIX.to_s)
bottling &&= !new_prefix.to_s.start_with?(HOMEBREW_PREFIX.to_s)
# Skip relocation of files with `protodesc_cold` sections because patchelf.rb seems to break them,
# but only when bottling (as we don't want to break existing bottles that require relocation).
# https://github.com/Homebrew/homebrew-core/pull/232490#issuecomment-3161362452
return false if bottling && file.section_names.include?("protodesc_cold")
updated = {}
old_rpath = file.rpath
new_rpath = if old_rpath