Upgrade outdated formulae with brew install
This commit is contained in:
parent
76cda750d5
commit
56e6710064
@ -396,6 +396,20 @@ module Homebrew
|
|||||||
f.print_tap_action
|
f.print_tap_action
|
||||||
build_options = f.build
|
build_options = f.build
|
||||||
|
|
||||||
|
if f.outdated? && !f.head?
|
||||||
|
formulae = [f] + f.old_installed_formulae
|
||||||
|
version_upgrade = "#{f.linked_version} -> #{f.pkg_version}"
|
||||||
|
|
||||||
|
oh1 <<~EOS
|
||||||
|
#{f.name} #{f.linked_version} is installed and out of date
|
||||||
|
Upgrading #{Formatter.identifier(f.name)} #{version_upgrade}
|
||||||
|
EOS
|
||||||
|
outdated_kegs = formulae.map(&:linked_keg)
|
||||||
|
.select(&:directory?)
|
||||||
|
.map { |k| Keg.new(k.resolved_path) }
|
||||||
|
linked_kegs = outdated_kegs.select(&:linked?)
|
||||||
|
end
|
||||||
|
|
||||||
fi = FormulaInstaller.new(
|
fi = FormulaInstaller.new(
|
||||||
f,
|
f,
|
||||||
**{
|
**{
|
||||||
@ -419,6 +433,9 @@ module Homebrew
|
|||||||
)
|
)
|
||||||
fi.prelude
|
fi.prelude
|
||||||
fi.fetch
|
fi.fetch
|
||||||
|
|
||||||
|
outdated_kegs.each(&:unlink) if outdated_kegs.present?
|
||||||
|
|
||||||
fi.install
|
fi.install
|
||||||
fi.finish
|
fi.finish
|
||||||
rescue FormulaInstallationAlreadyAttemptedError
|
rescue FormulaInstallationAlreadyAttemptedError
|
||||||
@ -427,5 +444,12 @@ module Homebrew
|
|||||||
nil
|
nil
|
||||||
rescue CannotInstallFormulaError => e
|
rescue CannotInstallFormulaError => e
|
||||||
ofail e.message
|
ofail e.message
|
||||||
|
ensure
|
||||||
|
begin
|
||||||
|
# Re-link kegs if upgrade fails
|
||||||
|
linked_kegs.each(&:link) unless formula.latest_version_installed?
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -351,12 +351,7 @@ class FormulaInstaller
|
|||||||
message = <<~EOS
|
message = <<~EOS
|
||||||
#{formula.name} #{formula.linked_version} is already installed
|
#{formula.name} #{formula.linked_version} is already installed
|
||||||
EOS
|
EOS
|
||||||
if formula.outdated? && !formula.head?
|
if only_deps?
|
||||||
message += <<~EOS
|
|
||||||
To upgrade to #{formula.pkg_version}, run:
|
|
||||||
brew upgrade #{formula.full_name}
|
|
||||||
EOS
|
|
||||||
elsif only_deps?
|
|
||||||
message = nil
|
message = nil
|
||||||
else
|
else
|
||||||
# some other version is already installed *and* linked
|
# some other version is already installed *and* linked
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user