diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 0503882cc7..cc12be3886 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -7,7 +7,6 @@ require "cask/cask_loader" require "set" CLEANUP_DEFAULT_DAYS = 30 -CLEANUP_MAX_AGE_DAYS = 120 module CleanupRefinement refine Pathname do @@ -132,7 +131,7 @@ module Homebrew @args = args @dry_run = dry_run @scrub = scrub - @days = days || CLEANUP_MAX_AGE_DAYS + @days = days || Homebrew::EnvConfig.cleanup_max_age_days.to_i @cache = cache @cleaned_up_paths = Set.new end diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb index 9b106947a9..3f8481c8e6 100644 --- a/Library/Homebrew/cmd/cleanup.rb +++ b/Library/Homebrew/cmd/cleanup.rb @@ -8,12 +8,14 @@ module Homebrew def cleanup_args Homebrew::CLI::Parser.new do + days = Homebrew::EnvConfig::ENVS[:HOMEBREW_CLEANUP_MAX_AGE_DAYS][:default] usage_banner <<~EOS `cleanup` [] [|] Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae. If arguments are specified, - only do this for the given formulae and casks. + only do this for the given formulae and casks. Removes all downloads more than + #{days} days old. This can be adjusted with `HOMEBREW_CLEANUP_MAX_AGE_DAYS`. EOS flag "--prune=", description: "Remove all cache files older than specified ." diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index 793e3e698e..14bb6e5a3a 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -50,6 +50,10 @@ module Homebrew "Linux: `$XDG_CACHE_HOME/Homebrew` or `$HOME/.cache/Homebrew`.", default: HOMEBREW_DEFAULT_CACHE, }, + HOMEBREW_CLEANUP_MAX_AGE_DAYS: { + description: "Cleanup all cached files older than this many days.", + default: 120, + }, HOMEBREW_COLOR: { description: "If set, force colour output on non-TTY outputs.", boolean: true, diff --git a/docs/Manpage.md b/docs/Manpage.md index 120e1cee70..979448a0c3 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -60,7 +60,8 @@ Control Homebrew's anonymous aggregate user behaviour analytics. Read more at Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae. If arguments are specified, only do -this for the given formulae and casks. +this for the given formulae and casks. Removes all downloads more than 120 days +old. This can be adjusted with `HOMEBREW_CLEANUP_MAX_AGE_DAYS`. * `--prune`: Remove all cache files older than specified *`days`*. @@ -1223,6 +1224,11 @@ Note that environment variables must have a value set to be detected. For exampl *Default:* macOS: `$HOME/Library/Caches/Homebrew`, Linux: `$XDG_CACHE_HOME/Homebrew` or `$HOME/.cache/Homebrew`. + * `HOMEBREW_CLEANUP_MAX_AGE_DAYS`: + Cleanup all cached files older than this many days. + + *Default:* `120`. + * `HOMEBREW_COLOR`: If set, force colour output on non-TTY outputs. diff --git a/manpages/brew.1 b/manpages/brew.1 index 6a7878449c..3fcac119eb 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -54,7 +54,7 @@ Control Homebrew\'s anonymous aggregate user behaviour analytics\. Read more at Regenerate the UUID used for Homebrew\'s analytics\. . .SS "\fBcleanup\fR [\fIoptions\fR] [\fIformula\fR|\fIcask\fR]" -Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae\. If arguments are specified, only do this for the given formulae and casks\. +Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae\. If arguments are specified, only do this for the given formulae and casks\. Removes all downloads more than 120 days old\. This can be adjusted with \fBHOMEBREW_CLEANUP_MAX_AGE_DAYS\fR\. . .TP \fB\-\-prune\fR @@ -1560,6 +1560,13 @@ Use the specified directory as the download cache\. \fIDefault:\fR macOS: \fB$HOME/Library/Caches/Homebrew\fR, Linux: \fB$XDG_CACHE_HOME/Homebrew\fR or \fB$HOME/\.cache/Homebrew\fR\. . .TP +\fBHOMEBREW_CLEANUP_MAX_AGE_DAYS\fR +Cleanup all cached files older than this many days\. +. +.IP +\fIDefault:\fR \fB120\fR\. +. +.TP \fBHOMEBREW_COLOR\fR If set, force colour output on non\-TTY outputs\. .