aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/reinstall.rb
diff options
context:
space:
mode:
authorJack Nagel2014-03-15 10:40:18 -0500
committerJack Nagel2014-03-15 10:53:03 -0500
commiteab90dcb567c552dbd1965383b2cd10035f7debd (patch)
tree80f42e220c8c2c7dfeaf19f014573025358fc150 /Library/Homebrew/cmd/reinstall.rb
parentd441d7b97fdb9c085f44989ea406ace486133490 (diff)
downloadbrew-eab90dcb567c552dbd1965383b2cd10035f7debd.tar.bz2
Rewrite `brew reinstall`
Fixes Homebrew/homebrew#23928.
Diffstat (limited to 'Library/Homebrew/cmd/reinstall.rb')
-rw-r--r--Library/Homebrew/cmd/reinstall.rb68
1 files changed, 36 insertions, 32 deletions
diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb
index 53f7f1930..393662b0c 100644
--- a/Library/Homebrew/cmd/reinstall.rb
+++ b/Library/Homebrew/cmd/reinstall.rb
@@ -2,39 +2,43 @@ require 'cmd/install'
module Homebrew extend self
def reinstall
- # At first save the named formulae and remove them from ARGV
- named = ARGV.named
- ARGV.delete_if { |arg| named.include? arg }
- clean_ARGV = ARGV.clone
-
- # Add the used_options for each named formula separately so
- # that the options apply to the right formula.
- named.each do |name|
- ARGV.replace(clean_ARGV)
- ARGV << name
- tab = Tab.for_name(name)
- tab.used_options.each { |option| ARGV << option.to_s }
- if tab.built_as_bottle and not tab.poured_from_bottle
- ARGV << '--build-bottle'
- end
-
- formula = Formulary.factory(name)
-
- begin
- oh1 "Reinstalling #{name} #{ARGV.options_only*' '}"
- opt_link = formula.opt_prefix
- if opt_link.exist?
- keg = Keg.new(opt_link.realpath)
- backup keg
- end
- self.install_formula formula
- rescue Exception
- ignore_interrupts { restore_backup(keg, formula) }
- raise
- else
- backup_path(keg).rmtree if backup_path(keg).exist?
- end
+ ARGV.formulae.each { |f| reinstall_formula(f) }
+ end
+
+ def reinstall_formula f
+ tab = Tab.for_formula(f)
+ options = tab.used_options | f.build.used_options
+
+ notice = "Reinstalling #{f.name}"
+ notice += " with #{options * ", "}" unless options.empty?
+ oh1 notice
+
+ if (opt_link = f.opt_prefix).exist?
+ keg = Keg.new(opt_link.realpath)
+ backup keg
end
+
+ fi = FormulaInstaller.new(f)
+ fi.options = options
+ fi.build_bottle = ARGV.build_bottle?
+ fi.build_bottle ||= tab.built_as_bottle && !tab.poured_from_bottle
+ fi.build_from_source = ARGV.build_from_source?
+ fi.force_bottle = ARGV.force_bottle?
+ fi.verbose = ARGV.verbose?
+ fi.debug = ARGV.debug?
+ fi.prelude
+ fi.install
+ fi.caveats
+ fi.finish
+ rescue FormulaInstallationAlreadyAttemptedError
+ # next
+ rescue FormulaAlreadyInstalledError => e
+ opoo e.message
+ rescue Exception
+ ignore_interrupts { restore_backup(keg, f) }
+ raise
+ else
+ backup_path(keg).rmtree if backup_path(keg).exist?
end
def backup keg