diff options
| author | Max Howell | 2012-03-07 11:17:36 +0000 |
|---|---|---|
| committer | Max Howell | 2012-03-07 12:34:40 +0000 |
| commit | a13ff43886f5255694ead2789a65bda3b97dd6b9 (patch) | |
| tree | 2fa24b98b866cfb81cbb2016122aedadbcf078e1 /Library/Homebrew/cmd | |
| parent | 76aa0a62f3ef3bbb31c2688037e3932b80aff7f9 (diff) | |
| download | brew-a13ff43886f5255694ead2789a65bda3b97dd6b9.tar.bz2 | |
Don't abort upgrade if one formula won't build
Also, unlink previous keg before installing to prevent issues when existing installed brews cause build problems for the newer installed brew.
If the build fails the active keg is relinked before aborting.
Fixes #10341.
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/upgrade.rb | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 44a88529b..f27357764 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -14,9 +14,12 @@ module Homebrew extend self outdated = if ARGV.named.empty? Homebrew.outdated_brews else - ARGV.formulae.each do |f| - raise "#{f} already upgraded" if f.installed? - raise "#{f} not installed" unless f.rack.exist? and not f.rack.children.empty? + ARGV.formulae.select do |f| + unless f.rack.exist? and not f.rack.children.empty? + onoe "#{f} not installed" + else + true + end end end @@ -35,13 +38,34 @@ module Homebrew extend self end outdated.each do |f| - installer = FormulaInstaller.new f - installer.show_header = false - oh1 "Upgrading #{f.name}" - installer.install - Keg.new(f.linked_keg.realpath).unlink if f.linked_keg.directory? - installer.caveats - installer.finish # includes link step + upgrade_formula f end end + + def upgrade_formula f + outdated_keg = Keg.new(f.linked_keg.realpath) rescue nil + + installer = FormulaInstaller.new f + installer.show_header = false + + oh1 "Upgrading #{f.name}" + + # 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 + # do! Seriously, it happens! + outdated_keg.unlink if outdated_keg + + installer.install + installer.caveats + installer.finish # includes link step + rescue CannotInstallFormulaError => e + onoe e + rescue BuildError => e + e.dump + puts + ensure + # restore previous installation state if build failed + outdated_keg.link if outdated_keg and not f.linked_keg.directory? + end + end |
