diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index a3d7b64527f7d3e30013b24ced6700ec9d32561f..d1a50e88730f3773bdd5564d69f821fc57ae6854 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -36,14 +36,9 @@ module Homebrew extend self end unless ARGV.force? perform_preinstall_checks + begin - ARGV.formulae.each do |f| - begin - install_formula(f) - rescue CannotInstallFormulaError => e - ofail e.message - end - end + ARGV.formulae.each { |f| install_formula(f) } rescue FormulaUnavailableError => e ofail e.message require 'cmd/search' @@ -124,6 +119,7 @@ module Homebrew extend self # another formula. In that case, don't generate an error, just move on. rescue FormulaAlreadyInstalledError => e opoo e.message - # Ignore CannotInstallFormulaError and let caller handle it. + rescue CannotInstallFormulaError => e + ofail e.message end end diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index 53f7f193016157c989e116bbc6af27ea4b14c3e7..393662b0cd9adf9575a82efe784d49e6490d9ed2 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