aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorilovezfs2017-03-17 08:31:49 -0700
committerilovezfs2017-03-17 12:39:43 -0700
commit52d1d2cc3f420b356157aad5f91bb5149862110d (patch)
tree8249ba36183307da1e654c7f9ffec7d159a3b941 /Library
parentff77013f48f8d3c7836c193163203b89af9cdabe (diff)
downloadbrew-52d1d2cc3f420b356157aad5f91bb5149862110d.tar.bz2
upgrade: keg_only before non-keg_only formulae
Avoids unnecessary conflicts when a previously non-keg_only formula is in the way by prioritizing keg_only before non-keg_only formulae. This change is motivated by the upgrade of gnupg 2.0 to 2.1, since the latter no longer depends on the gpg-agent formula, which, even if made keg_only, still causes the link step to fail for 2.1, as gpg-agent's non-keg version won't have been upgraded to the keg_only version at that point (alphabetically gnupg precedes gpg-agent).
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/upgrade.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb
index cea77ad29..ed36b8f33 100644
--- a/Library/Homebrew/cmd/upgrade.rb
+++ b/Library/Homebrew/cmd/upgrade.rb
@@ -75,6 +75,18 @@ module Homebrew
puts pinned.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", "
end
+ # Sort keg_only before non-keg_only formulae to avoid any needless conflicts
+ # with outdated, non-keg_only versions of formulae being upgraded.
+ formulae_to_install.sort! do |a, b|
+ if !a.keg_only? && b.keg_only?
+ 1
+ elsif a.keg_only? && !b.keg_only?
+ -1
+ else
+ 0
+ end
+ end
+
formulae_to_install.each do |f|
upgrade_formula(f)
next unless ARGV.include?("--cleanup")