
Consequence: you can no longer install when something is already installed, you must upgrade it. This doesn't apply if the formula in question was unlinked. You can still --force installs though. Rationale: the old way of installing over the top would leave symlinks to multiple versions in /usr/local if the old version had a file the newer version didn't. The new upgrade command handles everything properly.
36 lines
886 B
Ruby
36 lines
886 B
Ruby
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
|
|
ARGV.formulae.map{ |f| [f.prefix.parent, f.name, f.version] }
|
|
end
|
|
|
|
if outdated.count > 1
|
|
oh1 "Upgrading #{outdated.count} outdated package#{outdated.count.plural_s}, with result:"
|
|
puts outdated.map{ |_, name, version| "#{name} #{version}" } * ", "
|
|
end
|
|
|
|
outdated.each do |rack, name, version|
|
|
installer = FormulaInstaller.new(Formula.factory(name))
|
|
installer.show_header = false
|
|
oh1 "Upgrading #{name}"
|
|
installer.install
|
|
Keg.new("#{rack}/#{version}").unlink
|
|
installer.caveats
|
|
installer.finish # includes link step
|
|
end
|
|
end
|
|
end
|