aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/help.rb2
-rw-r--r--Library/Homebrew/cmd/install.rb26
-rw-r--r--Library/Homebrew/cmd/upgrade.rb35
3 files changed, 51 insertions, 12 deletions
diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb
index 3e7cc75b9..2d55d0427 100644
--- a/Library/Homebrew/cmd/help.rb
+++ b/Library/Homebrew/cmd/help.rb
@@ -5,7 +5,7 @@ Example usage:
brew search [foo]
brew list [FORMULA...]
brew update
- brew outdated
+ brew upgrade [FORMULA...]
brew [info | home] [FORMULA...]
Troubleshooting:
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index b7f9e7cae..4b2711994 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -57,22 +57,26 @@ module Homebrew extend self
end
end
- def install_formulae formulae
- formulae = [formulae].flatten.compact
- return if formulae.empty?
-
+ def perform_preinstall_checks
check_ppc
check_writable_install_location
check_cc
check_macports
+ end
- formulae.each do |f|
- begin
- installer = FormulaInstaller.new f
- installer.ignore_deps = ARGV.include? '--ignore-dependencies'
- installer.go
- rescue FormulaAlreadyInstalledError => e
- opoo e.message
+ def install_formulae formulae
+ formulae = [formulae].flatten.compact
+ unless formulae.empty?
+ perform_preinstall_checks
+ formulae.each do |f|
+ begin
+ fi = FormulaInstaller.new(f)
+ fi.install
+ fi.caveats
+ fi.finish
+ rescue FormulaAlreadyInstalledError => e
+ opoo e.message
+ end
end
end
end
diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb
new file mode 100644
index 000000000..f86e8a871
--- /dev/null
+++ b/Library/Homebrew/cmd/upgrade.rb
@@ -0,0 +1,35 @@
+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