refactoring install
This commit is contained in:
parent
fd159ed32c
commit
a5251b2fb6
@ -310,9 +310,7 @@ module Homebrew
|
||||
Install.perform_preinstall_checks_once
|
||||
Install.check_cc_argv(args.cc)
|
||||
|
||||
Install.ask_formulae(installed_formulae, args: args) if args.ask?
|
||||
|
||||
Install.install_formulae(
|
||||
formulae_installer = Install.get_formulae_dependencies(
|
||||
installed_formulae,
|
||||
installed_on_request: !args.as_dependency?,
|
||||
installed_as_dependency: args.as_dependency?,
|
||||
@ -338,7 +336,8 @@ module Homebrew
|
||||
skip_link: args.skip_link?,
|
||||
)
|
||||
|
||||
Upgrade.check_installed_dependents(
|
||||
if args.ask?
|
||||
dependants = Upgrade.get_dependants(
|
||||
installed_formulae,
|
||||
flags: args.flags_only,
|
||||
installed_on_request: !args.as_dependency?,
|
||||
@ -354,6 +353,55 @@ module Homebrew
|
||||
dry_run: args.dry_run?,
|
||||
)
|
||||
|
||||
formulae_dependencies = formulae_installer.flat_map do |f|
|
||||
[f.formula, f.compute_dependencies.flatten.filter do |c|
|
||||
c.is_a? Dependency
|
||||
end.flat_map(&:to_formula)]
|
||||
end.flatten.uniq
|
||||
formulae_dependencies.concat(dependants.upgradeable) if dependants
|
||||
# Main block: if asking the user is enabled, show dependency and size information.
|
||||
Install.ask_formulae(formulae_dependencies, args: args)
|
||||
end
|
||||
|
||||
Upgrade.upgrade_formulae(formulae_installer,
|
||||
dry_run: args.dry_run?,
|
||||
verbose: args.verbose?)
|
||||
|
||||
unless args.ask?
|
||||
dependants = Upgrade.get_dependants(
|
||||
installed_formulae,
|
||||
flags: args.flags_only,
|
||||
dry_run: args.dry_run?,
|
||||
ask: args.ask?,
|
||||
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?,
|
||||
)
|
||||
end
|
||||
|
||||
if dependants
|
||||
Upgrade.upgrade_dependents(
|
||||
dependants, installed_formulae,
|
||||
flags: args.flags_only,
|
||||
dry_run: args.dry_run?,
|
||||
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?
|
||||
)
|
||||
end
|
||||
|
||||
Cleanup.periodic_clean!(dry_run: args.dry_run?)
|
||||
|
||||
Homebrew.messages.display_messages(display_times: args.display_times?)
|
||||
|
||||
@ -232,7 +232,7 @@ module Homebrew
|
||||
false
|
||||
end
|
||||
|
||||
def install_formulae(
|
||||
def get_formulae_dependencies(
|
||||
formulae_to_install,
|
||||
installed_on_request: true,
|
||||
installed_as_dependency: false,
|
||||
@ -257,11 +257,11 @@ module Homebrew
|
||||
skip_post_install: false,
|
||||
skip_link: false
|
||||
)
|
||||
formula_installers = formulae_to_install.filter_map do |formula|
|
||||
formulae_to_install.filter_map do |formula|
|
||||
Migrator.migrate_if_needed(formula, force:, dry_run:)
|
||||
build_options = formula.build
|
||||
|
||||
formula_installer = FormulaInstaller.new(
|
||||
FormulaInstaller.new(
|
||||
formula,
|
||||
options: build_options.used_options,
|
||||
installed_on_request:,
|
||||
@ -286,24 +286,36 @@ module Homebrew
|
||||
skip_post_install:,
|
||||
skip_link:,
|
||||
)
|
||||
|
||||
begin
|
||||
unless dry_run
|
||||
formula_installer.prelude
|
||||
formula_installer.fetch
|
||||
end
|
||||
formula_installer
|
||||
rescue CannotInstallFormulaError => e
|
||||
ofail e.message
|
||||
nil
|
||||
rescue UnsatisfiedRequirements, DownloadError, ChecksumMismatchError => e
|
||||
ofail "#{formula}: #{e}"
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def install_formulae(
|
||||
formula_installers,
|
||||
installed_on_request: true,
|
||||
installed_as_dependency: false,
|
||||
build_bottle: false,
|
||||
force_bottle: false,
|
||||
bottle_arch: nil,
|
||||
ignore_deps: false,
|
||||
only_deps: false,
|
||||
include_test_formulae: [],
|
||||
build_from_source_formulae: [],
|
||||
cc: nil,
|
||||
git: false,
|
||||
interactive: false,
|
||||
keep_tmp: false,
|
||||
debug_symbols: false,
|
||||
force: false,
|
||||
overwrite: false,
|
||||
debug: false,
|
||||
quiet: false,
|
||||
verbose: false,
|
||||
dry_run: false,
|
||||
skip_post_install: false,
|
||||
skip_link: false
|
||||
)
|
||||
if dry_run
|
||||
if (formulae_name_to_install = formulae_to_install.map(&:name))
|
||||
if (formulae_name_to_install = formula_installers.map(&:name))
|
||||
ohai "Would install #{Utils.pluralize("formula", formulae_name_to_install.count,
|
||||
plural: "e", include_count: true)}:"
|
||||
puts formulae_name_to_install.join(" ")
|
||||
@ -316,6 +328,18 @@ module Homebrew
|
||||
end
|
||||
|
||||
formula_installers.each do |fi|
|
||||
begin
|
||||
unless dry_run
|
||||
fi.prelude
|
||||
fi.fetch
|
||||
end
|
||||
rescue CannotInstallFormulaError => e
|
||||
ofail e.message
|
||||
next
|
||||
rescue UnsatisfiedRequirements, DownloadError, ChecksumMismatchError => e
|
||||
ofail "#{formula}: #{e}"
|
||||
next
|
||||
end
|
||||
install_formula(fi)
|
||||
Cleanup.install_formula_clean!(fi.formula)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user