Merge pull request #7124 from MichelleNguy/brew-upgrade

Fetch formula resources before unlinking during upgrade.
This commit is contained in:
Mike McQuaid 2020-05-11 10:03:43 +01:00 committed by GitHub
commit 806bdee516
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 55 additions and 10 deletions

View File

@ -368,6 +368,7 @@ module Cask
fi.installed_on_request = false
fi.show_header = true
fi.verbose = verbose?
fi.fetch
fi.prelude
fi.install
fi.finish

View File

@ -325,6 +325,7 @@ module Homebrew
fi.build_bottle = args.build_bottle?
fi.interactive = args.interactive?
fi.git = args.git?
fi.fetch
fi.prelude
fi.install
fi.finish

View File

@ -183,7 +183,6 @@ module Homebrew
fi.installed_as_dependency = tab.installed_as_dependency
fi.installed_on_request ||= tab.installed_on_request
end
fi.prelude
upgrade_version = if f.optlinked?
"#{Keg.new(f.opt_prefix).version} -> #{f.pkg_version}"
@ -192,6 +191,9 @@ module Homebrew
end
oh1 "Upgrading #{Formatter.identifier(f.full_specified_name)} #{upgrade_version} #{fi.options.to_a.join(" ")}"
fi.fetch
fi.prelude
# 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

@ -561,6 +561,18 @@ class FormulaInstaller
@show_header = true unless deps.empty?
end
def fetch_dependency(dep)
df = dep.to_formula
fi = FormulaInstaller.new(df)
fi.build_from_source = Homebrew.args.build_formula_from_source?(df)
fi.force_bottle = false
fi.verbose = verbose?
fi.quiet = quiet?
fi.debug = debug?
fi.fetch
end
def install_dependency(dep, inherited_options)
df = dep.to_formula
tab = Tab.for_formula(df)
@ -946,14 +958,33 @@ 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 { |dep, _options| fetch_dependency(dep) }
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

@ -35,6 +35,7 @@ module Homebrew
fi.installed_as_dependency = tab.installed_as_dependency
fi.installed_on_request = tab.installed_on_request
end
fi.fetch
fi.prelude
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

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