Fixes#2355
Create unremovable_kegs instance var
Check cellar cleanup failure after full cleanup completes
Use module_function in Homebrew::Cleanup as we never instantiate the
class
Before
```
$ time brew cleanup -s
brew cleanup -s 0.73s user 3.52s system 58% cpu 7.297 total
```
After
```
$ time brew cleanup -s
brew cleanup -s 0.69s user 2.57s system 139% cpu 2.341 total
```
ClosesHomebrew/homebrew#42968.
Signed-off-by: Xu Cheng <xucheng@me.com>
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.