155 Commits

Author SHA1 Message Date
Michka Popoff
5e91802470 checksum: simplify, use only sha256
We use only one sha type right now.

Needed for https://github.com/Homebrew/brew/pull/10186
2021-01-07 20:46:13 +01:00
Mike McQuaid
0d76400a80
cleanup: don't do stale check when passing --prune.
This speeds up `--prune` fairly considerably.

Before:
```
$ hyperfine --warmup 3 'brew cleanup --prune=365'
Benchmark #1: brew cleanup --prune=365
  Time (mean ± σ):     33.352 s ±  0.654 s    [User: 21.684 s, System: 6.458 s]
  Range (min … max):   31.901 s … 34.096 s    10 runs
```

After:
```
$ hyperfine --warmup 3 'brew cleanup --prune=365'
Benchmark #1: brew cleanup --prune=365
  Time (mean ± σ):      6.821 s ±  0.186 s    [User: 2.225 s, System: 3.926 s]
  Range (min … max):    6.578 s …  7.178 s    10 runs
```

Closes https://github.com/Homebrew/brew/pull/10177/
Fixes https://github.com/Homebrew/brew/issues/10172
2020-12-31 14:00:12 +00:00
Mike McQuaid
4f438f6e45
Merge pull request #9477 from MikeMcQuaid/cleanup_periodic_full_days
Add HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS environment variable
2020-12-10 12:57:08 +00:00
Mike McQuaid
adab0fbb41
cleanup: fix portable Ruby behaviour.
Better match the macOS behaviour in `ruby.sh`.

Fixes #9469
2020-12-09 11:50:45 +00:00
Mike McQuaid
5757777a6e
Add HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS environment variable
This allows customisation of how often the periodic cleanups are done.
2020-12-09 10:36:02 +00:00
Mike McQuaid
9216d8abe6
rubocop-rails: make fixes. 2020-12-02 10:43:04 +00:00
EricFromCanada
19a382570c cleanup.rb: ensure cache exists before touching .cleaned 2020-11-14 10:48:10 -05:00
Jonathan Chang
500908ee6f rubocop: fix Lint/NoReturnInBeginEndBlocks 2020-11-10 23:28:31 +11:00
EricFromCanada
3768b7a6e9 apidoc: update comment wording, punctuation, formatting 2020-11-06 00:21:02 -05:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Mike McQuaid
3d436d3664 Improve linkage cache linkage_cache_performance
- Use reference counting so nested `CacheStoreDatabase.use` share the
  same underlying database (rather than rereading it every time).
- Only write out the cache database file when it has changed.
- Cleanup cache database entries on formula or full `brew cleanup`.

Fixes #8690
2020-09-11 12:57:15 +01:00
Maxim Belkin
896c93b819 cleanup.rb: quiet down Ruby test 2020-09-03 17:24:25 +00:00
Maxim Belkin
a6d29894d9 cleanup: fix and reuse portable ruby logic.
Align the logic in `cleanup_portable_ruby` with that in `ruby.sh`.

