Change behavior for `brew cleanup` as follows:
- If `--force` is supplied, remove only outdated keg-only packages.
- If `--prune=<days>` is supplied, remove both logs and cached downloads
older than the specified number of days. Use `--prune=all` to remove
all logs and cached downloads irrespective of age.
- By default, remove logs after 14 days and cached downloads never.
Also centralizes handling of `--prune`, thus removing duplicate logic.
This is motivated by commit 17eee232838d4639b25f863aa342b1dda61b81bc
that made `--force` much more aggressive and made it override whatever
was specified via `--prune`, completely removing all:
- outdated keg-only packages
- cached downloads irrespective of age
- logs irrespective of age
This made it impossible to remove outdated keg-only packages without
also deleting all cached downloads, which is at least inconvenient for
people with limited bandwidth wanting to rebuild packages later.
ClosesHomebrew/homebrew#42970.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
The bug that prompted the two relevant commits has since been addressed.
Squashed commit of the following:
commit ecca17ede8324efd1175a42300ace8e1e2df30fa
Author: Jack Nagel <jacknagel@gmail.com>
Date: Sat Dec 27 16:16:12 2014 -0500
Revert "Don't use pkg_version when cleaning the cache"
This reverts commit 4d511b5169d78a5d44bbf6c36c17f0c28014a614.
commit e8935de08f6440ae1874ce523f93b19da6b68df3
Author: Jack Nagel <jacknagel@gmail.com>
Date: Sat Dec 27 16:16:12 2014 -0500
Revert "Fix cleanup for head-only formulae"
This reverts commit 510267ffd314c296c0b0969dd27d130a249f16e2.
Rationale: "prune" is slow, does not need to be run as often as
"cleanup", and is potentially destructive to things like empty
directories that Homebrew did not create. Thus we should let users run
`brew prune` only when they wish to, while still being able to use `brew
cleanup`.
ClosesHomebrew/homebrew#19863.