Fix handling of formula install blocks
This commit is contained in:
parent
48459b29c3
commit
b2ffe7b060
@ -336,24 +336,28 @@ module Homebrew
|
|||||||
fi.download_queue = download_queue
|
fi.download_queue = download_queue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
valid_formula_installers = formula_installers.dup
|
||||||
|
|
||||||
begin
|
begin
|
||||||
[:prelude_fetch, :prelude, :fetch].each do |step|
|
[:prelude_fetch, :prelude, :fetch].each do |step|
|
||||||
formula_installers.each do |fi|
|
valid_formula_installers.select! do |fi|
|
||||||
fi.public_send(step)
|
fi.public_send(step)
|
||||||
rescue UnsatisfiedRequirements, DownloadError, ChecksumMismatchError => e
|
true
|
||||||
ofail "#{fi.formula}: #{e}"
|
|
||||||
next
|
|
||||||
end
|
|
||||||
download_queue&.fetch
|
|
||||||
rescue CannotInstallFormulaError => e
|
rescue CannotInstallFormulaError => e
|
||||||
ofail e.message
|
ofail e.message
|
||||||
next
|
false
|
||||||
|
rescue UnsatisfiedRequirements, DownloadError, ChecksumMismatchError => e
|
||||||
|
ofail "#{fi.formula}: #{e}"
|
||||||
|
false
|
||||||
|
end
|
||||||
|
download_queue&.fetch
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
download_queue&.shutdown
|
download_queue&.shutdown
|
||||||
end
|
end
|
||||||
|
|
||||||
formula_installers.each do |fi|
|
valid_formula_installers.each do |fi|
|
||||||
install_formula(fi)
|
install_formula(fi)
|
||||||
Cleanup.install_formula_clean!(fi.formula)
|
Cleanup.install_formula_clean!(fi.formula)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -95,4 +95,14 @@ RSpec.describe Homebrew::Cmd::InstallCmd do
|
|||||||
|
|
||||||
expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file
|
expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "refuses to install forbidden formulae", :integration_test do
|
||||||
|
setup_test_formula "testball1"
|
||||||
|
|
||||||
|
expect { brew "install", "testball1", { "HOMEBREW_FORBIDDEN_FORMULAE" => "testball1" } }
|
||||||
|
.to not_to_output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}o).to_stdout
|
||||||
|
.and output(/testball1 was forbidden/).to_stderr
|
||||||
|
.and be_a_failure
|
||||||
|
expect(HOMEBREW_CELLAR/"testball1").not_to exist
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -34,4 +34,18 @@ RSpec.describe Homebrew::Cmd::Reinstall do
|
|||||||
|
|
||||||
expect(foo_dir).to exist
|
expect(foo_dir).to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "refuses to reinstall a forbidden formula", :integration_test do
|
||||||
|
install_test_formula "testball"
|
||||||
|
foo_dir = HOMEBREW_CELLAR/"testball/0.1/bin"
|
||||||
|
expect(foo_dir).to exist
|
||||||
|
FileUtils.rm_r(foo_dir)
|
||||||
|
|
||||||
|
expect { brew "reinstall", "testball", { "HOMEBREW_FORBIDDEN_FORMULAE" => "testball" } }
|
||||||
|
.to not_to_output(%r{#{HOMEBREW_CELLAR}/testball/0\.1}o).to_stdout
|
||||||
|
.and output(/testball was forbidden/).to_stderr
|
||||||
|
.and be_a_failure
|
||||||
|
|
||||||
|
expect(foo_dir).not_to exist
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -28,4 +28,15 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
|
|||||||
expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory
|
expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory
|
||||||
expect(HOMEBREW_CELLAR/"testball/0.0.1").not_to exist
|
expect(HOMEBREW_CELLAR/"testball/0.0.1").not_to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "refuses to upgrades a forbidden formula", :integration_test do
|
||||||
|
setup_test_formula "testball"
|
||||||
|
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||||
|
|
||||||
|
expect { brew "upgrade", "testball", { "HOMEBREW_FORBIDDEN_FORMULAE" => "testball" } }
|
||||||
|
.to not_to_output(%r{#{HOMEBREW_CELLAR}/testball/0\.1}o).to_stdout
|
||||||
|
.and output(/testball was forbidden/).to_stderr
|
||||||
|
.and be_a_failure
|
||||||
|
expect(HOMEBREW_CELLAR/"testball/0.1").not_to exist
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -92,18 +92,23 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.upgrade_formulae(formula_installers, dry_run: false, verbose: false)
|
def self.upgrade_formulae(formula_installers, dry_run: false, verbose: false)
|
||||||
|
valid_formula_installers = formula_installers.dup
|
||||||
|
|
||||||
unless dry_run
|
unless dry_run
|
||||||
formula_installers.each do |fi|
|
valid_formula_installers.select! do |fi|
|
||||||
fi.prelude
|
fi.prelude
|
||||||
fi.fetch
|
fi.fetch
|
||||||
|
true
|
||||||
rescue CannotInstallFormulaError => e
|
rescue CannotInstallFormulaError => e
|
||||||
ofail e
|
ofail e
|
||||||
|
false
|
||||||
rescue UnsatisfiedRequirements, DownloadError => e
|
rescue UnsatisfiedRequirements, DownloadError => e
|
||||||
ofail "#{fi.formula.full_name}: #{e}"
|
ofail "#{fi.formula.full_name}: #{e}"
|
||||||
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
formula_installers.each do |fi|
|
valid_formula_installers.each do |fi|
|
||||||
upgrade_formula(fi, dry_run:, verbose:)
|
upgrade_formula(fi, dry_run:, verbose:)
|
||||||
Cleanup.install_formula_clean!(fi.formula, dry_run:)
|
Cleanup.install_formula_clean!(fi.formula, dry_run:)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user