install, upgrade: run formula installer prelude before fetching

This commit is contained in:
fn ⌃ ⌥ 2021-09-10 06:01:37 -07:00
parent a96e286400
commit 0c3afa5837
3 changed files with 16 additions and 8 deletions

View File

@ -218,8 +218,12 @@ class FormulaInstaller
raise raise
end end
def check_install_sanity def check_installation_already_attempted
raise FormulaInstallationAlreadyAttemptedError, formula if self.class.attempted.include?(formula) raise FormulaInstallationAlreadyAttemptedError, formula if self.class.attempted.include?(formula)
end
def check_install_sanity
check_installation_already_attempted
if force_bottle? && !pour_bottle? if force_bottle? && !pour_bottle?
raise CannotInstallFormulaError, "--force-bottle passed but #{formula.full_name} has no bottle!" raise CannotInstallFormulaError, "--force-bottle passed but #{formula.full_name} has no bottle!"

View File

@ -291,8 +291,11 @@ module Homebrew
) )
begin begin
fi.prelude
fi.fetch fi.fetch
fi fi
rescue CannotInstallFormulaError => e
ofail e.message
rescue UnsatisfiedRequirements, DownloadError, ChecksumMismatchError => e rescue UnsatisfiedRequirements, DownloadError, ChecksumMismatchError => e
ofail "#{f}: #{e}" ofail "#{f}: #{e}"
nil nil
@ -308,7 +311,7 @@ module Homebrew
def install_formula(formula_installer) def install_formula(formula_installer)
f = formula_installer.formula f = formula_installer.formula
formula_installer.prelude formula_installer.check_installation_already_attempted
f.print_tap_action f.print_tap_action
@ -327,8 +330,6 @@ module Homebrew
# We already attempted to install f as part of the dependency tree of # 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. # another formula. In that case, don't generate an error, just move on.
nil nil
rescue CannotInstallFormulaError => e
ofail e.message
ensure ensure
# Re-link kegs if upgrade fails # Re-link kegs if upgrade fails
begin begin

View File

@ -58,8 +58,13 @@ module Homebrew
quiet: quiet, quiet: quiet,
verbose: verbose, verbose: verbose,
) )
fi.fetch unless dry_run unless dry_run
fi.prelude
fi.fetch
end
fi fi
rescue CannotInstallFormulaError => e
ofail e
rescue UnsatisfiedRequirements, DownloadError => e rescue UnsatisfiedRequirements, DownloadError => e
ofail "#{formula}: #{e}" ofail "#{formula}: #{e}"
nil nil
@ -167,7 +172,7 @@ module Homebrew
return return
end end
formula_installer.prelude formula_installer.check_installation_already_attempted
print_upgrade_message(formula, formula_installer.options) 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 # 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. # another formula. In that case, don't generate an error, just move on.
nil nil
rescue CannotInstallFormulaError => e
ofail e
rescue BuildError => e rescue BuildError => e
e.dump(verbose: verbose) e.dump(verbose: verbose)
puts puts