From 11cf77be175760760d6d9ddca6d30ef4f2d5fbea Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 23 May 2020 13:40:13 +0100 Subject: [PATCH] formula_installer: prelude before fetch. This ensures that dependencies are verified and tapped before they are fetched. `FormulaInstaller#lock` has been moved into `FormulaInstaller#install` to avoid locking until necessary. While we're here, don't compute dependencies before fetching if we're not going to use them. --- Library/Homebrew/cask/installer.rb | 2 +- Library/Homebrew/cmd/install.rb | 2 +- Library/Homebrew/cmd/upgrade.rb | 2 +- Library/Homebrew/formula_installer.rb | 8 +++++--- Library/Homebrew/reinstall.rb | 2 +- .../helper/spec/shared_context/integration_test.rb | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/cask/installer.rb b/Library/Homebrew/cask/installer.rb index 503962e308def..369b05f1d0610 100644 --- a/Library/Homebrew/cask/installer.rb +++ b/Library/Homebrew/cask/installer.rb @@ -368,8 +368,8 @@ def cask_and_formula_dependencies fi.installed_on_request = false fi.show_header = true fi.verbose = verbose? - fi.fetch fi.prelude + fi.fetch fi.install fi.finish end diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 03f373447de3d..ef95b00c76626 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -325,8 +325,8 @@ def install_formula(f) fi.build_bottle = args.build_bottle? fi.interactive = args.interactive? fi.git = args.git? - fi.fetch 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 df2481fb10f09..c9099de7411ae 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -191,8 +191,8 @@ def upgrade_formula(f) end oh1 "Upgrading #{Formatter.identifier(f.full_specified_name)} #{upgrade_version} #{fi.options.to_a.join(" ")}" - fi.fetch fi.prelude + 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 diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index c6b632ee79ecf..4365c0fbe9c10 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -141,7 +141,6 @@ def install_bottle_for?(dep, build) def prelude Tab.clear_cache verify_deps_exist unless ignore_deps? - lock check_install_sanity end @@ -221,6 +220,8 @@ def build_bottle_postinstall end def install + lock + start_time = Time.now if !formula.bottle_unneeded? && !pour_bottle? && DevelopmentTools.installed? Homebrew::Install.perform_build_from_source_checks @@ -969,9 +970,10 @@ def post_install end def fetch_dependencies - deps = compute_dependencies + return if ignore_deps? - return if deps.empty? || ignore_deps? + deps = compute_dependencies + return if deps.empty? deps.each { |dep, _options| fetch_dependency(dep) } end diff --git a/Library/Homebrew/reinstall.rb b/Library/Homebrew/reinstall.rb index ff3c5707f2187..be7f9c847eabd 100644 --- a/Library/Homebrew/reinstall.rb +++ b/Library/Homebrew/reinstall.rb @@ -35,8 +35,8 @@ def reinstall_formula(f, build_from_source: false) fi.installed_as_dependency = tab.installed_as_dependency fi.installed_on_request = tab.installed_on_request end - fi.fetch fi.prelude + fi.fetch oh1 "Reinstalling #{Formatter.identifier(f.full_name)} #{options.to_a.join " "}" 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 3f4468a3a79bf..cbc933817d0af 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 @@ -176,8 +176,8 @@ def install_test_formula(name, content = nil, build_bottle: false) setup_test_formula(name, content) fi = FormulaInstaller.new(Formula[name]) fi.build_bottle = build_bottle - fi.fetch fi.prelude + fi.fetch fi.install fi.finish end