I am not sure why we also checked for HOMEBREW_FORCE_HOMEBREW_ON_LINUX.
If the minimum curl version needs to be changed, we should introduce
specific env variables for each case that needs it, instead of
asking for HOMEBREW_FORCE_HOMEBREW_ON_LINUX to be set too (which is not the case
in the linuxbrew-core repo for example)
This will make the error more informative by showing the architecture a
binary was built for along with the error message.
Before:
foo:
* Binaries built for an incompatible architecture were installed into foo's prefix.
The offending files are:
/usr/local/Cellar/foo/1.0/lib/libbar.dylib
/usr/local/Cellar/foo/1.0/lib/libfoo.dylib
/usr/local/Cellar/foo/1.0/lib/libincompatible.dylib
Unexpected universal binaries were found.
The offending files are:
/usr/local/Cellar/foo/1.0/lib/liball.dylib
/usr/local/Cellar/foo/1.0/lib/libuniversal.dylib
After:
foo:
* Binaries built for a non-native architecture were installed into foo's prefix.
The offending files are:
/usr/local/Cellar/foo/1.0/lib/libbar.dylib (i386)
/usr/local/Cellar/foo/1.0/lib/libfoo.dylib (arm64)
/usr/local/Cellar/foo/1.0/lib/libincompatible.dylib (universal)
Unexpected universal binaries were found.
The offending files are:
/usr/local/Cellar/foo/1.0/lib/liball.dylib
/usr/local/Cellar/foo/1.0/lib/libuniversal.dylib
This method takes an optional array of `Pathnames`s or `Strings`s and
extracts the native slice from the specified universal binary. If no
parameter is supplied, this is done on all compatible universal binaries
in a formula's keg.
`deuniversalize_machos` is a no-op on Linux.
I still need to look into a) error handling, and b) whether using this
method requires codesigning on ARM.
I've also added signatures to the methods in `extend/os/linux/formula`.
`FormulaInstaller` calls `audit_installed` at install time, which
invokes methods in `FormulaCellarChecks`. One of these methods makes a
call to `tap_audit_exception` (cf. #11750), but this method isn't
visible in `FormulaInstaller`.
Instead of trying to replicate the logic of `tap_audit_exception` in
`FormulaAuditor` (or trying to initialise an instance of one to make the
call to `FormulaAuditor`'s implementation of it), let's just implement a
stub that assumes an exception always exists.
I'll need to think a bit about whether this is the right fix for this,
but currently the missing method error is blocking PRs in Homebrew/core,
so let's go with this for now. [1]
[1] e.g. Homebrew/homebrew-core#81388, Homebrew/homebrew-core#81582
The `check_binary_arches` audit will fail any formula that produces
universal binaries. We have a handful of formulae in Homebrew/core that
do this (see any formula that does `ENV.permit_arch_flags`, for
example). Moreover, some third party taps may have their own formulae
that build universal binaries.
I've updated the check so that it ignores a formula that produces
universal binaries whenever the formula is in the appropriate allowlist.
We'll need to create one in Homebrew/core for the handful of formulae
that do (expectedly) build universal binaries.
If we don't want to maintain an allowlist, we can easily modify this to
pass over any formulae that builds compatible universal binaries.
I've also fixed the spacing of the error this audit produces whenever
there is more than one file that fails the audit.