Expand description
Replace Homebrew’s bottling placeholders with real paths — the same work
brew does when pouring a bottle (Library/Homebrew/keg_relocate.rb).
Because we always install at the canonical prefix, placeholder replacements shrink or stay nearly the same size: @@HOMEBREW_PREFIX@@ (19) -> /opt/homebrew (13) @@HOMEBREW_CELLAR@@ (19) -> /opt/homebrew/Cellar (20)
Text files get plain string replacement. For shebang executables with binary payloads, such as zipapps, only the shebang is replaced so offsets and checksums in the payload remain intact. Mach-O binaries get in-place C-string replacement: the new string must fit in the existing string’s slot (its bytes plus any trailing NUL padding, keeping one terminator). Replacements that shrink always fit; the +1-byte Cellar case fits unless the original string ended exactly at its slot boundary, which we detect and report as an error rather than corrupt the binary.
Structs§
Functions§
- relocate_
keg - Walk a poured keg and replace placeholders.
skip_linkageleaves binary linkage untouched while still relocating text files, matching Homebrew’s handling of:any_skip_relocationbottles.