diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 7cbbecbb25..192b0beb8e 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -3,7 +3,8 @@ #: #: Options for the `install` command are also valid here. #: -#: If `--cleanup` is specified then remove previously installed version(s). +#: If `--cleanup` is specified or `HOMEBREW_UPGRADE_CLEANUP` is set then remove +#: previously installed version(s). #: #: If `--fetch-HEAD` is passed, fetch the upstream repository to detect if #: the HEAD installation of the formula is outdated. Otherwise, the @@ -82,7 +83,7 @@ module Homebrew Migrator.migrate_if_needed(f) begin upgrade_formula(f) - next unless ARGV.include?("--cleanup") + next if !ARGV.include?("--cleanup") && !ENV["HOMEBREW_UPGRADE_CLEANUP"] next unless f.installed? Homebrew::Cleanup.cleanup_formula f rescue UnsatisfiedRequirements => e diff --git a/Library/Homebrew/manpages/brew.1.md.erb b/Library/Homebrew/manpages/brew.1.md.erb index 618e050f63..e3d3faf09e 100644 --- a/Library/Homebrew/manpages/brew.1.md.erb +++ b/Library/Homebrew/manpages/brew.1.md.erb @@ -242,6 +242,9 @@ can take several different forms: This issue typically occurs when using FileVault or custom SSD configurations. + * `HOMEBREW_UPGRADE_CLEANUP`: + If set, `brew upgrade` always assumes `--cleanup` has been passed. + * `HOMEBREW_VERBOSE`: If set, Homebrew always assumes `--verbose` when running commands. diff --git a/docs/Manpage.md b/docs/Manpage.md index 388b886b45..4c523c435c 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -554,7 +554,8 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note Options for the `install` command are also valid here. - If `--cleanup` is specified then remove previously installed `formula` version(s). + If `--cleanup` is specified or `HOMEBREW_UPGRADE_CLEANUP` is set then remove + previously installed `formula` version(s). If `--fetch-HEAD` is passed, fetch the upstream repository to detect if the HEAD installation of the formula is outdated. Otherwise, the @@ -1092,6 +1093,9 @@ can take several different forms: This issue typically occurs when using FileVault or custom SSD configurations. + * `HOMEBREW_UPGRADE_CLEANUP`: + If set, `brew upgrade` always assumes `--cleanup` has been passed. + * `HOMEBREW_VERBOSE`: If set, Homebrew always assumes `--verbose` when running commands. diff --git a/manpages/brew.1 b/manpages/brew.1 index 2ac999dd58..536049a33b 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -570,7 +570,7 @@ Upgrade outdated, unpinned brews (with existing install options)\. Options for the \fBinstall\fR command are also valid here\. . .IP -If \fB\-\-cleanup\fR is specified then remove previously installed \fIformula\fR version(s)\. +If \fB\-\-cleanup\fR is specified or \fBHOMEBREW_UPGRADE_CLEANUP\fR is set then remove previously installed \fIformula\fR version(s)\. . .IP If \fB\-\-fetch\-HEAD\fR is passed, fetch the upstream repository to detect if the HEAD installation of the formula is outdated\. Otherwise, the repository\'s HEAD will be checked for updates when a new stable or devel version has been released\. @@ -1111,6 +1111,10 @@ If set, instructs Homebrew to use \fBHOMEBREW_TEMP\fR as the temporary directory This issue typically occurs when using FileVault or custom SSD configurations\. . .TP +\fBHOMEBREW_UPGRADE_CLEANUP\fR +If set, \fBbrew upgrade\fR always assumes \fB\-\-cleanup\fR has been passed\. +. +.TP \fBHOMEBREW_VERBOSE\fR If set, Homebrew always assumes \fB\-\-verbose\fR when running commands\. .