Callers of FormulaInstaller now usually unlink the existing keg prior to
running the installer. However, Tab.for_formula uses the LinkedKeg
record to obtain the tab.
Since we need the tab to persist install options across upgrades, we
must start creating the Tab object before unlinking the old keg and
passing it to the FormulaInstaller.
FixesHomebrew/homebrew#11086.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Also, unlink previous keg before installing to prevent issues when existing installed brews cause build problems for the newer installed brew.
If the build fails the active keg is relinked before aborting.
Fixes #10341.
Calling Keg#unlink on "#{f.rack}/#{f.version}" will perform the unlink
relative to the _new_ keg, rather than the keg we are upgrading from.
Fix this by resolving the linked_keg entry and unlinking relative to it.
FixesHomebrew/homebrew#10296.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Previously, `outdated_brews` returned a list of lists---each containing three
components of a Formula object:
- f.rack
- f.name
- f.version
Frequently more information is required which necessitates back-casting from
`name` to a Formula object---simpy returning formula objects removes this step.
`rack` is a commonly used alias for `formula.prefix.parent`---so common that it
gets defined and used quite a bit. This patch makes `rack` an official method
of the `Formula` class.
Consequence: you can no longer install when something is already installed, you must upgrade it. This doesn't apply if the formula in question was unlinked. You can still --force installs though.
Rationale: the old way of installing over the top would leave symlinks to multiple versions in /usr/local if the old version had a file the newer version didn't. The new upgrade command handles everything properly.