Merge pull request #18547 from Homebrew/cask-formula-dep-preinstall
Perform preinstall checks when a formula is installed via a cask
This commit is contained in:
commit
d1e539cb84
@ -368,6 +368,7 @@ on_request: true)
|
||||
force: false,
|
||||
).install
|
||||
else
|
||||
Homebrew::Install.perform_preinstall_checks_once
|
||||
fi = FormulaInstaller.new(
|
||||
cask_or_formula,
|
||||
**{
|
||||
|
@ -31,7 +31,7 @@ module Homebrew
|
||||
|
||||
sig { override.void }
|
||||
def run
|
||||
Install.perform_preinstall_checks(all_fatal: true)
|
||||
Install.perform_preinstall_checks_once(all_fatal: true)
|
||||
Install.perform_build_from_source_checks(all_fatal: true)
|
||||
return unless (formula = args.named.to_resolved_formulae.first)
|
||||
|
||||
|
@ -295,7 +295,8 @@ module Homebrew
|
||||
|
||||
return if formulae.any? && installed_formulae.empty?
|
||||
|
||||
Install.perform_preinstall_checks(cc: args.cc)
|
||||
Install.perform_preinstall_checks_once
|
||||
Install.check_cc_argv(args.cc)
|
||||
|
||||
Install.install_formulae(
|
||||
installed_formulae,
|
||||
|
@ -126,16 +126,35 @@ module Homebrew
|
||||
|
||||
formulae = Homebrew::Attestation.sort_formulae_for_install(formulae) if Homebrew::Attestation.enabled?
|
||||
|
||||
Install.perform_preinstall_checks
|
||||
unless formulae.empty?
|
||||
Install.perform_preinstall_checks_once
|
||||
|
||||
formulae.each do |formula|
|
||||
if formula.pinned?
|
||||
onoe "#{formula.full_name} is pinned. You must unpin it to reinstall."
|
||||
next
|
||||
formulae.each do |formula|
|
||||
if formula.pinned?
|
||||
onoe "#{formula.full_name} is pinned. You must unpin it to reinstall."
|
||||
next
|
||||
end
|
||||
Migrator.migrate_if_needed(formula, force: args.force?)
|
||||
Homebrew::Reinstall.reinstall_formula(
|
||||
formula,
|
||||
flags: args.flags_only,
|
||||
installed_on_request: args.named.present?,
|
||||
force_bottle: args.force_bottle?,
|
||||
build_from_source_formulae: args.build_from_source_formulae,
|
||||
interactive: args.interactive?,
|
||||
keep_tmp: args.keep_tmp?,
|
||||
debug_symbols: args.debug_symbols?,
|
||||
force: args.force?,
|
||||
debug: args.debug?,
|
||||
quiet: args.quiet?,
|
||||
verbose: args.verbose?,
|
||||
git: args.git?,
|
||||
)
|
||||
Cleanup.install_formula_clean!(formula)
|
||||
end
|
||||
Migrator.migrate_if_needed(formula, force: args.force?)
|
||||
Homebrew::Reinstall.reinstall_formula(
|
||||
formula,
|
||||
|
||||
Upgrade.check_installed_dependents(
|
||||
formulae,
|
||||
flags: args.flags_only,
|
||||
installed_on_request: args.named.present?,
|
||||
force_bottle: args.force_bottle?,
|
||||
@ -147,26 +166,9 @@ module Homebrew
|
||||
debug: args.debug?,
|
||||
quiet: args.quiet?,
|
||||
verbose: args.verbose?,
|
||||
git: args.git?,
|
||||
)
|
||||
Cleanup.install_formula_clean!(formula)
|
||||
end
|
||||
|
||||
Upgrade.check_installed_dependents(
|
||||
formulae,
|
||||
flags: args.flags_only,
|
||||
installed_on_request: args.named.present?,
|
||||
force_bottle: args.force_bottle?,
|
||||
build_from_source_formulae: args.build_from_source_formulae,
|
||||
interactive: args.interactive?,
|
||||
keep_tmp: args.keep_tmp?,
|
||||
debug_symbols: args.debug_symbols?,
|
||||
force: args.force?,
|
||||
debug: args.debug?,
|
||||
quiet: args.quiet?,
|
||||
verbose: args.verbose?,
|
||||
)
|
||||
|
||||
if casks.any?
|
||||
Cask::Reinstall.reinstall_casks(
|
||||
*casks,
|
||||
|
@ -154,8 +154,6 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
Install.perform_preinstall_checks
|
||||
|
||||
if formulae.blank?
|
||||
outdated = Formula.installed.select do |f|
|
||||
f.outdated?(fetch_head: args.fetch_HEAD?)
|
||||
@ -212,6 +210,8 @@ module Homebrew
|
||||
puts formulae_upgrades.join("\n")
|
||||
end
|
||||
|
||||
Install.perform_preinstall_checks_once
|
||||
|
||||
Upgrade.upgrade_formulae(
|
||||
formulae_to_install,
|
||||
flags: args.flags_only,
|
||||
|
@ -30,11 +30,12 @@ module Homebrew
|
||||
].freeze
|
||||
private_constant :GCC_RUNTIME_LIBS
|
||||
|
||||
def self.perform_preinstall_checks(all_fatal: false, cc: nil)
|
||||
generic_perform_preinstall_checks(all_fatal:, cc:)
|
||||
def self.perform_preinstall_checks(all_fatal: false)
|
||||
generic_perform_preinstall_checks(all_fatal:)
|
||||
symlink_ld_so
|
||||
setup_preferred_gcc_libs
|
||||
end
|
||||
private_class_method :perform_preinstall_checks
|
||||
|
||||
def self.global_post_install
|
||||
generic_global_post_install
|
||||
|
@ -11,15 +11,24 @@ module Homebrew
|
||||
# Helper module for performing (pre-)install checks.
|
||||
module Install
|
||||
class << self
|
||||
def perform_preinstall_checks(all_fatal: false, cc: nil)
|
||||
check_prefix
|
||||
check_cpu
|
||||
attempt_directory_creation
|
||||
check_cc_argv(cc)
|
||||
Diagnostic.checks(:supported_configuration_checks, fatal: all_fatal)
|
||||
Diagnostic.checks(:fatal_preinstall_checks)
|
||||
sig { params(all_fatal: T::Boolean).void }
|
||||
def perform_preinstall_checks_once(all_fatal: false)
|
||||
@perform_preinstall_checks_once ||= {}
|
||||
@perform_preinstall_checks_once[all_fatal] ||= begin
|
||||
perform_preinstall_checks(all_fatal:)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def check_cc_argv(cc)
|
||||
return unless cc
|
||||
|
||||
@checks ||= Diagnostic::Checks.new
|
||||
opoo <<~EOS
|
||||
You passed `--cc=#{cc}`.
|
||||
#{@checks.please_create_pull_requests}
|
||||
EOS
|
||||
end
|
||||
alias generic_perform_preinstall_checks perform_preinstall_checks
|
||||
|
||||
def perform_build_from_source_checks(all_fatal: false)
|
||||
Diagnostic.checks(:fatal_build_from_source_checks)
|
||||
@ -315,15 +324,14 @@ module Homebrew
|
||||
|
||||
private
|
||||
|
||||
def check_cc_argv(cc)
|
||||
return unless cc
|
||||
|
||||
@checks ||= Diagnostic::Checks.new
|
||||
opoo <<~EOS
|
||||
You passed `--cc=#{cc}`.
|
||||
#{@checks.please_create_pull_requests}
|
||||
EOS
|
||||
def perform_preinstall_checks(all_fatal: false)
|
||||
check_prefix
|
||||
check_cpu
|
||||
attempt_directory_creation
|
||||
Diagnostic.checks(:supported_configuration_checks, fatal: all_fatal)
|
||||
Diagnostic.checks(:fatal_preinstall_checks)
|
||||
end
|
||||
alias generic_perform_preinstall_checks perform_preinstall_checks
|
||||
|
||||
def attempt_directory_creation
|
||||
Keg.must_exist_directories.each do |dir|
|
||||
|
Loading…
x
Reference in New Issue
Block a user