Instead of cleaning every time if the file is missing: don't clean this
time, touch the file and clean when it's next needed.
Now that this feature has been around for longer this makes more sense
for existing installations and stops the first `brew install` run on a
new/test installation without this file always running a `brew cleanup`.
Also, fix up the use of a compat/deprecated method hit by tests by
this change.
If you have /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby (for older OS X versions), then the cleanup tool will nuke everything in usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby. You will need to brew update-reset to get back the old packages.
- avoid calling `rm_ds_store` multiple times when unnecessary
- use native Ruby method to remove `.DS_Store` files as it saves
shelling out to `find` and is a bit quicker.
I benchmarked these both locally and neither use of `Thread.new`
provides any measurable speedup (and in the `readall` case appears to
slow things down) on my 8 core machine.
When a formula and cask share the same name, a download can be
incorrectly considered stale. Only check for if a download is a stale
formula or stale cask, but not both.
Rather than trying to be smart and doing this ourselves in `brew cleanup` let’s just installed Bundler somewhere it doesn’t try to clean itself up and use `bundle install --cleanup` when we need cleanup done.
Also, use `ohai` and `odie` when possible as they look nicer.
This method is also run to check formulae and if a formula and cask have
the same name (e.g. `cmake`) then this method would mark all formulae
downloads to being stale.
Instead, check the `dirname` (which we're using for globs anyway) to
double check that this is definitely a stale cask.
This will become the default in a later version of Homebrew but has an
opt-out through HOMEBREW_NO_INSTALL_CLEANUP.
Also, always cleanup files older than 120 days and set the general
default value for "old" logs, casks etc. to 30 days.
It's always seemed a bit pointless to me that we have both of these
commands. Given we're doing more and more to recommend (and eventually,
safely, automatically run (see #4760) `brew cleanup` let's roll their
functionality into a single command.
This makes use of both the existing interfaces and could use the
existing cache file but we'll create a new one and cleanup the old one
to avoid issues and use a more consistent name.
- Cleanup portable ruby if you haven't specifically requested it and
you don't need it. This will be useful when e.g. upgrading OS versions
- Cleanup the old DBM linkage cache. These will not be used again.
- ensure that `HOMEBREW_CELLAR` is always created on `install`.
- remove the need for a special `PRUNEABLE_DIRECTORIES` variable
- reuse values from existing variables and get `uniq`s.
Consolidate the handling of which directories need to exist and which
need to be writable. Additionally, add a fatal check for formula
installations to ensure that any directories that need to be writable
are so before attempting an installation.
Fixes#4626.