2011-08-23 23:30:52 +01:00
|
|
|
require 'cmd/outdated'
|
|
|
|
require 'cmd/install'
|
|
|
|
|
|
|
|
class Fixnum
|
|
|
|
def plural_s
|
|
|
|
if self > 1 then "s" else "" end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module Homebrew extend self
|
|
|
|
def upgrade
|
|
|
|
Homebrew.perform_preinstall_checks
|
|
|
|
|
|
|
|
outdated = if ARGV.named.empty?
|
|
|
|
Homebrew.outdated_brews
|
|
|
|
else
|
2011-09-11 13:06:05 -07:00
|
|
|
ARGV.formulae.each do |f|
|
2011-09-02 09:55:37 +01:00
|
|
|
raise "#{f} already upgraded" if f.installed?
|
|
|
|
raise "#{f} not installed" unless f.rack.exist? and not f.rack.children.empty?
|
|
|
|
end
|
2011-08-23 23:30:52 +01:00
|
|
|
end
|
|
|
|
|
2011-08-24 17:33:28 -07:00
|
|
|
if outdated.length > 1
|
2011-08-25 18:02:36 -07:00
|
|
|
oh1 "Upgrading #{outdated.length} outdated package#{outdated.length.plural_s}, with result:"
|
2011-09-11 13:06:05 -07:00
|
|
|
puts outdated.map{ |f| "#{f.name} #{f.version}" } * ", "
|
2011-08-23 23:30:52 +01:00
|
|
|
end
|
|
|
|
|
2011-09-11 13:06:05 -07:00
|
|
|
outdated.each do |f|
|
|
|
|
installer = FormulaInstaller.new f
|
2011-08-23 23:30:52 +01:00
|
|
|
installer.show_header = false
|
2011-09-11 13:06:05 -07:00
|
|
|
oh1 "Upgrading #{f.name}"
|
2011-08-23 23:30:52 +01:00
|
|
|
installer.install
|
2011-09-11 13:06:05 -07:00
|
|
|
Keg.new("#{f.rack}/#{f.version}").unlink
|
2011-08-23 23:30:52 +01:00
|
|
|
installer.caveats
|
|
|
|
installer.finish # includes link step
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|