From 0c3afa583716e55fe7e5ebcc31fd6f9e1b3f581d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fn=20=E2=8C=83=20=E2=8C=A5?= <70830482+FnControlOption@users.noreply.github.com> Date: Fri, 10 Sep 2021 06:01:37 -0700 Subject: [PATCH] install, upgrade: run formula installer prelude before fetching --- Library/Homebrew/formula_installer.rb | 6 +++++- Library/Homebrew/install.rb | 7 ++++--- Library/Homebrew/upgrade.rb | 11 +++++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 04375fcbe7..7a7fc8b8ef 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -218,8 +218,12 @@ class FormulaInstaller raise end - def check_install_sanity + def check_installation_already_attempted raise FormulaInstallationAlreadyAttemptedError, formula if self.class.attempted.include?(formula) + end + + def check_install_sanity + check_installation_already_attempted if force_bottle? && !pour_bottle? raise CannotInstallFormulaError, "--force-bottle passed but #{formula.full_name} has no bottle!" diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 798bd99047..191ad6f0b5 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -291,8 +291,11 @@ module Homebrew ) begin + fi.prelude fi.fetch fi + rescue CannotInstallFormulaError => e + ofail e.message rescue UnsatisfiedRequirements, DownloadError, ChecksumMismatchError => e ofail "#{f}: #{e}" nil @@ -308,7 +311,7 @@ module Homebrew def install_formula(formula_installer) f = formula_installer.formula - formula_installer.prelude + formula_installer.check_installation_already_attempted f.print_tap_action @@ -327,8 +330,6 @@ module Homebrew # We already attempted to install f as part of the dependency tree of # another formula. In that case, don't generate an error, just move on. nil - rescue CannotInstallFormulaError => e - ofail e.message ensure # Re-link kegs if upgrade fails begin diff --git a/Library/Homebrew/upgrade.rb b/Library/Homebrew/upgrade.rb index b90bdfb6dc..e203045090 100644 --- a/Library/Homebrew/upgrade.rb +++ b/Library/Homebrew/upgrade.rb @@ -58,8 +58,13 @@ module Homebrew quiet: quiet, verbose: verbose, ) - fi.fetch unless dry_run + unless dry_run + fi.prelude + fi.fetch + end fi + rescue CannotInstallFormulaError => e + ofail e rescue UnsatisfiedRequirements, DownloadError => e ofail "#{formula}: #{e}" nil @@ -167,7 +172,7 @@ module Homebrew return end - formula_installer.prelude + formula_installer.check_installation_already_attempted print_upgrade_message(formula, formula_installer.options) @@ -182,8 +187,6 @@ module Homebrew # We already attempted to upgrade f as part of the dependency tree of # another formula. In that case, don't generate an error, just move on. nil - rescue CannotInstallFormulaError => e - ofail e rescue BuildError => e e.dump(verbose: verbose) puts