Fetch formula resources before unlinking during upgrade.

Fixes #6374.
This commit is contained in:
Michelle Nguyen 2020-03-04 17:48:17 -05:00 committed by Mike McQuaid
parent fc56a3d354
commit 2264c08cee
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
11 changed files with 45 additions and 9 deletions

View File

@ -369,6 +369,7 @@ module Cask
fi.show_header = true
fi.verbose = verbose?
fi.prelude
fi.fetch
fi.install
fi.finish
end

View File

@ -326,6 +326,7 @@ module Homebrew
fi.interactive = args.interactive?
fi.git = args.git?
fi.prelude
fi.fetch
fi.install
fi.finish
rescue FormulaInstallationAlreadyAttemptedError

View File

@ -192,6 +192,8 @@ module Homebrew
end
oh1 "Upgrading #{Formatter.identifier(f.full_specified_name)} #{upgrade_version} #{fi.options.to_a.join(" ")}"
fi.fetch
# first we unlink the currently active keg for this formula otherwise it is
# possible for the existing build to interfere with the build we are about to
# do! Seriously, it happens!

View File

@ -1160,6 +1160,7 @@ class Formula
# @private
def brew
@prefix_returns_versioned_prefix = true
active_spec.fetch
stage do |staging|
staging.retain! if Homebrew.args.keep_tmp?
prepare_patches

View File

@ -600,6 +600,7 @@ class FormulaInstaller
fi.installed_as_dependency = true
fi.installed_on_request = df.any_version_installed? && tab.installed_on_request
fi.prelude
fi.fetch
oh1 "Installing #{formula.full_name} dependency: #{Formatter.identifier(dep.name)}"
fi.install
fi.finish
@ -946,14 +947,35 @@ class FormulaInstaller
@show_summary_heading = true
end
def pour
if (bottle_path = formula.local_bottle_path)
downloader = LocalBottleDownloadStrategy.new(bottle_path)
else
downloader = formula.bottle
downloader.fetch
end
def fetch_dependencies
deps = compute_dependencies
return if deps.empty? || ignore_deps?
deps.each do |dep, _|
dep.to_formula.resources.each(&:fetch)
end
end
def fetch
fetch_dependencies
return if only_deps?
downloader.fetch
end
def downloader
if (bottle_path = formula.local_bottle_path)
LocalBottleDownloadStrategy.new(bottle_path)
elsif pour_bottle?
formula.bottle
else
formula.downloader
end
end
def pour
HOMEBREW_CELLAR.cd do
downloader.stage
end

View File

@ -36,6 +36,7 @@ module Homebrew
fi.installed_on_request = tab.installed_on_request
end
fi.prelude
fi.fetch
oh1 "Reinstalling #{Formatter.identifier(f.full_name)} #{options.to_a.join " "}"

View File

@ -70,8 +70,8 @@ class Resource
def stage(target = nil, &block)
raise ArgumentError, "target directory or block is required" unless target || block
fetch
prepare_patches
unpack(target, &block)
end

View File

@ -23,7 +23,10 @@ describe FormulaInstaller do
stub_formula_loader formula("gcc") { url "gcc-1.0" }
stub_formula_loader formula("patchelf") { url "patchelf-1.0" }
allow(Formula["patchelf"]).to receive(:latest_version_installed?).and_return(true)
described_class.new(formula).install
fi = FormulaInstaller.new(formula)
fi.fetch
fi.install
keg = Keg.new(formula.prefix)

View File

@ -21,6 +21,7 @@ describe FormulaInstaller do
installer = described_class.new(formula)
installer.fetch
installer.install
keg = Keg.new(formula.prefix)
@ -158,6 +159,7 @@ describe FormulaInstaller do
it "shows audit problems if HOMEBREW_DEVELOPER is set" do
ENV["HOMEBREW_DEVELOPER"] = "1"
formula_installer.fetch
formula_installer.install
expect(formula_installer).to receive(:audit_installed).and_call_original
formula_installer.caveats

View File

@ -149,6 +149,7 @@ describe Formulary do
let(:installer) { FormulaInstaller.new(installed_formula) }
it "returns a Formula when given a rack" do
installer.fetch
installer.install
f = described_class.from_rack(installed_formula.rack)
@ -156,6 +157,7 @@ describe Formulary do
end
it "returns a Formula when given a Keg" do
installer.fetch
installer.install
keg = Keg.new(installed_formula.prefix)

View File

@ -177,6 +177,7 @@ RSpec.shared_context "integration test" do
fi = FormulaInstaller.new(Formula[name])
fi.build_bottle = build_bottle
fi.prelude
fi.fetch
fi.install
fi.finish
end