Skip to content

Commit

Permalink
Merge pull request #11963 from FnControlOption/install
Browse files Browse the repository at this point in the history
install: fetch all formulae before install
  • Loading branch information
MikeMcQuaid committed Sep 2, 2021
2 parents bd27111 + cf2800a commit e3f851d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 50 deletions.
40 changes: 18 additions & 22 deletions Library/Homebrew/cmd/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,28 +202,24 @@ def install

Install.perform_preinstall_checks(cc: args.cc)

installed_formulae.each do |f|
Migrator.migrate_if_needed(f, force: args.force?)
Install.install_formula(
f,
build_bottle: args.build_bottle?,
force_bottle: args.force_bottle?,
bottle_arch: args.bottle_arch,
ignore_deps: args.ignore_dependencies?,
only_deps: args.only_dependencies?,
include_test_formulae: args.include_test_formulae,
build_from_source_formulae: args.build_from_source_formulae,
cc: args.cc,
git: args.git?,
interactive: args.interactive?,
keep_tmp: args.keep_tmp?,
force: args.force?,
debug: args.debug?,
quiet: args.quiet?,
verbose: args.verbose?,
)
Cleanup.install_formula_clean!(f)
end
Install.install_formulae(
installed_formulae,
build_bottle: args.build_bottle?,
force_bottle: args.force_bottle?,
bottle_arch: args.bottle_arch,
ignore_deps: args.ignore_dependencies?,
only_deps: args.only_dependencies?,
include_test_formulae: args.include_test_formulae,
build_from_source_formulae: args.build_from_source_formulae,
cc: args.cc,
git: args.git?,
interactive: args.interactive?,
keep_tmp: args.keep_tmp?,
force: args.force?,
debug: args.debug?,
quiet: args.quiet?,
verbose: args.verbose?,
)

Upgrade.check_installed_dependents(
installed_formulae,
Expand Down
77 changes: 49 additions & 28 deletions Library/Homebrew/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ def install_formula?(
false
end

def install_formula(
f,
def install_formulae(
formulae_to_install,
build_bottle: false,
force_bottle: false,
bottle_arch: nil,
Expand All @@ -247,28 +247,49 @@ def install_formula(
quiet: false,
verbose: false
)
formula_installers = formulae_to_install.map do |f|
Migrator.migrate_if_needed(f, force: force)
build_options = f.build

fi = FormulaInstaller.new(
f,
options: build_options.used_options,
build_bottle: build_bottle,
force_bottle: force_bottle,
bottle_arch: bottle_arch,
ignore_deps: ignore_deps,
only_deps: only_deps,
include_test_formulae: include_test_formulae,
build_from_source_formulae: build_from_source_formulae,
cc: cc,
git: git,
interactive: interactive,
keep_tmp: keep_tmp,
force: force,
debug: debug,
quiet: quiet,
verbose: verbose,
)

begin
fi.fetch
fi
rescue UnsatisfiedRequirements, DownloadError, ChecksumMismatchError => e
ofail "#{f}: #{e}"
nil
end
end.compact

formula_installers.each do |fi|
install_formula(fi, only_deps: only_deps)
Cleanup.install_formula_clean!(fi.formula)
end
end

def install_formula(formula_installer, only_deps: false)
f = formula_installer.formula

f.print_tap_action
build_options = f.build

fi = FormulaInstaller.new(
f,
options: build_options.used_options,
build_bottle: build_bottle,
force_bottle: force_bottle,
bottle_arch: bottle_arch,
ignore_deps: ignore_deps,
only_deps: only_deps,
include_test_formulae: include_test_formulae,
build_from_source_formulae: build_from_source_formulae,
cc: cc,
git: git,
interactive: interactive,
keep_tmp: keep_tmp,
force: force,
debug: debug,
quiet: quiet,
verbose: verbose,
)

if f.linked_keg.directory?
if Homebrew::EnvConfig.no_install_upgrade?
Expand All @@ -291,17 +312,16 @@ def install_formula(
puts "#{f.name} #{f.linked_version} is installed but outdated"
kegs = Upgrade.outdated_kegs(f)
linked_kegs = kegs.select(&:linked?)
Upgrade.print_upgrade_message(f, fi.options)
Upgrade.print_upgrade_message(f, formula_installer.options)
end
end

fi.prelude
fi.fetch
formula_installer.prelude

kegs.each(&:unlink) if kegs.present?

fi.install
fi.finish
formula_installer.install
formula_installer.finish
rescue FormulaInstallationAlreadyAttemptedError
# 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.
Expand All @@ -316,6 +336,7 @@ def install_formula(
nil
end
end
private_class_method :install_formula
end
end

Expand Down

0 comments on commit e3f851d

Please sign in to comment.