2020-10-10 14:16:11 +02:00
|
|
|
# typed: false
|
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"
|
2020-07-25 21:33:48 +02:00
|
|
|
require "install"
|
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"
|
2020-06-30 13:22:21 -04:00
|
|
|
require "cask/cmd"
|
|
|
|
require "cask/utils"
|
|
|
|
require "cask/macos"
|
2020-07-02 12:53:52 +01:00
|
|
|
require "upgrade"
|
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
|
2020-09-28 01:33:29 +02:00
|
|
|
`reinstall` [<options>] <formula>|<cask>
|
2018-11-07 22:17:36 +05:30
|
|
|
|
2020-09-28 01:33:29 +02:00
|
|
|
Uninstall and then reinstall a <formula> or <cask> using the same options it was
|
|
|
|
originally installed with, plus any appended options specific to a <formula>.
|
2019-02-03 09:34:00 +01:00
|
|
|
|
2019-08-20 00:04:14 -04:00
|
|
|
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
|
2019-08-06 13:23:19 -04:00
|
|
|
reinstalled formulae or, every 30 days, for all formulae.
|
2018-11-07 22:17:36 +05:30
|
|
|
EOS
|
2020-07-30 18:40:10 +02:00
|
|
|
switch "-d", "--debug",
|
2020-10-08 11:18:24 +02:00
|
|
|
description: "If brewing fails, open an interactive debugging session with access to IRB " \
|
2019-08-06 14:22:24 -04:00
|
|
|
"or a shell inside the temporary build directory."
|
2020-07-27 03:59:52 +02:00
|
|
|
switch "-f", "--force",
|
2020-10-08 11:18:24 +02:00
|
|
|
description: "Install without checking for previously installed keg-only or " \
|
2019-04-30 08:44:35 +01:00
|
|
|
"non-migrated versions."
|
2020-07-30 18:40:10 +02:00
|
|
|
switch "-v", "--verbose",
|
2019-04-30 08:44:35 +01:00
|
|
|
description: "Print the verification and postinstall steps."
|
2020-10-08 11:18:24 +02:00
|
|
|
[
|
|
|
|
[:switch, "--formula", "--formulae", { description: "Treat all named arguments as formulae." }],
|
|
|
|
[:switch, "-s", "--build-from-source", {
|
|
|
|
description: "Compile <formula> from source even if a bottle is available.",
|
|
|
|
}],
|
|
|
|
[:switch, "-i", "--interactive", {
|
|
|
|
description: "Download and patch <formula>, then open a shell. This allows the user to " \
|
|
|
|
"run `./configure --help` and otherwise determine how to turn the software " \
|
|
|
|
"package into a Homebrew package.",
|
|
|
|
}],
|
|
|
|
[:switch, "--force-bottle", {
|
|
|
|
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.",
|
|
|
|
}],
|
|
|
|
[:switch, "--keep-tmp", {
|
|
|
|
description: "Retain the temporary files created during installation.",
|
|
|
|
}],
|
|
|
|
[:switch, "--display-times", {
|
|
|
|
env: :display_install_times,
|
|
|
|
description: "Print install times for each formula at the end of the run.",
|
|
|
|
}],
|
|
|
|
].each do |options|
|
2020-09-28 02:10:17 +02:00
|
|
|
send(*options)
|
|
|
|
conflicts "--cask", options[-2]
|
|
|
|
end
|
2020-10-03 02:45:32 +02:00
|
|
|
formula_options
|
2020-10-08 11:18:24 +02:00
|
|
|
[
|
|
|
|
[:switch, "--cask", "--casks", { description: "Treat all named arguments as casks." }],
|
|
|
|
*Cask::Cmd::AbstractCommand::OPTIONS,
|
|
|
|
*Cask::Cmd::Install::OPTIONS,
|
|
|
|
].each do |options|
|
2020-09-28 02:10:17 +02:00
|
|
|
send(*options)
|
|
|
|
conflicts "--formula", options[-2]
|
|
|
|
end
|
2020-10-03 02:45:32 +02:00
|
|
|
cask_options
|
2020-09-28 02:10:17 +02:00
|
|
|
|
2020-10-08 11:18:24 +02:00
|
|
|
conflicts "--build-from-source", "--force-bottle"
|
|
|
|
|
2020-10-08 11:12:17 +02:00
|
|
|
min_named :formula_or_cask
|
2018-11-07 22:17:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-17 13:23:41 +00:00
|
|
|
def reinstall
|
2020-07-25 03:48:33 +02:00
|
|
|
args = reinstall_args.parse
|
2018-11-07 22:17:36 +05:30
|
|
|
|
2020-07-28 12:55:46 +02:00
|
|
|
FormulaInstaller.prevent_build_flags(args)
|
2015-06-29 14:09:57 -04:00
|
|
|
|
2020-07-27 11:37:07 +02:00
|
|
|
Install.perform_preinstall_checks
|
2018-09-06 18:38:43 +01:00
|
|
|
|
2020-09-28 02:10:17 +02:00
|
|
|
only = :cask if args.cask? && !args.formula?
|
|
|
|
only = :formula if !args.cask? && args.formula?
|
|
|
|
|
|
|
|
formulae, casks = args.named.to_formulae_and_casks(only: only, method: :resolve)
|
|
|
|
.partition { |o| o.is_a?(Formula) }
|
|
|
|
|
|
|
|
formulae.each do |f|
|
2016-09-05 22:40:08 +03:00
|
|
|
if f.pinned?
|
|
|
|
onoe "#{f.full_name} is pinned. You must unpin it to reinstall."
|
|
|
|
next
|
|
|
|
end
|
2020-07-25 21:33:48 +02:00
|
|
|
Migrator.migrate_if_needed(f, force: args.force?)
|
2020-07-25 03:48:33 +02:00
|
|
|
reinstall_formula(f, args: args)
|
2019-01-03 16:23:44 +00:00
|
|
|
Cleanup.install_formula_clean!(f)
|
2016-09-05 22:40:08 +03:00
|
|
|
end
|
2020-07-02 12:53:52 +01:00
|
|
|
|
2020-08-24 00:37:22 +02:00
|
|
|
Upgrade.check_installed_dependents(args: args)
|
2020-07-02 12:53:52 +01:00
|
|
|
|
2020-09-28 02:10:17 +02:00
|
|
|
if casks.any?
|
|
|
|
Cask::Cmd::Reinstall.reinstall_casks(
|
|
|
|
*casks,
|
|
|
|
binaries: EnvConfig.cask_opts_binaries?,
|
|
|
|
verbose: args.verbose?,
|
|
|
|
force: args.force?,
|
|
|
|
require_sha: EnvConfig.cask_opts_require_sha?,
|
|
|
|
skip_cask_deps: args.skip_cask_deps?,
|
|
|
|
quarantine: EnvConfig.cask_opts_quarantine?,
|
|
|
|
)
|
|
|
|
end
|
2020-06-24 15:03:35 -04:00
|
|
|
|
2020-09-28 02:10:17 +02:00
|
|
|
Homebrew.messages.display_messages(display_times: args.display_times?)
|
2014-03-15 10:40:18 -05:00
|
|
|
end
|
2013-02-17 13:23:41 +00:00
|
|
|
end
|