Expand description
Brew-emulate fallback: build a homebrew-core formula with real Homebrew
installed at the keg prefix, for the macOS long tail the generic
crate::source_build recipe runner cannot reproduce.
§When this runs
crate::source_build::ensure_from_source handles the homebrew-core C-tool
population with a generic autotools/CMake/Makefile runner. Some formulae have
custom .rb install do logic (compile a single file by hand, run a
bespoke install.sh, cargo install / go build, apply patches, …) that
a generic build-system detector cannot reproduce — for those the generic
runner either fails detection (no configure/CMakeLists.txt/Makefile) or
errors mid-build. This module is the fallback: it runs the formula’s actual
Homebrew install recipe, so whatever custom logic the formula carries is
executed faithfully.
§Why install Homebrew AT the keg prefix
The keg must be self-contained and relocation-free — no @@HOMEBREW@@
placeholders in any binary’s load commands (those abort under a darwin
Seatbelt container, see crate::source_build module docs). Two properties
get us there:
- A non-default prefix forces build-from-source. We additionally pass
--build-from-source, so Homebrew compiles the named formula instead of pouring a relocatable bottle (a poured bottle is exactly where the@@HOMEBREW@@install-name placeholders come from). A compiled binary bakes the absolute prefix path into itsLC_LOAD_DYLIB/ rpath load commands. - The prefix lives inside the keg, permanently. We clone Homebrew into
<keg>/brewand pointHOMEBREW_PREFIX/HOMEBREW_CELLAR/HOMEBREW_REPOSITORYthere, so those baked-in absolute paths (<keg>/brew/opt/<dep>/lib/...) remain valid for the life of the keg — no post-install relocation, ever.
The resulting keg has the standard layout the resolver expects (a bin of
the installed formula’s executables, reached via the Homebrew prefix’s
opt/<formula>/bin + bin symlink dirs) plus a KegManifest.
Functions§
- ensure_
via_ brew - Build
formulainto a self-contained keg by running its real Homebrew install recipe at a keg-rooted prefix, returning the keg path.