Merge pull request #5165 from Wojonatior/feature/homebrew_install_cleanup
Implement the HOMEBREW_INSTALL_CLEANUP env to trigger cleanup on reinstall/install/upgrade
This commit is contained in:
commit
6b1d439a87
@ -73,6 +73,9 @@
|
|||||||
#:
|
#:
|
||||||
#: If `--git` (or `-g`) is passed, Homebrew will create a Git repository, useful for
|
#: If `--git` (or `-g`) is passed, Homebrew will create a Git repository, useful for
|
||||||
#: creating patches to the software.
|
#: creating patches to the software.
|
||||||
|
#:
|
||||||
|
#: If `HOMEBREW_INSTALL_CLEANUP` is set then remove previously installed versions
|
||||||
|
#: of upgraded <formulae> as well as the HOMEBREW_CACHE for that formula.
|
||||||
|
|
||||||
require "missing_formula"
|
require "missing_formula"
|
||||||
require "formula_installer"
|
require "formula_installer"
|
||||||
@ -254,6 +257,7 @@ module Homebrew
|
|||||||
formulae.each do |f|
|
formulae.each do |f|
|
||||||
Migrator.migrate_if_needed(f)
|
Migrator.migrate_if_needed(f)
|
||||||
install_formula(f)
|
install_formula(f)
|
||||||
|
Cleanup.new.cleanup_formula(f) if ENV["HOMEBREW_INSTALL_CLEANUP"]
|
||||||
end
|
end
|
||||||
Homebrew.messages.display_messages
|
Homebrew.messages.display_messages
|
||||||
rescue FormulaUnreadableError, FormulaClassUnavailableError,
|
rescue FormulaUnreadableError, FormulaClassUnavailableError,
|
||||||
|
|||||||
@ -3,6 +3,9 @@
|
|||||||
#:
|
#:
|
||||||
#: If `--display-times` is passed, install times for each formula are printed
|
#: If `--display-times` is passed, install times for each formula are printed
|
||||||
#: at the end of the run.
|
#: at the end of the run.
|
||||||
|
#:
|
||||||
|
#: If `HOMEBREW_INSTALL_CLEANUP` is set then remove previously installed versions
|
||||||
|
#: of upgraded <formulae> as well as the HOMEBREW_CACHE for that formula.
|
||||||
|
|
||||||
require "formula_installer"
|
require "formula_installer"
|
||||||
require "development_tools"
|
require "development_tools"
|
||||||
@ -24,6 +27,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
Migrator.migrate_if_needed(f)
|
Migrator.migrate_if_needed(f)
|
||||||
reinstall_formula(f)
|
reinstall_formula(f)
|
||||||
|
Cleanup.new.cleanup_formula(f) if ENV["HOMEBREW_INSTALL_CLEANUP"]
|
||||||
end
|
end
|
||||||
Homebrew.messages.display_messages
|
Homebrew.messages.display_messages
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
#:
|
#:
|
||||||
#: Options for the `install` command are also valid here.
|
#: Options for the `install` command are also valid here.
|
||||||
#:
|
#:
|
||||||
#: If `--cleanup` is specified or `HOMEBREW_UPGRADE_CLEANUP` is set then remove
|
#: If `--cleanup` is specified or `HOMEBREW_INSTALL_CLEANUP` is set then remove
|
||||||
#: previously installed version(s) of upgraded <formulae>.
|
#: previously installed version(s) of upgraded <formulae>.
|
||||||
#:
|
#:
|
||||||
#: If `--fetch-HEAD` is passed, fetch the upstream repository to detect if
|
#: If `--fetch-HEAD` is passed, fetch the upstream repository to detect if
|
||||||
@ -107,7 +107,7 @@ module Homebrew
|
|||||||
Migrator.migrate_if_needed(f)
|
Migrator.migrate_if_needed(f)
|
||||||
begin
|
begin
|
||||||
upgrade_formula(f)
|
upgrade_formula(f)
|
||||||
next if !ARGV.include?("--cleanup") && !ENV["HOMEBREW_UPGRADE_CLEANUP"]
|
next if !ARGV.include?("--cleanup") && !ENV["HOMEBREW_UPGRADE_CLEANUP"] && !ENV["HOMEBREW_INSTALL_CLEANUP"]
|
||||||
next unless f.installed?
|
next unless f.installed?
|
||||||
|
|
||||||
Cleanup.new.cleanup_formula(f)
|
Cleanup.new.cleanup_formula(f)
|
||||||
|
|||||||
@ -8,7 +8,7 @@ describe "brew upgrade", :integration_test do
|
|||||||
expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory
|
expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
it "upgrades a Formula and cleans up old versions" do
|
it "upgrades a Formula and cleans up old versions when `--cleanup` is passed" do
|
||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||||
|
|
||||||
|
|||||||
@ -311,6 +311,9 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
|
|||||||
If `--git` (or `-g`) is passed, Homebrew will create a Git repository, useful for
|
If `--git` (or `-g`) is passed, Homebrew will create a Git repository, useful for
|
||||||
creating patches to the software.
|
creating patches to the software.
|
||||||
|
|
||||||
|
If `HOMEBREW_INSTALL_CLEANUP` is set then remove previously installed versions
|
||||||
|
of upgraded *`formulae`* as well as the HOMEBREW_CACHE for that formula.
|
||||||
|
|
||||||
* `leaves`:
|
* `leaves`:
|
||||||
Show installed formulae that are not dependencies of another installed formula.
|
Show installed formulae that are not dependencies of another installed formula.
|
||||||
|
|
||||||
@ -428,6 +431,9 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
|
|||||||
If `--display-times` is passed, install times for each formula are printed
|
If `--display-times` is passed, install times for each formula are printed
|
||||||
at the end of the run.
|
at the end of the run.
|
||||||
|
|
||||||
|
If `HOMEBREW_INSTALL_CLEANUP` is set then remove previously installed versions
|
||||||
|
of upgraded *`formulae`* as well as the HOMEBREW_CACHE for that formula.
|
||||||
|
|
||||||
* `search`, `-S`:
|
* `search`, `-S`:
|
||||||
Display all locally available formulae (including tapped ones).
|
Display all locally available formulae (including tapped ones).
|
||||||
No online search is performed.
|
No online search is performed.
|
||||||
@ -601,7 +607,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
|
|||||||
|
|
||||||
Options for the `install` command are also valid here.
|
Options for the `install` command are also valid here.
|
||||||
|
|
||||||
If `--cleanup` is specified or `HOMEBREW_UPGRADE_CLEANUP` is set then remove
|
If `--cleanup` is specified or `HOMEBREW_INSTALL_CLEANUP` is set then remove
|
||||||
previously installed version(s) of upgraded *`formulae`*.
|
previously installed version(s) of upgraded *`formulae`*.
|
||||||
|
|
||||||
If `--fetch-HEAD` is passed, fetch the upstream repository to detect if
|
If `--fetch-HEAD` is passed, fetch the upstream repository to detect if
|
||||||
|
|||||||
@ -315,6 +315,9 @@ If \fB\-\-interactive\fR (or \fB\-i\fR) is passed, download and patch \fIformula
|
|||||||
.IP
|
.IP
|
||||||
If \fB\-\-git\fR (or \fB\-g\fR) is passed, Homebrew will create a Git repository, useful for creating patches to the software\.
|
If \fB\-\-git\fR (or \fB\-g\fR) is passed, Homebrew will create a Git repository, useful for creating patches to the software\.
|
||||||
.
|
.
|
||||||
|
.IP
|
||||||
|
If \fBHOMEBREW_INSTALL_CLEANUP\fR is set then remove previously installed versions of upgraded \fIformulae\fR as well as the HOMEBREW_CACHE for that formula\.
|
||||||
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBleaves\fR
|
\fBleaves\fR
|
||||||
Show installed formulae that are not dependencies of another installed formula\.
|
Show installed formulae that are not dependencies of another installed formula\.
|
||||||
@ -438,6 +441,9 @@ Uninstall and then install \fIformula\fR (with existing install options)\.
|
|||||||
.IP
|
.IP
|
||||||
If \fB\-\-display\-times\fR is passed, install times for each formula are printed at the end of the run\.
|
If \fB\-\-display\-times\fR is passed, install times for each formula are printed at the end of the run\.
|
||||||
.
|
.
|
||||||
|
.IP
|
||||||
|
If \fBHOMEBREW_INSTALL_CLEANUP\fR is set then remove previously installed versions of upgraded \fIformulae\fR as well as the HOMEBREW_CACHE for that formula\.
|
||||||
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBsearch\fR, \fB\-S\fR
|
\fBsearch\fR, \fB\-S\fR
|
||||||
Display all locally available formulae (including tapped ones)\. No online search is performed\.
|
Display all locally available formulae (including tapped ones)\. No online search is performed\.
|
||||||
@ -614,7 +620,7 @@ Upgrade outdated, unpinned brews (with existing install options)\.
|
|||||||
Options for the \fBinstall\fR command are also valid here\.
|
Options for the \fBinstall\fR command are also valid here\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
If \fB\-\-cleanup\fR is specified or \fBHOMEBREW_UPGRADE_CLEANUP\fR is set then remove previously installed version(s) of upgraded \fIformulae\fR\.
|
If \fB\-\-cleanup\fR is specified or \fBHOMEBREW_INSTALL_CLEANUP\fR is set then remove previously installed version(s) of upgraded \fIformulae\fR\.
|
||||||
.
|
.
|
||||||
.IP
|
.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\.
|
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\.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user