2020-12-01 08:59:59 +02:00
|
|
|
#![allow(clippy::cognitive_complexity)]
|
2021-12-18 20:39:57 +02:00
|
|
|
|
|
|
|
|
use std::env;
|
|
|
|
|
use std::io;
|
2023-05-01 00:02:13 +05:30
|
|
|
use std::path::PathBuf;
|
2021-12-18 20:39:57 +02:00
|
|
|
use std::process::exit;
|
2023-01-29 19:19:27 +00:00
|
|
|
use std::time::Duration;
|
2021-12-18 20:39:57 +02:00
|
|
|
|
2024-01-23 14:50:35 +08:00
|
|
|
use crate::breaking_changes::{first_run_of_major_release, print_breaking_changes, should_skip, write_keep_file};
|
2022-11-26 20:42:35 +01:00
|
|
|
use clap::CommandFactory;
|
2022-04-23 12:35:06 +02:00
|
|
|
use clap::{crate_version, Parser};
|
2022-11-11 09:39:29 -05:00
|
|
|
use color_eyre::eyre::Context;
|
2023-05-01 00:02:13 +05:30
|
|
|
use color_eyre::eyre::Result;
|
2021-12-18 20:39:57 +02:00
|
|
|
use console::Key;
|
2023-12-03 09:52:35 +08:00
|
|
|
use etcetera::base_strategy::BaseStrategy;
|
2023-05-01 00:02:13 +05:30
|
|
|
#[cfg(windows)]
|
|
|
|
|
use etcetera::base_strategy::Windows;
|
2023-12-03 09:52:35 +08:00
|
|
|
#[cfg(unix)]
|
|
|
|
|
use etcetera::base_strategy::Xdg;
|
2023-05-01 00:02:13 +05:30
|
|
|
use once_cell::sync::Lazy;
|
2024-10-03 12:47:35 +02:00
|
|
|
use rust_i18n::{i18n, t};
|
2022-11-16 13:43:57 -05:00
|
|
|
use tracing::debug;
|
2021-12-18 20:39:57 +02:00
|
|
|
|
|
|
|
|
use self::config::{CommandLineArgs, Config, Step};
|
|
|
|
|
use self::error::StepFailed;
|
|
|
|
|
#[cfg(all(windows, feature = "self-update"))]
|
|
|
|
|
use self::error::Upgraded;
|
2025-02-02 19:24:57 -08:00
|
|
|
#[allow(clippy::wildcard_imports)]
|
2021-12-18 20:39:57 +02:00
|
|
|
use self::steps::{remote::*, *};
|
2025-02-02 19:24:57 -08:00
|
|
|
#[allow(clippy::wildcard_imports)]
|
2021-12-18 20:39:57 +02:00
|
|
|
use self::terminal::*;
|
|
|
|
|
|
2024-04-08 13:43:32 +02:00
|
|
|
use self::utils::{hostname, install_color_eyre, install_tracing, update_tracing};
|
2023-10-17 11:19:47 +08:00
|
|
|
|
2023-12-03 09:52:35 +08:00
|
|
|
mod breaking_changes;
|
2022-11-08 05:54:35 -05:00
|
|
|
mod command;
|
2018-06-28 12:16:54 +03:00
|
|
|
mod config;
|
2018-10-17 14:07:58 +03:00
|
|
|
mod ctrlc;
|
2018-12-11 16:43:26 +02:00
|
|
|
mod error;
|
2020-02-08 22:13:56 +02:00
|
|
|
mod execution_context;
|
2018-08-26 16:12:59 +03:00
|
|
|
mod executor;
|
2018-06-03 18:04:58 +03:00
|
|
|
mod report;
|
2020-02-09 13:41:55 +02:00
|
|
|
mod runner;
|
2020-07-01 21:03:19 +03:00
|
|
|
#[cfg(windows)]
|
|
|
|
|
mod self_renamer;
|
2018-11-26 14:27:19 +02:00
|
|
|
#[cfg(feature = "self-update")]
|
|
|
|
|
mod self_update;
|
2018-12-15 21:52:21 +02:00
|
|
|
mod steps;
|
2022-11-24 14:15:43 -05:00
|
|
|
mod sudo;
|
2018-05-31 16:00:01 +03:00
|
|
|
mod terminal;
|
2018-06-17 11:43:25 +03:00
|
|
|
mod utils;
|
2018-05-30 07:53:19 +03:00
|
|
|
|
2023-12-03 09:52:35 +08:00
|
|
|
pub(crate) static HOME_DIR: Lazy<PathBuf> = Lazy::new(|| home::home_dir().expect("No home directory"));
|
|
|
|
|
#[cfg(unix)]
|
|
|
|
|
pub(crate) static XDG_DIRS: Lazy<Xdg> = Lazy::new(|| Xdg::new().expect("No home directory"));
|
2024-03-09 17:57:33 +08:00
|
|
|
|
2023-05-01 00:02:13 +05:30
|
|
|
#[cfg(windows)]
|
2023-12-03 09:52:35 +08:00
|
|
|
pub(crate) static WINDOWS_DIRS: Lazy<Windows> = Lazy::new(|| Windows::new().expect("No home directory"));
|
2023-05-01 00:02:13 +05:30
|
|
|
|
2024-10-03 12:47:35 +02:00
|
|
|
// Init and load the i18n files
|
|
|
|
|
i18n!("locales", fallback = "en");
|
|
|
|
|
|
2025-02-02 19:24:57 -08:00
|
|
|
#[allow(clippy::too_many_lines)]
|
2019-12-11 23:05:38 +02:00
|
|
|
fn run() -> Result<()> {
|
2023-09-18 21:09:58 -04:00
|
|
|
install_color_eyre()?;
|
2018-10-17 14:07:58 +03:00
|
|
|
ctrlc::set_handler();
|
|
|
|
|
|
2022-04-23 12:35:06 +02:00
|
|
|
let opt = CommandLineArgs::parse();
|
2023-10-17 11:19:47 +08:00
|
|
|
// Set up the logger with the filter directives from:
|
|
|
|
|
// 1. CLI option `--log-filter`
|
|
|
|
|
// 2. `debug` if the `--verbose` option is present
|
|
|
|
|
// We do this because we need our logger to work while loading the
|
|
|
|
|
// configuration file.
|
|
|
|
|
//
|
|
|
|
|
// When the configuration file is loaded, update the logger with the full
|
|
|
|
|
// filter directives.
|
|
|
|
|
//
|
|
|
|
|
// For more info, see the comments in `CommandLineArgs::tracing_filter_directives()`
|
|
|
|
|
// and `Config::tracing_filter_directives()`.
|
|
|
|
|
let reload_handle = install_tracing(&opt.tracing_filter_directives())?;
|
2022-05-07 08:11:53 +03:00
|
|
|
|
2024-10-03 12:47:35 +02:00
|
|
|
// Get current system locale and set it as the default locale
|
|
|
|
|
let system_locale = sys_locale::get_locale().unwrap_or("en".to_string());
|
|
|
|
|
rust_i18n::set_locale(&system_locale);
|
|
|
|
|
debug!("Current system locale is {system_locale}");
|
|
|
|
|
|
2022-11-26 20:42:35 +01:00
|
|
|
if let Some(shell) = opt.gen_completion {
|
|
|
|
|
let cmd = &mut CommandLineArgs::command();
|
2023-05-27 17:41:42 +08:00
|
|
|
clap_complete::generate(shell, cmd, clap::crate_name!(), &mut io::stdout());
|
2022-11-26 20:42:35 +01:00
|
|
|
return Ok(());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if opt.gen_manpage {
|
|
|
|
|
let man = clap_mangen::Man::new(CommandLineArgs::command());
|
2023-05-27 17:41:42 +08:00
|
|
|
man.render(&mut io::stdout())?;
|
2022-11-26 20:42:35 +01:00
|
|
|
return Ok(());
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-07 08:11:53 +03:00
|
|
|
for env in opt.env_variables() {
|
|
|
|
|
let mut splitted = env.split('=');
|
|
|
|
|
let var = splitted.next().unwrap();
|
|
|
|
|
let value = splitted.next().unwrap();
|
|
|
|
|
env::set_var(var, value);
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-04 22:55:06 +02:00
|
|
|
if opt.edit_config() {
|
2023-05-01 00:02:13 +05:30
|
|
|
Config::edit()?;
|
2019-08-22 22:29:31 +03:00
|
|
|
return Ok(());
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-30 10:01:22 +03:00
|
|
|
if opt.show_config_reference() {
|
2023-05-27 17:41:42 +08:00
|
|
|
print!("{}", config::EXAMPLE_CONFIG);
|
2020-06-30 10:01:22 +03:00
|
|
|
return Ok(());
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-01 00:02:13 +05:30
|
|
|
let config = Config::load(opt)?;
|
2023-10-17 11:19:47 +08:00
|
|
|
// Update the logger with the full filter directives.
|
|
|
|
|
update_tracing(&reload_handle, &config.tracing_filter_directives())?;
|
2023-05-27 17:41:42 +08:00
|
|
|
set_title(config.set_title());
|
|
|
|
|
display_time(config.display_time());
|
|
|
|
|
set_desktop_notifications(config.notify_each_step());
|
2019-11-04 22:55:06 +02:00
|
|
|
|
2020-02-26 12:27:58 +02:00
|
|
|
debug!("Version: {}", crate_version!());
|
|
|
|
|
debug!("OS: {}", env!("TARGET"));
|
|
|
|
|
debug!("{:?}", std::env::args());
|
|
|
|
|
debug!("Binary path: {:?}", std::env::current_exe());
|
2023-10-18 12:19:53 +08:00
|
|
|
debug!("self-update Feature Enabled: {:?}", cfg!(feature = "self-update"));
|
2023-10-17 11:19:47 +08:00
|
|
|
debug!("Configuration: {:?}", config);
|
2020-02-26 12:27:58 +02:00
|
|
|
|
2019-06-13 09:21:39 +03:00
|
|
|
if config.run_in_tmux() && env::var("TOPGRADE_INSIDE_TMUX").is_err() {
|
2018-06-27 23:04:39 +03:00
|
|
|
#[cfg(unix)]
|
|
|
|
|
{
|
2024-09-17 20:06:39 +07:00
|
|
|
tmux::run_in_tmux(config.tmux_config()?)?;
|
2022-11-15 10:30:26 -05:00
|
|
|
return Ok(());
|
2018-06-20 21:05:49 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-03 04:20:42 +08:00
|
|
|
let powershell = powershell::Powershell::new();
|
|
|
|
|
let should_run_powershell = powershell.profile().is_some() && config.should_run(Step::Powershell);
|
|
|
|
|
let emacs = emacs::Emacs::new();
|
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
|
let distribution = linux::Distribution::detect();
|
2018-11-07 14:31:44 +02:00
|
|
|
|
2023-03-13 19:23:37 +00:00
|
|
|
let sudo = config.sudo_command().map_or_else(sudo::Sudo::detect, sudo::Sudo::new);
|
2019-01-22 22:37:32 +02:00
|
|
|
let run_type = executor::RunType::new(config.dry_run());
|
2024-03-09 17:57:33 +08:00
|
|
|
let ctx = execution_context::ExecutionContext::new(run_type, sudo, &config);
|
2020-02-09 13:41:55 +02:00
|
|
|
let mut runner = runner::Runner::new(&ctx);
|
|
|
|
|
|
2024-01-23 14:50:35 +08:00
|
|
|
// If
|
|
|
|
|
//
|
|
|
|
|
// 1. the breaking changes notification shouldnot be skipped
|
|
|
|
|
// 2. this is the first execution of a major release
|
|
|
|
|
//
|
|
|
|
|
// inform user of breaking changes
|
|
|
|
|
if !should_skip() && first_run_of_major_release()? {
|
2023-12-03 09:52:35 +08:00
|
|
|
print_breaking_changes();
|
|
|
|
|
|
|
|
|
|
if prompt_yesno("Confirmed?")? {
|
|
|
|
|
write_keep_file()?;
|
|
|
|
|
} else {
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-18 12:19:53 +08:00
|
|
|
// Self-Update step, this will execute only if:
|
|
|
|
|
// 1. the `self-update` feature is enabled
|
|
|
|
|
// 2. it is not disabled from configuration (env var/CLI opt/file)
|
2018-11-12 21:27:49 +02:00
|
|
|
#[cfg(feature = "self-update")]
|
|
|
|
|
{
|
2023-10-18 12:19:53 +08:00
|
|
|
let should_self_update = env::var("TOPGRADE_NO_SELF_UPGRADE").is_err() && !config.no_self_update();
|
|
|
|
|
|
|
|
|
|
if should_self_update {
|
|
|
|
|
runner.execute(Step::SelfUpdate, "Self Update", || self_update::self_update(&ctx))?;
|
2018-11-12 21:27:49 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-11-07 14:31:44 +02:00
|
|
|
|
2020-07-01 21:03:19 +03:00
|
|
|
#[cfg(windows)]
|
|
|
|
|
let _self_rename = if config.self_rename() {
|
|
|
|
|
Some(crate::self_renamer::SelfRenamer::create()?)
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-20 20:26:08 +03:00
|
|
|
if let Some(commands) = config.pre_commands() {
|
|
|
|
|
for (name, command) in commands {
|
2021-09-02 06:18:01 +03:00
|
|
|
generic::run_custom_command(name, command, &ctx)?;
|
2018-06-20 20:26:08 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 14:15:43 -05:00
|
|
|
if config.pre_sudo() {
|
2022-11-25 17:19:32 -05:00
|
|
|
if let Some(sudo) = ctx.sudo() {
|
|
|
|
|
sudo.elevate(&ctx)?;
|
|
|
|
|
}
|
2022-11-24 14:15:43 -05:00
|
|
|
}
|
|
|
|
|
|
2023-06-03 04:20:42 +08:00
|
|
|
if let Some(topgrades) = config.remote_topgrades() {
|
2024-04-08 13:43:32 +02:00
|
|
|
for remote_topgrade in topgrades.iter().filter(|t| config.should_execute_remote(hostname(), t)) {
|
2023-06-03 04:20:42 +08:00
|
|
|
runner.execute(Step::Remotes, format!("Remote ({remote_topgrade})"), || {
|
|
|
|
|
ssh::ssh_step(&ctx, remote_topgrade)
|
|
|
|
|
})?;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-27 09:47:20 +02:00
|
|
|
|
2019-06-04 09:35:29 +03:00
|
|
|
#[cfg(windows)]
|
2023-05-27 17:37:51 +08:00
|
|
|
{
|
|
|
|
|
runner.execute(Step::Wsl, "WSL", || windows::run_wsl_topgrade(&ctx))?;
|
|
|
|
|
runner.execute(Step::WslUpdate, "WSL", || windows::update_wsl(&ctx))?;
|
|
|
|
|
runner.execute(Step::Chocolatey, "Chocolatey", || windows::run_chocolatey(&ctx))?;
|
2023-06-03 04:20:42 +08:00
|
|
|
runner.execute(Step::Scoop, "Scoop", || windows::run_scoop(&ctx))?;
|
2023-05-27 17:37:51 +08:00
|
|
|
runner.execute(Step::Winget, "Winget", || windows::run_winget(&ctx))?;
|
|
|
|
|
runner.execute(Step::System, "Windows update", || windows::windows_update(&ctx))?;
|
2024-10-23 02:15:46 +02:00
|
|
|
runner.execute(Step::MicrosoftStore, "Microsoft Store", || {
|
|
|
|
|
windows::microsoft_store(&ctx)
|
|
|
|
|
})?;
|
2023-05-27 17:37:51 +08:00
|
|
|
}
|
2023-01-29 19:19:27 +00:00
|
|
|
|
2018-10-02 10:46:38 +03:00
|
|
|
#[cfg(target_os = "linux")]
|
2018-08-22 22:18:48 +03:00
|
|
|
{
|
2023-06-03 04:20:42 +08:00
|
|
|
// NOTE: Due to breaking `nu` updates, `packer.nu` needs to be updated before `nu` get updated
|
|
|
|
|
// by other package managers.
|
|
|
|
|
runner.execute(Step::Shell, "packer.nu", || linux::run_packer_nu(&ctx))?;
|
|
|
|
|
|
2020-07-02 11:15:56 +03:00
|
|
|
match &distribution {
|
|
|
|
|
Ok(distribution) => {
|
|
|
|
|
runner.execute(Step::System, "System update", || distribution.upgrade(&ctx))?;
|
|
|
|
|
}
|
|
|
|
|
Err(e) => {
|
2024-10-03 12:47:35 +02:00
|
|
|
println!("{}", t!("Error detecting current distribution: {error}", error = e));
|
2018-10-02 10:46:38 +03:00
|
|
|
}
|
2018-08-22 22:18:48 +03:00
|
|
|
}
|
2022-01-26 22:52:52 +02:00
|
|
|
runner.execute(Step::ConfigUpdate, "config-update", || linux::run_config_update(&ctx))?;
|
2020-12-16 13:43:38 +02:00
|
|
|
|
2023-06-03 04:20:42 +08:00
|
|
|
runner.execute(Step::AM, "am", || linux::run_am(&ctx))?;
|
|
|
|
|
runner.execute(Step::AppMan, "appman", || linux::run_appman(&ctx))?;
|
|
|
|
|
runner.execute(Step::DebGet, "deb-get", || linux::run_deb_get(&ctx))?;
|
|
|
|
|
runner.execute(Step::Toolbx, "toolbx", || toolbx::run_toolbx(&ctx))?;
|
|
|
|
|
runner.execute(Step::Snap, "snap", || linux::run_snap(&ctx))?;
|
|
|
|
|
runner.execute(Step::Pacstall, "pacstall", || linux::run_pacstall(&ctx))?;
|
|
|
|
|
runner.execute(Step::Pacdef, "pacdef", || linux::run_pacdef(&ctx))?;
|
|
|
|
|
runner.execute(Step::Protonup, "protonup", || linux::run_protonup_update(&ctx))?;
|
|
|
|
|
runner.execute(Step::Distrobox, "distrobox", || linux::run_distrobox_update(&ctx))?;
|
|
|
|
|
runner.execute(Step::DkpPacman, "dkp-pacman", || linux::run_dkp_pacman_update(&ctx))?;
|
|
|
|
|
runner.execute(Step::System, "pihole", || linux::run_pihole_update(&ctx))?;
|
|
|
|
|
runner.execute(Step::Firmware, "Firmware upgrades", || linux::run_fwupdmgr(&ctx))?;
|
|
|
|
|
runner.execute(Step::Restarts, "Restarts", || linux::run_needrestart(&ctx))?;
|
2023-08-06 09:02:20 +05:30
|
|
|
|
|
|
|
|
runner.execute(Step::Flatpak, "Flatpak", || linux::run_flatpak(&ctx))?;
|
|
|
|
|
runner.execute(Step::BrewFormula, "Brew", || {
|
|
|
|
|
unix::run_brew_formula(&ctx, unix::BrewVariant::Path)
|
|
|
|
|
})?;
|
2023-08-15 08:36:20 +08:00
|
|
|
runner.execute(Step::Lure, "LURE", || linux::run_lure_update(&ctx))?;
|
2024-02-16 11:57:53 +08:00
|
|
|
runner.execute(Step::Waydroid, "Waydroid", || linux::run_waydroid(&ctx))?;
|
2024-05-18 16:34:03 +08:00
|
|
|
runner.execute(Step::AutoCpufreq, "auto-cpufreq", || linux::run_auto_cpufreq(&ctx))?;
|
2025-03-04 01:57:12 +01:00
|
|
|
runner.execute(Step::CinnamonSpices, "Cinnamon spices", || {
|
|
|
|
|
linux::run_cinnamon_spices_updater(&ctx)
|
|
|
|
|
})?;
|
2018-06-28 07:47:51 +03:00
|
|
|
}
|
|
|
|
|
|
2020-12-16 13:43:38 +02:00
|
|
|
#[cfg(target_os = "macos")]
|
2019-09-28 14:49:24 +03:00
|
|
|
{
|
2020-12-30 10:35:50 +02:00
|
|
|
runner.execute(Step::BrewFormula, "Brew (ARM)", || {
|
|
|
|
|
unix::run_brew_formula(&ctx, unix::BrewVariant::MacArm)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::BrewFormula, "Brew (Intel)", || {
|
|
|
|
|
unix::run_brew_formula(&ctx, unix::BrewVariant::MacIntel)
|
|
|
|
|
})?;
|
2022-05-13 20:59:13 +03:00
|
|
|
runner.execute(Step::BrewFormula, "Brew", || {
|
|
|
|
|
unix::run_brew_formula(&ctx, unix::BrewVariant::Path)
|
|
|
|
|
})?;
|
2020-12-30 10:35:50 +02:00
|
|
|
runner.execute(Step::BrewCask, "Brew Cask (ARM)", || {
|
|
|
|
|
unix::run_brew_cask(&ctx, unix::BrewVariant::MacArm)
|
2020-12-16 13:43:38 +02:00
|
|
|
})?;
|
2020-12-30 10:35:50 +02:00
|
|
|
runner.execute(Step::BrewCask, "Brew Cask (Intel)", || {
|
|
|
|
|
unix::run_brew_cask(&ctx, unix::BrewVariant::MacIntel)
|
2020-12-16 13:43:38 +02:00
|
|
|
})?;
|
2022-05-13 20:59:13 +03:00
|
|
|
runner.execute(Step::BrewCask, "Brew Cask", || {
|
|
|
|
|
unix::run_brew_cask(&ctx, unix::BrewVariant::Path)
|
|
|
|
|
})?;
|
2021-05-04 11:27:19 +03:00
|
|
|
runner.execute(Step::Macports, "MacPorts", || macos::run_macports(&ctx))?;
|
2024-02-29 15:58:24 -08:00
|
|
|
runner.execute(Step::Xcodes, "Xcodes", || macos::update_xcodes(&ctx))?;
|
2023-06-03 04:20:42 +08:00
|
|
|
runner.execute(Step::Sparkle, "Sparkle", || macos::run_sparkle(&ctx))?;
|
|
|
|
|
runner.execute(Step::Mas, "App Store", || macos::run_mas(&ctx))?;
|
|
|
|
|
runner.execute(Step::System, "System upgrade", || macos::upgrade_macos(&ctx))?;
|
2019-09-28 14:49:24 +03:00
|
|
|
}
|
|
|
|
|
|
2019-06-25 22:47:36 -07:00
|
|
|
#[cfg(target_os = "dragonfly")]
|
2023-05-27 17:37:51 +08:00
|
|
|
{
|
|
|
|
|
runner.execute(Step::Pkg, "DragonFly BSD Packages", || {
|
|
|
|
|
dragonfly::upgrade_packages(&ctx)
|
|
|
|
|
})?;
|
2024-01-07 18:40:01 -07:00
|
|
|
runner.execute(Step::Audit, "DragonFly Audit", || dragonfly::audit_packages(&ctx))?;
|
2023-05-27 17:37:51 +08:00
|
|
|
}
|
2019-09-28 14:49:24 +03:00
|
|
|
|
2018-11-12 11:13:43 +02:00
|
|
|
#[cfg(target_os = "freebsd")]
|
2023-05-27 17:37:51 +08:00
|
|
|
{
|
|
|
|
|
runner.execute(Step::Pkg, "FreeBSD Packages", || freebsd::upgrade_packages(&ctx))?;
|
|
|
|
|
runner.execute(Step::System, "FreeBSD Upgrade", || freebsd::upgrade_freebsd(&ctx))?;
|
2024-01-07 18:40:01 -07:00
|
|
|
runner.execute(Step::Audit, "FreeBSD Audit", || freebsd::audit_packages(&ctx))?;
|
2023-05-27 17:37:51 +08:00
|
|
|
}
|
2018-08-19 14:45:23 +03:00
|
|
|
|
2022-11-02 11:00:10 +01:00
|
|
|
#[cfg(target_os = "openbsd")]
|
2023-05-27 17:37:51 +08:00
|
|
|
{
|
|
|
|
|
runner.execute(Step::Pkg, "OpenBSD Packages", || openbsd::upgrade_packages(&ctx))?;
|
|
|
|
|
runner.execute(Step::System, "OpenBSD Upgrade", || openbsd::upgrade_openbsd(&ctx))?;
|
|
|
|
|
}
|
2022-11-02 11:00:10 +01:00
|
|
|
|
2021-09-02 16:54:31 +00:00
|
|
|
#[cfg(target_os = "android")]
|
2023-06-03 04:20:42 +08:00
|
|
|
{
|
|
|
|
|
runner.execute(Step::Pkg, "Termux Packages", || android::upgrade_packages(&ctx))?;
|
2019-11-04 23:04:35 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-19 08:47:01 +02:00
|
|
|
#[cfg(unix)]
|
2019-11-04 23:04:35 +02:00
|
|
|
{
|
2023-06-03 04:20:42 +08:00
|
|
|
runner.execute(Step::Yadm, "yadm", || unix::run_yadm(&ctx))?;
|
|
|
|
|
runner.execute(Step::Nix, "nix", || unix::run_nix(&ctx))?;
|
2023-12-20 19:55:32 -05:00
|
|
|
runner.execute(Step::Nix, "nix upgrade-nix", || unix::run_nix_self_upgrade(&ctx))?;
|
2025-07-15 11:05:46 +02:00
|
|
|
runner.execute(Step::NixHelper, "nh", || unix::run_nix_helper(&ctx))?;
|
2023-06-03 04:20:42 +08:00
|
|
|
runner.execute(Step::Guix, "guix", || unix::run_guix(&ctx))?;
|
|
|
|
|
runner.execute(Step::HomeManager, "home-manager", || unix::run_home_manager(&ctx))?;
|
|
|
|
|
runner.execute(Step::Asdf, "asdf", || unix::run_asdf(&ctx))?;
|
2024-03-30 04:40:16 -06:00
|
|
|
runner.execute(Step::Mise, "mise", || unix::run_mise(&ctx))?;
|
2023-06-03 04:20:42 +08:00
|
|
|
runner.execute(Step::Pkgin, "pkgin", || unix::run_pkgin(&ctx))?;
|
2023-11-22 23:36:00 +01:00
|
|
|
runner.execute(Step::BunPackages, "bun-packages", || unix::run_bun_packages(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Shell, "zr", || zsh::run_zr(&ctx))?;
|
|
|
|
|
runner.execute(Step::Shell, "antibody", || zsh::run_antibody(&ctx))?;
|
2023-02-26 23:45:43 +02:00
|
|
|
runner.execute(Step::Shell, "antidote", || zsh::run_antidote(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Shell, "antigen", || zsh::run_antigen(&ctx))?;
|
|
|
|
|
runner.execute(Step::Shell, "zgenom", || zsh::run_zgenom(&ctx))?;
|
|
|
|
|
runner.execute(Step::Shell, "zplug", || zsh::run_zplug(&ctx))?;
|
|
|
|
|
runner.execute(Step::Shell, "zinit", || zsh::run_zinit(&ctx))?;
|
|
|
|
|
runner.execute(Step::Shell, "zi", || zsh::run_zi(&ctx))?;
|
|
|
|
|
runner.execute(Step::Shell, "zim", || zsh::run_zim(&ctx))?;
|
2020-07-02 11:15:56 +03:00
|
|
|
runner.execute(Step::Shell, "oh-my-zsh", || zsh::run_oh_my_zsh(&ctx))?;
|
2023-05-18 01:17:37 +08:00
|
|
|
runner.execute(Step::Shell, "oh-my-bash", || unix::run_oh_my_bash(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Shell, "fisher", || unix::run_fisher(&ctx))?;
|
2021-02-10 08:58:03 +02:00
|
|
|
runner.execute(Step::Shell, "bash-it", || unix::run_bashit(&ctx))?;
|
2020-09-03 09:32:45 +03:00
|
|
|
runner.execute(Step::Shell, "oh-my-fish", || unix::run_oh_my_fish(&ctx))?;
|
2021-04-12 04:14:14 -05:00
|
|
|
runner.execute(Step::Shell, "fish-plug", || unix::run_fish_plug(&ctx))?;
|
2022-10-31 02:05:43 -04:00
|
|
|
runner.execute(Step::Shell, "fundle", || unix::run_fundle(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Tmux, "tmux", || tmux::run_tpm(&ctx))?;
|
|
|
|
|
runner.execute(Step::Tldr, "TLDR", || unix::run_tldr(&ctx))?;
|
|
|
|
|
runner.execute(Step::Pearl, "pearl", || unix::run_pearl(&ctx))?;
|
2022-04-23 01:50:17 +05:30
|
|
|
#[cfg(not(any(target_os = "macos", target_os = "android")))]
|
2021-10-25 21:31:13 +03:00
|
|
|
runner.execute(Step::GnomeShellExtensions, "Gnome Shell Extensions", || {
|
|
|
|
|
unix::upgrade_gnome_extensions(&ctx)
|
|
|
|
|
})?;
|
2024-02-26 20:25:18 -05:00
|
|
|
runner.execute(Step::Pyenv, "pyenv", || unix::run_pyenv(&ctx))?;
|
2023-06-03 04:20:42 +08:00
|
|
|
runner.execute(Step::Sdkman, "SDKMAN!", || unix::run_sdkman(&ctx))?;
|
2022-10-31 02:05:12 -04:00
|
|
|
runner.execute(Step::Rcm, "rcm", || unix::run_rcm(&ctx))?;
|
2023-05-18 01:18:03 +08:00
|
|
|
runner.execute(Step::Maza, "maza", || unix::run_maza(&ctx))?;
|
2020-06-29 05:13:31 +02:00
|
|
|
}
|
|
|
|
|
|
2018-10-29 14:32:33 +02:00
|
|
|
#[cfg(not(any(
|
|
|
|
|
target_os = "freebsd",
|
|
|
|
|
target_os = "openbsd",
|
|
|
|
|
target_os = "netbsd",
|
|
|
|
|
target_os = "dragonfly"
|
|
|
|
|
)))]
|
2023-06-03 04:20:42 +08:00
|
|
|
{
|
|
|
|
|
runner.execute(Step::Atom, "apm", || generic::run_apm(&ctx))?;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The following update function should be executed on all OSes.
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Fossil, "fossil", || generic::run_fossil(&ctx))?;
|
2024-03-15 18:35:47 -07:00
|
|
|
runner.execute(Step::Elan, "elan", || generic::run_elan(&ctx))?;
|
2024-05-13 05:52:13 -07:00
|
|
|
runner.execute(Step::Rye, "rye", || generic::run_rye(&ctx))?;
|
2023-04-05 15:42:47 +03:00
|
|
|
runner.execute(Step::Rustup, "rustup", || generic::run_rustup(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Juliaup, "juliaup", || generic::run_juliaup(&ctx))?;
|
2020-12-26 09:21:14 +02:00
|
|
|
runner.execute(Step::Dotnet, ".NET", || generic::run_dotnet_upgrade(&ctx))?;
|
2020-08-28 16:16:23 +03:00
|
|
|
runner.execute(Step::Choosenim, "choosenim", || generic::run_choosenim(&ctx))?;
|
2021-03-22 09:00:56 +02:00
|
|
|
runner.execute(Step::Cargo, "cargo", || generic::run_cargo_update(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Flutter, "Flutter", || generic::run_flutter_upgrade(&ctx))?;
|
|
|
|
|
runner.execute(Step::Go, "go-global-update", || go::run_go_global_update(&ctx))?;
|
|
|
|
|
runner.execute(Step::Go, "gup", || go::run_go_gup(&ctx))?;
|
2021-11-18 20:45:34 +02:00
|
|
|
runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(&ctx))?;
|
2022-10-10 20:24:41 +00:00
|
|
|
runner.execute(Step::Opam, "opam", || generic::run_opam_update(&ctx))?;
|
2022-12-15 11:39:25 +00:00
|
|
|
runner.execute(Step::Vcpkg, "vcpkg", || generic::run_vcpkg_update(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Pipx, "pipx", || generic::run_pipx_update(&ctx))?;
|
2025-03-04 02:11:57 +01:00
|
|
|
runner.execute(Step::Pipxu, "pipxu", || generic::run_pipxu_update(&ctx))?;
|
2023-08-14 03:22:26 +02:00
|
|
|
runner.execute(Step::Vscode, "Visual Studio Code extensions", || {
|
2024-01-24 03:32:00 +01:00
|
|
|
generic::run_vscode_extensions_update(&ctx)
|
2023-08-14 03:22:26 +02:00
|
|
|
})?;
|
2025-01-09 10:35:45 +08:00
|
|
|
runner.execute(Step::Vscodium, "VSCodium extensions", || {
|
|
|
|
|
generic::run_vscodium_extensions_update(&ctx)
|
|
|
|
|
})?;
|
2022-01-15 06:50:42 +02:00
|
|
|
runner.execute(Step::Conda, "conda", || generic::run_conda_update(&ctx))?;
|
2023-04-17 16:19:59 +02:00
|
|
|
runner.execute(Step::Mamba, "mamba", || generic::run_mamba_update(&ctx))?;
|
2024-09-26 07:19:32 +01:00
|
|
|
runner.execute(Step::Pixi, "pixi", || generic::run_pixi_update(&ctx))?;
|
2023-08-13 04:05:07 +02:00
|
|
|
runner.execute(Step::Miktex, "miktex", || generic::run_miktex_packages_update(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Pip3, "pip3", || generic::run_pip3_update(&ctx))?;
|
2023-01-29 19:19:27 +00:00
|
|
|
runner.execute(Step::PipReview, "pip-review", || generic::run_pip_review_update(&ctx))?;
|
2023-05-20 23:03:59 +05:30
|
|
|
runner.execute(Step::PipReviewLocal, "pip-review (local)", || {
|
|
|
|
|
generic::run_pip_review_local_update(&ctx)
|
|
|
|
|
})?;
|
2023-01-29 19:19:27 +00:00
|
|
|
runner.execute(Step::Pipupgrade, "pipupgrade", || generic::run_pipupgrade_update(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Ghcup, "ghcup", || generic::run_ghcup_update(&ctx))?;
|
|
|
|
|
runner.execute(Step::Stack, "stack", || generic::run_stack_update(&ctx))?;
|
2020-07-02 11:15:56 +03:00
|
|
|
runner.execute(Step::Tlmgr, "tlmgr", || generic::run_tlmgr_update(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Myrepos, "myrepos", || generic::run_myrepos_update(&ctx))?;
|
|
|
|
|
runner.execute(Step::Chezmoi, "chezmoi", || generic::run_chezmoi_update(&ctx))?;
|
|
|
|
|
runner.execute(Step::Jetpack, "jetpack", || generic::run_jetpack(&ctx))?;
|
2023-05-01 00:02:13 +05:30
|
|
|
runner.execute(Step::Vim, "vim", || vim::upgrade_vim(&ctx))?;
|
|
|
|
|
runner.execute(Step::Vim, "Neovim", || vim::upgrade_neovim(&ctx))?;
|
2022-04-23 15:39:58 +03:00
|
|
|
runner.execute(Step::Vim, "The Ultimate vimrc", || vim::upgrade_ultimate_vimrc(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Vim, "voom", || vim::run_voom(&ctx))?;
|
2022-02-06 18:48:06 -03:00
|
|
|
runner.execute(Step::Kakoune, "Kakoune", || kakoune::upgrade_kak_plug(&ctx))?;
|
2022-12-14 09:12:39 +01:00
|
|
|
runner.execute(Step::Helix, "helix", || generic::run_helix_grammars(&ctx))?;
|
2021-06-09 10:52:48 +03:00
|
|
|
runner.execute(Step::Node, "npm", || node::run_npm_upgrade(&ctx))?;
|
2022-12-15 00:42:48 +03:00
|
|
|
runner.execute(Step::Yarn, "yarn", || node::run_yarn_upgrade(&ctx))?;
|
|
|
|
|
runner.execute(Step::Pnpm, "pnpm", || node::run_pnpm_upgrade(&ctx))?;
|
2024-08-01 11:26:22 +01:00
|
|
|
runner.execute(Step::VoltaPackages, "volta packages", || {
|
|
|
|
|
node::run_volta_packages_upgrade(&ctx)
|
|
|
|
|
})?;
|
2022-03-05 20:59:19 +01:00
|
|
|
runner.execute(Step::Containers, "Containers", || containers::run_containers(&ctx))?;
|
2020-10-01 15:59:06 -04:00
|
|
|
runner.execute(Step::Deno, "deno", || node::deno_upgrade(&ctx))?;
|
2020-07-02 11:15:56 +03:00
|
|
|
runner.execute(Step::Composer, "composer", || generic::run_composer_update(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Krew, "krew", || generic::run_krew_upgrade(&ctx))?;
|
|
|
|
|
runner.execute(Step::Helm, "helm", || generic::run_helm_repo_update(&ctx))?;
|
|
|
|
|
runner.execute(Step::Gem, "gem", || generic::run_gem(&ctx))?;
|
2023-01-29 19:19:27 +00:00
|
|
|
runner.execute(Step::RubyGems, "rubygems", || generic::run_rubygems(&ctx))?;
|
2022-10-10 18:29:56 +00:00
|
|
|
runner.execute(Step::Julia, "julia", || generic::update_julia_packages(&ctx))?;
|
2021-10-25 12:54:27 -06:00
|
|
|
runner.execute(Step::Haxelib, "haxelib", || generic::run_haxelib_update(&ctx))?;
|
2020-07-30 06:27:29 +03:00
|
|
|
runner.execute(Step::Sheldon, "sheldon", || generic::run_sheldon(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Stew, "stew", || generic::run_stew(&ctx))?;
|
2020-09-25 01:00:06 +08:00
|
|
|
runner.execute(Step::Rtcl, "rtcl", || generic::run_rtcl(&ctx))?;
|
2021-05-29 01:59:27 -03:00
|
|
|
runner.execute(Step::Bin, "bin", || generic::bin_update(&ctx))?;
|
2023-05-25 15:09:23 +08:00
|
|
|
runner.execute(Step::Gcloud, "gcloud", || generic::run_gcloud_components_update(&ctx))?;
|
|
|
|
|
runner.execute(Step::Micro, "micro", || generic::run_micro(&ctx))?;
|
|
|
|
|
runner.execute(Step::Raco, "raco", || generic::run_raco_update(&ctx))?;
|
2021-11-15 07:09:02 +01:00
|
|
|
runner.execute(Step::Spicetify, "spicetify", || generic::spicetify_upgrade(&ctx))?;
|
2022-04-03 17:25:07 -04:00
|
|
|
runner.execute(Step::GithubCliExtensions, "GitHub CLI Extensions", || {
|
2022-03-08 00:16:52 +01:00
|
|
|
generic::run_ghcli_extensions_upgrade(&ctx)
|
|
|
|
|
})?;
|
2023-06-23 17:03:57 +08:00
|
|
|
runner.execute(Step::Bob, "Bob", || generic::run_bob(&ctx))?;
|
2024-01-28 13:03:30 +08:00
|
|
|
runner.execute(Step::Certbot, "Certbot", || generic::run_certbot(&ctx))?;
|
2024-03-09 17:57:33 +08:00
|
|
|
runner.execute(Step::GitRepos, "Git Repositories", || git::run_git_pull(&ctx))?;
|
2024-03-19 14:10:47 +08:00
|
|
|
runner.execute(Step::ClamAvDb, "ClamAV Databases", || generic::run_freshclam(&ctx))?;
|
2024-04-07 11:03:33 +08:00
|
|
|
runner.execute(Step::PlatformioCore, "PlatformIO Core", || {
|
|
|
|
|
generic::run_platform_io(&ctx)
|
|
|
|
|
})?;
|
2024-06-30 22:41:09 +08:00
|
|
|
runner.execute(Step::Lensfun, "Lensfun's database update", || {
|
|
|
|
|
generic::run_lensfun_update_data(&ctx)
|
|
|
|
|
})?;
|
2024-07-07 10:37:07 +08:00
|
|
|
runner.execute(Step::Poetry, "Poetry", || generic::run_poetry(&ctx))?;
|
2024-08-24 22:22:27 -04:00
|
|
|
runner.execute(Step::Uv, "uv", || generic::run_uv(&ctx))?;
|
2024-07-23 07:26:08 +08:00
|
|
|
runner.execute(Step::Zvm, "ZVM", || generic::run_zvm(&ctx))?;
|
2024-08-20 03:18:27 +02:00
|
|
|
runner.execute(Step::Aqua, "aqua", || generic::run_aqua(&ctx))?;
|
2024-08-26 22:21:17 +08:00
|
|
|
runner.execute(Step::Bun, "bun", || generic::run_bun(&ctx))?;
|
2025-02-08 06:25:10 +00:00
|
|
|
runner.execute(Step::Zigup, "zigup", || generic::run_zigup(&ctx))?;
|
2025-04-11 04:56:24 +02:00
|
|
|
runner.execute(Step::JetbrainsToolbox, "JetBrains Toolbox", || {
|
2025-03-18 04:19:37 +01:00
|
|
|
generic::run_jetbrains_toolbox(&ctx)
|
|
|
|
|
})?;
|
2025-04-11 04:56:24 +02:00
|
|
|
runner.execute(Step::AndroidStudio, "Android Studio plugins", || {
|
|
|
|
|
generic::run_android_studio(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::JetbrainsAqua, "JetBrains Aqua plugins", || {
|
|
|
|
|
generic::run_jetbrains_aqua(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::JetbrainsClion, "JetBrains CLion plugins", || {
|
|
|
|
|
generic::run_jetbrains_clion(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::JetbrainsDatagrip, "JetBrains DataGrip plugins", || {
|
|
|
|
|
generic::run_jetbrains_datagrip(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::JetbrainsDataspell, "JetBrains DataSpell plugins", || {
|
|
|
|
|
generic::run_jetbrains_dataspell(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
// JetBrains dotCover has no CLI
|
|
|
|
|
// JetBrains dotMemory has no CLI
|
|
|
|
|
// JetBrains dotPeek has no CLI
|
|
|
|
|
// JetBrains dotTrace has no CLI
|
|
|
|
|
// JetBrains Fleet has a different CLI without a `fleet update` command.
|
|
|
|
|
runner.execute(Step::JetbrainsGateway, "JetBrains Gateway plugins", || {
|
|
|
|
|
generic::run_jetbrains_gateway(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::JetbrainsGoland, "JetBrains GoLand plugins", || {
|
|
|
|
|
generic::run_jetbrains_goland(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::JetbrainsIdea, "JetBrains IntelliJ IDEA plugins", || {
|
|
|
|
|
generic::run_jetbrains_idea(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::JetbrainsMps, "JetBrains MPS plugins", || {
|
|
|
|
|
generic::run_jetbrains_mps(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::JetbrainsPhpstorm, "JetBrains PhpStorm plugins", || {
|
|
|
|
|
generic::run_jetbrains_phpstorm(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::JetbrainsPycharm, "JetBrains PyCharm plugins", || {
|
|
|
|
|
generic::run_jetbrains_pycharm(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
// JetBrains ReSharper has no CLI (it's a VSCode extension)
|
|
|
|
|
// JetBrains ReSharper C++ has no CLI (it's a VSCode extension)
|
|
|
|
|
runner.execute(Step::JetbrainsRider, "JetBrains Rider plugins", || {
|
|
|
|
|
generic::run_jetbrains_rider(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::JetbrainsRubymine, "JetBrains RubyMine plugins", || {
|
|
|
|
|
generic::run_jetbrains_rubymine(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
runner.execute(Step::JetbrainsRustrover, "JetBrains RustRover plugins", || {
|
|
|
|
|
generic::run_jetbrains_rustrover(&ctx)
|
|
|
|
|
})?;
|
|
|
|
|
// JetBrains Space Desktop does not have a CLI
|
|
|
|
|
runner.execute(Step::JetbrainsWebstorm, "JetBrains WebStorm plugins", || {
|
|
|
|
|
generic::run_jetbrains_webstorm(&ctx)
|
|
|
|
|
})?;
|
2025-04-21 05:45:01 +02:00
|
|
|
runner.execute(Step::Yazi, "Yazi packages", || generic::run_yazi(&ctx))?;
|
2023-06-03 04:20:42 +08:00
|
|
|
|
|
|
|
|
if should_run_powershell {
|
|
|
|
|
runner.execute(Step::Powershell, "Powershell Modules Update", || {
|
|
|
|
|
powershell.update_modules(&ctx)
|
|
|
|
|
})?;
|
2018-06-14 13:24:52 +03:00
|
|
|
}
|
|
|
|
|
|
2018-06-11 08:38:29 +03:00
|
|
|
if let Some(commands) = config.commands() {
|
|
|
|
|
for (name, command) in commands {
|
2022-05-07 15:25:51 +03:00
|
|
|
if config.should_run_custom_command(name) {
|
|
|
|
|
runner.execute(Step::CustomCommands, name, || {
|
|
|
|
|
generic::run_custom_command(name, command, &ctx)
|
|
|
|
|
})?;
|
|
|
|
|
}
|
2018-06-11 08:38:29 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-10 11:51:52 +03:00
|
|
|
if config.should_run(Step::Vagrant) {
|
2020-06-16 21:02:50 +03:00
|
|
|
if let Ok(boxes) = vagrant::collect_boxes(&ctx) {
|
|
|
|
|
for vagrant_box in boxes {
|
2020-07-02 11:15:56 +03:00
|
|
|
runner.execute(Step::Vagrant, format!("Vagrant ({})", vagrant_box.smart_name()), || {
|
2020-06-16 21:02:50 +03:00
|
|
|
vagrant::topgrade_vagrant_box(&ctx, &vagrant_box)
|
|
|
|
|
})?;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-10 11:51:52 +03:00
|
|
|
}
|
2022-04-23 15:09:54 +03:00
|
|
|
runner.execute(Step::Vagrant, "Vagrant boxes", || vagrant::upgrade_vagrant_boxes(&ctx))?;
|
2020-06-10 11:51:52 +03:00
|
|
|
|
2020-02-09 13:41:55 +02:00
|
|
|
if !runner.report().data().is_empty() {
|
2024-10-03 12:47:35 +02:00
|
|
|
print_separator(t!("Summary"));
|
2018-06-03 18:04:58 +03:00
|
|
|
|
2020-07-02 11:15:56 +03:00
|
|
|
for (key, result) in runner.report().data() {
|
2020-08-21 23:04:36 +03:00
|
|
|
print_result(key, result);
|
2018-06-03 18:04:58 +03:00
|
|
|
}
|
2018-10-02 11:36:10 +03:00
|
|
|
|
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
|
{
|
|
|
|
|
if let Ok(distribution) = &distribution {
|
|
|
|
|
distribution.show_summary();
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-29 23:48:30 +03:00
|
|
|
}
|
|
|
|
|
|
2020-08-30 07:40:06 +03:00
|
|
|
let mut post_command_failed = false;
|
|
|
|
|
if let Some(commands) = config.post_commands() {
|
|
|
|
|
for (name, command) in commands {
|
2021-09-02 06:18:01 +03:00
|
|
|
if generic::run_custom_command(name, command, &ctx).is_err() {
|
2020-08-30 07:40:06 +03:00
|
|
|
post_command_failed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-16 09:09:05 +03:00
|
|
|
if config.keep_at_end() {
|
2024-10-03 12:47:35 +02:00
|
|
|
print_info(t!("\n(R)eboot\n(S)hell\n(Q)uit"));
|
2019-08-04 09:25:35 +03:00
|
|
|
loop {
|
2021-02-13 06:26:50 +02:00
|
|
|
match get_key() {
|
2025-02-02 19:24:57 -08:00
|
|
|
Ok(Key::Char('s' | 'S')) => {
|
2022-11-08 05:54:35 -05:00
|
|
|
run_shell().context("Failed to execute shell")?;
|
2021-10-28 22:05:35 +03:00
|
|
|
}
|
2025-02-02 19:24:57 -08:00
|
|
|
Ok(Key::Char('r' | 'R')) => {
|
2022-11-08 05:54:35 -05:00
|
|
|
reboot().context("Failed to reboot")?;
|
2021-10-28 22:05:35 +03:00
|
|
|
}
|
2025-02-02 19:24:57 -08:00
|
|
|
Ok(Key::Char('q' | 'Q')) => (),
|
2021-10-28 22:05:35 +03:00
|
|
|
_ => {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-06-13 22:05:18 +03:00
|
|
|
}
|
2019-08-04 09:25:35 +03:00
|
|
|
break;
|
2019-06-13 22:05:18 +03:00
|
|
|
}
|
2019-06-13 09:21:39 +03:00
|
|
|
}
|
|
|
|
|
|
2020-11-04 11:31:09 +02:00
|
|
|
let failed = post_command_failed || runner.report().data().iter().any(|(_, result)| result.failed());
|
2022-10-10 20:21:20 +00:00
|
|
|
|
|
|
|
|
if !config.skip_notify() {
|
2023-05-27 17:41:42 +08:00
|
|
|
notify_desktop(
|
2024-10-03 12:47:35 +02:00
|
|
|
if failed {
|
|
|
|
|
t!("Topgrade finished with errors")
|
|
|
|
|
} else {
|
|
|
|
|
t!("Topgrade finished successfully")
|
|
|
|
|
},
|
2023-01-29 19:19:27 +00:00
|
|
|
Some(Duration::from_secs(10)),
|
2025-02-02 19:24:57 -08:00
|
|
|
);
|
2022-10-10 20:21:20 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-04 11:31:09 +02:00
|
|
|
if failed {
|
2019-12-11 23:05:38 +02:00
|
|
|
Err(StepFailed.into())
|
2020-07-02 11:15:56 +03:00
|
|
|
} else {
|
|
|
|
|
Ok(())
|
2018-06-11 08:57:55 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
match run() {
|
|
|
|
|
Ok(()) => {
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
Err(error) => {
|
2019-06-03 09:41:25 +03:00
|
|
|
#[cfg(all(windows, feature = "self-update"))]
|
|
|
|
|
{
|
2019-12-11 23:05:38 +02:00
|
|
|
if let Some(Upgraded(status)) = error.downcast_ref::<Upgraded>() {
|
2019-06-03 09:41:25 +03:00
|
|
|
exit(status.code().unwrap());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
let skip_print = (error.downcast_ref::<StepFailed>().is_some())
|
|
|
|
|
|| (error
|
|
|
|
|
.downcast_ref::<io::Error>()
|
2018-12-11 16:43:26 +02:00
|
|
|
.filter(|io_error| io_error.kind() == io::ErrorKind::Interrupted)
|
2019-12-11 23:05:38 +02:00
|
|
|
.is_some());
|
2018-12-11 16:43:26 +02:00
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
if !skip_print {
|
2022-11-11 09:39:29 -05:00
|
|
|
// The `Debug` implementation of `eyre::Result` prints a multi-line
|
2022-11-03 12:46:43 -04:00
|
|
|
// error message that includes all the 'causes' added with
|
|
|
|
|
// `.with_context(...)` calls.
|
2024-10-03 12:47:35 +02:00
|
|
|
println!("{}", t!("Error: {error}", error = format!("{:?}", error)));
|
2018-10-17 14:07:58 +03:00
|
|
|
}
|
2018-06-11 08:57:55 +03:00
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-29 23:48:30 +03:00
|
|
|
}
|