The main thing is that this DSL allows us to provide an
interface that can be serialized to the JSON API.
Changes:
- Homebrew::Service
- Adds `#service_name` and `#plist_name` methods
- Each is now included in the `#serialize` method as well
- Eval block on instantiation
- Before we lazy evaluated this but the cost is not significant
and it complicated the code a bunch. This only gets called
during install, when evaluating caveats and in the `brew service`
command. It skips this evaluation if the service block isn't there.
- Add `#command?` helper to avoid `#command.blank?` and `#command.present?`
- Formula
- `#service` now returns a service whenever it's called. This call is
hidden behind a call to `#service?` most of the time anyway so this
should be fine.
- `#plist_name` and `#service_name` now call the methods of the same name
on the service class. This should have already been in the service object
to begin with and keeping these methods here helps preserve backwards
compatibility with people who were overwriting these methods before.
- Caveats
- Prefer `service#command?`
- Add helpers for checking on service commands
- This duplicates some of the work in `brew services`. Maybe we should
merge that repo in at some point.
- Check for installed service at `#plist_name` or `#service_name`. I think
this should be used instead of `Keg#plist_installed?` which checked for any plist file.
We should think about deprecating `#plist_installed?` in the future.
- Stop using `ps aux | grep #{formula.plist_name}` to check for service files
because it was inaccurate (it always returns true on my machine) because the grep
process is started before the ps process.
- Note: The behavior is the same as it was before. This means that caveats
only show up for custom service files on install or if they're already installed.
Otherwise it won't show up in `brew info`. This is because it has to check
first if the service file has been installed.
- Utils::Service
- Add utils for evaluating if a service is installed and running. This duplicates
some of the work already found in `brew services`. We should seriously consider
merging `brew services` with the main brew repo in the future since it's already
tightly coupled to the code in the main repo.
- Formulary.load_formula_from_api
- Be more explicit about which types can be deserialized into run params since
it is now possible for run params to be nil.
- Update and add tests
- Change name of rubocop warning
- Disable linting on remaining offending lines
- Add todos to move lines with disabled linting
checks to extend/os in the future
Currently, if formula `foo` ships both universal and non-native
binaries and `foo` is on both allowlists, then `brew audit --strict`
errors out with an empty error message:
❯ brew audit --strict foo
foo:
*
Error: 1 problem in 1 formula detected
Let's fix this (admittedly obscure) corner case by returning early when
a formula is present on both allowlists.
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
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.
There have been a few instances I've noticed that we've been silently
installing binaries built for x86_64 on ARM. There's probably more that
I haven't found yet, so it seems useful to check this with an audit.
The output format of `objdump` on Mojave is different from newer
versions of macOS, so I've adjusted the relevant audit to account for
this difference.
- Refuse to create bottles which have non-relocatable references to
`HOMEBREW_LIBRARY`. This allows us to make all bottles ignore where
`HOMEBREW_REPOSITORY` is (even those that aren't `cellar :any`).
I cannot see any circumstances in which any bottle should link to
anything within `HOMEBREW_REPOSITORY`.
- Remove audit that becomes unnecessary given the above change.
- Relocate references to `@HOMEBREW_LIBRARY@` but don't actually write
any references yet. This will allow us to move to using
`@HOMEBREW_LIBRARY` and remove all relocation of `HOMEBREW_REPOSITORY`
in a future release (2.7.1, most likely).