brew/Library/Homebrew/cmd/reinstall.rb
Mike McQuaid 8144667a71
Cleanup periodically if HOMEBREW_INSTALL_CLEANUP is set.
This will become the default in a later version of Homebrew but has an
opt-out through HOMEBREW_NO_INSTALL_CLEANUP.

Also, always cleanup files older than 120 days and set the general
default value for "old" logs, casks etc. to 30 days.
2019-01-03 16:23:44 +00:00

58 lines
1.7 KiB
Ruby

#: * `reinstall` [`--display-times`] <formula>:
#: Uninstall and then install <formula> (with existing install options).
#:
#: If `--display-times` is passed, install times for each formula are printed
#: at the end of the run.
#:
#: If `HOMEBREW_INSTALL_CLEANUP` is set then remove previously installed versions
#: of upgraded <formulae> as well as the HOMEBREW_CACHE for that formula.
require "formula_installer"
require "development_tools"
require "messages"
require "reinstall"
require "cli_parser"
require "cleanup"
module Homebrew
module_function
def reinstall_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`reinstall` [<option(s)>] <formula>:
Uninstall and then install <formula> (with existing install options).
If `HOMEBREW_INSTALL_CLEANUP` is set then remove previously installed versions
of upgraded <formulae> as well as the HOMEBREW_CACHE for that formula.
EOS
switch "-s", "--build-from-source",
description: "Compile the formula> from source even if a bottle is available."
switch "--display-times",
description: "Print install times for each formula at the end of the run."
switch :verbose
switch :debug
end
end
def reinstall
reinstall_args.parse
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
Install.perform_preinstall_checks
ARGV.resolved_formulae.each do |f|
if f.pinned?
onoe "#{f.full_name} is pinned. You must unpin it to reinstall."
next
end
Migrator.migrate_if_needed(f)
reinstall_formula(f)
Cleanup.install_formula_clean!(f)
end
Homebrew.messages.display_messages
end
end