1. Running `brew linkage some_package` does not set the cache.
2. Running `brew linkage --cached some_package` when `DatabaseCache.empty?` returns `true` should build the cache.
3. Running `brew linkage --cached some_package` when `DatabaseCache.empty?` returns `false` should use the cache.
It doesn't really make any sense for the `dependencies` hash to include
all optional, recommended and build dependencies when these are already
separately output.
Let's reorder this to more closely match the ordering in a formula file.
This makes `to_hash` (and our JSON output) more useful and easily
readable for people used to formula files.
The fixes the issue mentioned in:
https://github.com/Homebrew/brew/pull/4066#issuecomment-381308153
where `brew missing` was not reading from a tab of an outdated formula.
The `installed_prefix.directory?` check is unnecessary as the following
`opt_or_installed_prefix_keg` call is already checking that when it is
necessary. In this case it's not necessary anyway as `opt_prefix` is
preferred and makes more sense on outdated formulae.
Make some changes required to have `brew info --json=v1` whether there
is any bottle block rather than a bottle checksum for the given system.
This provides more consistent output.
An installed formula doesn't get optlinked until _after_ it's installed,
meaning that we can't rely on `opt_prefix` to get the right keg.
So, if not optlinked, fall back to the formula's prefix, which will be
that of the current installation.
Dot directories are not racks because formulae names do not start with
"." so avoid attempting to descend into dot directories, which may not
always be possible (e.g. .Trashes).
Remove more Requirement logic to enable future removal of default
formula logic. Also, output deprecations, convert symbol requirement
usage to deps and simplify the compatibility code for the direct
Requirement usage.
This has been a nightmare in terms of the complexity to our dependency
system and the whack-a-mole required on bugs. If a Requirement resolves
to a Formula it should just use `depends_on "formula"` instead. This
matches the effective behaviour all users of bottles (the vast majority
of users and installs) and what we're doing in Homebrew/homebrew-core.
Do this instead of appending the `HOMEBREW_PREFIX` as it's more
reliable at finding e.g. keg-only and requirement PATH additions. It's
not ideal as it overrides some environment filtering but the only real
alternative is recreate the entire build environment by shelling out to
`build.rb` in `formula_installer`.