diff --git a/Library/Homebrew/cask/installer.rb b/Library/Homebrew/cask/installer.rb index 212e40720a..369b05f1d0 100644 --- a/Library/Homebrew/cask/installer.rb +++ b/Library/Homebrew/cask/installer.rb @@ -369,6 +369,7 @@ module Cask fi.show_header = true fi.verbose = verbose? fi.prelude + fi.fetch fi.install fi.finish end diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 7d60894b9b..ef95b00c76 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -326,6 +326,7 @@ module Homebrew fi.interactive = args.interactive? fi.git = args.git? fi.prelude + fi.fetch fi.install fi.finish rescue FormulaInstallationAlreadyAttemptedError diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 80841542a2..f417c7c54f 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -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! diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index f431b19dfa..499937efd3 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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 diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index dcce9bbb84..7c5e82cba9 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -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 diff --git a/Library/Homebrew/reinstall.rb b/Library/Homebrew/reinstall.rb index 8fc5ed649d..be7f9c847e 100644 --- a/Library/Homebrew/reinstall.rb +++ b/Library/Homebrew/reinstall.rb @@ -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 " "}" diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index 920a787c3f..2d7d6f6d03 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -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 diff --git a/Library/Homebrew/test/formula_installer_bottle_spec.rb b/Library/Homebrew/test/formula_installer_bottle_spec.rb index d1a86b59c2..b5e715260f 100644 --- a/Library/Homebrew/test/formula_installer_bottle_spec.rb +++ b/Library/Homebrew/test/formula_installer_bottle_spec.rb @@ -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) diff --git a/Library/Homebrew/test/formula_installer_spec.rb b/Library/Homebrew/test/formula_installer_spec.rb index d7dcd713c1..cd5856a0bf 100644 --- a/Library/Homebrew/test/formula_installer_spec.rb +++ b/Library/Homebrew/test/formula_installer_spec.rb @@ -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 diff --git a/Library/Homebrew/test/formulary_spec.rb b/Library/Homebrew/test/formulary_spec.rb index 3170b71cb2..157b608050 100644 --- a/Library/Homebrew/test/formulary_spec.rb +++ b/Library/Homebrew/test/formulary_spec.rb @@ -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) diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb index 0a28b8b558..cbc933817d 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb @@ -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