2013-02-17 13:23:41 +00:00
|
|
|
require 'cmd/uninstall'
|
|
|
|
require 'cmd/install'
|
|
|
|
|
|
|
|
module Homebrew extend self
|
|
|
|
def reinstall
|
2013-07-23 10:55:07 +02:00
|
|
|
# At first save the named formulae and remove them from ARGV
|
|
|
|
named = ARGV.named
|
|
|
|
ARGV.delete_if { |arg| named.include? arg }
|
2013-08-21 20:18:55 +02:00
|
|
|
# We add --force because then uninstall always succeeds and so reinstall
|
|
|
|
# works for formulae not yet installed.
|
|
|
|
ARGV << "--force"
|
2013-07-23 10:55:07 +02:00
|
|
|
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 }
|
2013-09-01 13:54:21 +01:00
|
|
|
if tab.built_as_bottle and not tab.poured_from_bottle
|
|
|
|
ARGV << '--build-bottle'
|
|
|
|
end
|
2013-07-23 10:55:07 +02:00
|
|
|
# Todo: Be as smart as upgrade to restore the old state if reinstall fails.
|
|
|
|
self.uninstall
|
2013-09-01 13:54:33 +01:00
|
|
|
# Don't display --force in options; user didn't request it so a bit scary.
|
|
|
|
options_only = ARGV.options_only
|
|
|
|
options_only.delete "--force"
|
|
|
|
oh1 "Reinstalling #{name} #{options_only*' '}"
|
2013-07-23 10:55:07 +02:00
|
|
|
self.install
|
|
|
|
end
|
2013-02-17 13:23:41 +00:00
|
|
|
end
|
|
|
|
end
|