upgrade: add install_formula helper method
This commit is contained in:
parent
0c3afa5837
commit
15e8852128
@ -212,7 +212,10 @@ module Homebrew
|
|||||||
elsif f.linked?
|
elsif f.linked?
|
||||||
message = "#{f.name} #{f.linked_version} is already installed"
|
message = "#{f.name} #{f.linked_version} is already installed"
|
||||||
if f.outdated? && !head
|
if f.outdated? && !head
|
||||||
return true unless Homebrew::EnvConfig.no_install_upgrade?
|
unless Homebrew::EnvConfig.no_install_upgrade?
|
||||||
|
puts "#{message} but outdated"
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
onoe <<~EOS
|
onoe <<~EOS
|
||||||
#{message}
|
#{message}
|
||||||
@ -315,28 +318,9 @@ module Homebrew
|
|||||||
|
|
||||||
f.print_tap_action
|
f.print_tap_action
|
||||||
|
|
||||||
if f.linked? && f.outdated? && !f.head? && !Homebrew::EnvConfig.no_install_upgrade?
|
upgrade = f.linked? && f.outdated? && !f.head? && !Homebrew::EnvConfig.no_install_upgrade?
|
||||||
puts "#{f.full_name} #{f.linked_version} is installed but outdated"
|
|
||||||
kegs = Upgrade.outdated_kegs(f)
|
|
||||||
linked_kegs = kegs.select(&:linked?)
|
|
||||||
Upgrade.print_upgrade_message(f, formula_installer.options)
|
|
||||||
end
|
|
||||||
|
|
||||||
kegs.each(&:unlink) if kegs.present?
|
Upgrade.install_formula(formula_installer, upgrade: upgrade)
|
||||||
|
|
||||||
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.
|
|
||||||
nil
|
|
||||||
ensure
|
|
||||||
# Re-link kegs if upgrade fails
|
|
||||||
begin
|
|
||||||
linked_kegs.each(&:link) if linked_kegs.present? && !f.latest_version_installed?
|
|
||||||
rescue
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
private_class_method :install_formula
|
private_class_method :install_formula
|
||||||
end
|
end
|
||||||
|
|||||||
@ -164,9 +164,6 @@ module Homebrew
|
|||||||
def upgrade_formula(formula_installer, dry_run: false, verbose: false)
|
def upgrade_formula(formula_installer, dry_run: false, verbose: false)
|
||||||
formula = formula_installer.formula
|
formula = formula_installer.formula
|
||||||
|
|
||||||
kegs = outdated_kegs(formula)
|
|
||||||
linked_kegs = kegs.select(&:linked?)
|
|
||||||
|
|
||||||
if dry_run
|
if dry_run
|
||||||
print_dry_run_dependencies(formula, formula_installer.compute_dependencies)
|
print_dry_run_dependencies(formula, formula_installer.compute_dependencies)
|
||||||
return
|
return
|
||||||
@ -174,12 +171,28 @@ module Homebrew
|
|||||||
|
|
||||||
formula_installer.check_installation_already_attempted
|
formula_installer.check_installation_already_attempted
|
||||||
|
|
||||||
print_upgrade_message(formula, formula_installer.options)
|
install_formula(formula_installer, upgrade: true)
|
||||||
|
rescue BuildError => e
|
||||||
|
e.dump(verbose: verbose)
|
||||||
|
puts
|
||||||
|
Homebrew.failed = true
|
||||||
|
end
|
||||||
|
private_class_method :upgrade_formula
|
||||||
|
|
||||||
|
def install_formula(formula_installer, upgrade:)
|
||||||
|
formula = formula_installer.formula
|
||||||
|
|
||||||
|
if upgrade
|
||||||
|
print_upgrade_message(formula, formula_installer.options)
|
||||||
|
|
||||||
|
kegs = outdated_kegs(formula)
|
||||||
|
linked_kegs = kegs.select(&:linked?)
|
||||||
|
end
|
||||||
|
|
||||||
# first we unlink the currently active keg for this formula otherwise it is
|
# first we unlink the currently active keg for this formula otherwise it is
|
||||||
# possible for the existing build to interfere with the build we are about to
|
# possible for the existing build to interfere with the build we are about to
|
||||||
# do! Seriously, it happens!
|
# do! Seriously, it happens!
|
||||||
kegs.each(&:unlink)
|
kegs.each(&:unlink) if kegs.present?
|
||||||
|
|
||||||
formula_installer.install
|
formula_installer.install
|
||||||
formula_installer.finish
|
formula_installer.finish
|
||||||
@ -187,19 +200,14 @@ 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 BuildError => e
|
|
||||||
e.dump(verbose: verbose)
|
|
||||||
puts
|
|
||||||
Homebrew.failed = true
|
|
||||||
ensure
|
ensure
|
||||||
# restore previous installation state if build failed
|
# restore previous installation state if build failed
|
||||||
begin
|
begin
|
||||||
linked_kegs.each(&:link) unless formula.latest_version_installed?
|
linked_kegs.each(&:link) if linked_kegs.present? && !f.latest_version_installed?
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private_class_method :upgrade_formula
|
|
||||||
|
|
||||||
def check_broken_dependents(installed_formulae)
|
def check_broken_dependents(installed_formulae)
|
||||||
CacheStoreDatabase.use(:linkage) do |db|
|
CacheStoreDatabase.use(:linkage) do |db|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user