Co-authored-by: Maxim Belkin <maxim.belkin@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2020-09-03 09:43:41 +01:00
Mike McQuaid
8b97c27c21 brew style manual fixes 2020-09-01 14:26:45 +01:00
Mike McQuaid
3a91c37e66
Fix RuboCop checks. 2020-08-19 17:12:32 +01:00
Markus Reiter
5402500635 Refactor and document Cleanup. 2020-08-17 19:11:31 +02:00
Bo Anderson
3205ace13e cleanup: clean go_mod_cache 2020-07-20 15:30:33 +01:00
Mike McQuaid
4816e8320d
cleanup: check path exists before cleanup.
It may have been already cleaned up by an earlier step.
2020-07-10 09:32:27 +01:00
Mike McQuaid
f951ea83d4
Fix brew style. 2020-07-07 12:23:29 +01:00
Mike McQuaid
aa81982aba
brew style --fix 2020-06-02 09:49:23 +01:00
Mike McQuaid
4f75a77b08
Update deprecations
Add more deprecations, disable deprecations and remove disabled code.
2020-05-18 13:50:46 +01:00
Mike McQuaid
4da5c09c25
cleanup: tweak missing clean file behaviour.
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.
2020-05-07 11:01:09 +01:00
Mike McQuaid
701c1811d5
cleanup: all configuring max age days.
Fixes #7320
2020-04-20 10:33:15 +01:00
Mike McQuaid
3381cbf5c7
Use Homebrew::EnvConfig. 2020-04-07 09:58:26 +01:00
Mike McQuaid
f59c596e4b
cleanup: fix portable ruby bundler removal logic.
Need to ensure portable rubies are removed last and pass more paramaters to
git clean.
2020-01-16 16:06:22 +00:00
Roger Hu
d27c5fb2cb Catalina upgrades causes Homebrew to break when you run brew cleanup. Catalina has Ruby 2.6 installed, so the portable Ruby version is not needed.
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.
2020-01-15 23:56:28 -08:00
Mike McQuaid
95a1c8570a
cleanup: rescue more cask errors.
This will avoid a wider degree of failures.
2019-11-06 15:25:29 +00:00
Issy Long
1f6168fe8a
Change regexp.match?(string) to string.match?(regexp) everywhere
- Only try to call `.match?` on strings that aren't nil.
2019-10-13 23:22:51 +01:00
Issy Long
b78028b9c2
Auto-fix Performance/RegexpMatch offenses 2019-10-13 16:04:26 +01:00
Mike McQuaid
ea0e7f6d62
cleanup: some speedup optimisations.
- 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.
2019-09-19 08:42:03 +01:00
Mike McQuaid
c4f72312ce
Fixup brew style failures. 2019-04-30 09:19:18 +01:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
d1ea6f38d3
Fix mutable constants violations. 2019-04-19 21:46:20 +09:00
Mike McQuaid
640234caa1
Merge pull request #6030 from MikeMcQuaid/ruby-no-threads
Remove usage of Thread.new
2019-04-18 16:03:18 +09:00
Mike McQuaid
7fbfb02625
Remove usage of Thread.new
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.
2019-04-18 14:46:40 +09:00
Mike McQuaid
0b272ad26e
cleanup: don’t cleanup periodic clean file.
Cleaning up this file means that cleanup will run again prematurely.
2019-04-17 21:06:47 +09:00
Chase Stubblefield
2c95d733c2 cleanup: fix for formula/cask name collision
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.
2019-03-05 19:55:19 -08:00
Mike McQuaid
17f3ee1957
Improve Bundler cleanup
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.
2019-02-27 14:02:46 +00:00
Mike McQuaid
1dd8b82c6b
cleanup: run bundle clean. 2019-02-21 16:34:20 +00:00
Mike McQuaid
e095da4d01
rubocop: enable Layout/EmptyLineAfterGuardClause. 2019-02-21 12:55:49 +00:00
Mike McQuaid
d64429a736
rubocop: enable Style/IfUnlessModifier. 2019-02-21 12:55:49 +00:00
Mike McQuaid
ede9891bf2
cleanup: don't remove portable ruby on periodic cleanups.
Otherwise we end up deleting the running Ruby version.

Fixes #5707.
2019-02-13 12:56:36 +00:00
tueksta
4abacfd85d
style 2019-02-06 23:19:25 +01:00
tueksta
9abd7d31bd
Fix dry run 2019-02-06 22:50:17 +01:00
tueksta
b9b1b24e4e
Calculate actual delta in usage 2019-02-06 18:25:46 +01:00
Mike McQuaid
6fe75fb154
cleanup: fix stale cask detection.
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.
2019-02-03 15:32:30 +01:00
Mike McQuaid
d5adf87cf4
cleanup: better handle edge cases.
- don't complain about "skipping" kegs when `brew cleanup` runs
  automatically
- better handle orphaned directories
- output a better error message when a keg cannot be removed

Fixes #4989
Fixes #5627
Fixes https://github.com/Homebrew/homebrew-core/pull/35958#issuecomment-458031634
2019-01-28 16:08:23 +00:00
Mike McQuaid
eed1444d61
Update deprecations and cleanup
- Move `odeprecated` to `odisabled`
- Remove `odisabled`
- Enable automatic cleanup on install/reinstall/upgrade.
2019-01-23 21:57:40 +00:00
Mike McQuaid
79f3ff0a4e
cleanup: also consider ctime on prunes.
If this is an old tarball then we may end up removing it otherwise if
we've respected the `mtime` from the server on download.
2019-01-21 21:35:24 +00:00
Mike McQuaid
ea0fca9511
cleanup: make cache directory for clean file.
This means the `.cleaned` file is correctly created for periodic
cleanup handling.
2019-01-08 21:19:49 +00:00