2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-10-31 20:10:08 -05:00
|
|
|
require "formula_installer"
|
2016-07-29 20:31:32 -06:00
|
|
|
require "development_tools"
|
2018-06-20 02:10:54 -04:00
|
|
|
require "messages"
|
2018-09-12 19:28:02 +00:00
|
|
|
require "reinstall"
|
2019-04-17 18:25:08 +09:00
|
|
|
require "cli/parser"
|
2019-01-03 16:23:44 +00:00
|
|
|
require "cleanup"
|
2013-02-17 13:23:41 +00:00
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2016-09-26 01:44:51 +02:00
|
|
|
module_function
|
|
|
|
|
2018-11-07 22:17:36 +05:30
|
|
|
def reinstall_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
|
|
|
usage_banner <<~EOS
|
2019-01-29 19:25:13 +00:00
|
|
|
`reinstall` [<options>] <formula>
|
2018-11-07 22:17:36 +05:30
|
|
|
|
2019-01-29 19:25:13 +00:00
|
|
|
Uninstall and then install <formula> (with existing and any appended install options).
|
2019-02-03 09:34:00 +01:00
|
|
|
|
|
|
|
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will be run for the reinstalled formulae or, every 30 days, for all formulae.
|
2018-11-07 22:17:36 +05:30
|
|
|
EOS
|
2019-01-29 19:25:13 +00:00
|
|
|
switch :debug,
|
2019-04-30 08:44:35 +01:00
|
|
|
description: "If brewing fails, open an interactive debugging session with access to IRB "\
|
|
|
|
"or a shell inside the temporary build directory"
|
2018-11-24 15:36:59 +00:00
|
|
|
switch "-s", "--build-from-source",
|
2019-04-30 08:44:35 +01:00
|
|
|
description: "Compile <formula> from source even if a bottle is available."
|
2019-01-29 19:25:13 +00:00
|
|
|
switch "--force-bottle",
|
2019-04-30 08:44:35 +01:00
|
|
|
description: "Install from a bottle if it exists for the current or newest version of "\
|
|
|
|
"macOS, even if it would not normally be used for installation."
|
2019-01-29 19:25:13 +00:00
|
|
|
switch "--keep-tmp",
|
2019-04-30 08:44:35 +01:00
|
|
|
description: "Don't delete the temporary files created during installation."
|
2019-01-29 19:25:13 +00:00
|
|
|
switch :force,
|
2019-04-30 08:44:35 +01:00
|
|
|
description: "Install without checking for previously installed keg-only or "\
|
|
|
|
"non-migrated versions."
|
2019-01-29 19:25:13 +00:00
|
|
|
switch :verbose,
|
2019-04-30 08:44:35 +01:00
|
|
|
description: "Print the verification and postinstall steps."
|
2018-11-07 22:17:36 +05:30
|
|
|
switch "--display-times",
|
2019-07-28 11:12:32 +01:00
|
|
|
env: :display_install_times,
|
2019-04-30 08:44:35 +01:00
|
|
|
description: "Print install times for each formula at the end of the run."
|
2019-01-29 19:39:41 +00:00
|
|
|
conflicts "--build-from-source", "--force-bottle"
|
2019-01-29 19:25:13 +00:00
|
|
|
formula_options
|
2018-11-07 22:17:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-17 13:23:41 +00:00
|
|
|
def reinstall
|
2018-11-07 22:17:36 +05:30
|
|
|
reinstall_args.parse
|
|
|
|
|
2016-07-06 11:07:24 +01:00
|
|
|
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
|
2015-06-29 14:09:57 -04:00
|
|
|
|
2018-09-06 18:38:43 +01:00
|
|
|
Install.perform_preinstall_checks
|
|
|
|
|
2016-09-05 22:40:08 +03:00
|
|
|
ARGV.resolved_formulae.each do |f|
|
|
|
|
if f.pinned?
|
|
|
|
onoe "#{f.full_name} is pinned. You must unpin it to reinstall."
|
|
|
|
next
|
|
|
|
end
|
2017-03-29 11:25:27 +01:00
|
|
|
Migrator.migrate_if_needed(f)
|
2016-09-05 22:40:08 +03:00
|
|
|
reinstall_formula(f)
|
2019-01-03 16:23:44 +00:00
|
|
|
Cleanup.install_formula_clean!(f)
|
2016-09-05 22:40:08 +03:00
|
|
|
end
|
2018-06-20 02:10:54 -04:00
|
|
|
Homebrew.messages.display_messages
|
2014-03-15 10:40:18 -05:00
|
|
|
end
|
2013-02-17 13:23:41 +00:00
|
|
|
end
|