Files
topgrade/src/steps/os/linux.rs

684 lines
20 KiB
Rust
Raw Normal View History

2022-01-06 21:41:36 +02:00
use std::path::{Path, PathBuf};
use std::process::Command;
use anyhow::Result;
use ini::Ini;
use log::{debug, warn};
use crate::error::{SkipStep, TopgradeError};
2020-05-14 09:22:14 +03:00
use crate::execution_context::ExecutionContext;
use crate::executor::{CommandExt, RunType};
use crate::steps::os::archlinux;
2018-12-15 21:52:21 +02:00
use crate::terminal::{print_separator, print_warning};
2019-09-28 20:26:03 +03:00
use crate::utils::{require, require_option, which, PathExt};
use crate::Step;
static OS_RELEASE_PATH: &str = "/etc/os-release";
2021-04-06 10:28:07 +03:00
#[allow(clippy::upper_case_acronyms)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Distribution {
2021-07-06 09:24:42 +03:00
Alpine,
Arch,
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
Bedrock,
CentOS,
ClearLinux,
Fedora,
Debian,
2018-10-21 15:08:36 +03:00
Gentoo,
Suse,
2018-11-20 14:38:23 +02:00
Void,
2019-03-21 10:36:40 -07:00
Solus,
Exherbo,
NixOS,
KDENeon,
}
impl Distribution {
fn parse_os_release(os_release: &ini::Ini) -> Result<Self> {
2019-05-16 15:37:35 +03:00
let section = os_release.general_section();
2020-02-29 20:15:28 +02:00
let id = section.get("ID");
let id_like: Option<Vec<&str>> = section.get("ID_LIKE").map(|s| s.split_whitespace().collect());
2019-09-05 21:04:07 +03:00
Ok(match id {
2021-07-06 09:24:42 +03:00
Some("alpine") => Distribution::Alpine,
2021-10-28 22:05:35 +03:00
Some("centos") | Some("rhel") | Some("ol") => Distribution::CentOS,
Some("clear-linux-os") => Distribution::ClearLinux,
2019-09-05 21:04:07 +03:00
Some("fedora") => Distribution::Fedora,
Some("void") => Distribution::Void,
2021-10-28 22:05:35 +03:00
Some("debian") | Some("pureos") => Distribution::Debian,
Some("arch") | Some("anarchy") | Some("manjaro-arm") | Some("garuda") | Some("artix") => Distribution::Arch,
2019-09-05 21:04:07 +03:00
Some("solus") => Distribution::Solus,
Some("gentoo") => Distribution::Gentoo,
Some("exherbo") => Distribution::Exherbo,
Some("nixos") => Distribution::NixOS,
Some("neon") => Distribution::KDENeon,
_ => {
if let Some(id_like) = id_like {
if id_like.contains(&"debian") || id_like.contains(&"ubuntu") {
return Ok(Distribution::Debian);
} else if id_like.contains(&"centos") {
return Ok(Distribution::CentOS);
} else if id_like.contains(&"suse") {
return Ok(Distribution::Suse);
} else if id_like.contains(&"arch") || id_like.contains(&"archlinux") {
return Ok(Distribution::Arch);
} else if id_like.contains(&"alpine") {
return Ok(Distribution::Alpine);
} else if id_like.contains(&"fedora") {
return Ok(Distribution::Fedora);
}
}
return Err(TopgradeError::UnknownLinuxDistribution.into());
}
})
}
2019-03-21 10:36:40 -07:00
pub fn detect() -> Result<Self> {
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
if PathBuf::from("/bedrock").exists() {
return Ok(Distribution::Bedrock);
}
if PathBuf::from(OS_RELEASE_PATH).exists() {
let os_release = Ini::load_from_file(OS_RELEASE_PATH)?;
return Self::parse_os_release(&os_release);
2019-04-14 11:25:40 +03:00
}
Err(TopgradeError::UnknownLinuxDistribution.into())
}
2020-05-14 09:22:14 +03:00
pub fn upgrade(self, ctx: &ExecutionContext) -> Result<()> {
2018-12-05 11:34:08 +02:00
print_separator("System update");
2019-02-11 14:10:06 +02:00
match self {
2021-07-06 09:24:42 +03:00
Distribution::Alpine => upgrade_alpine_linux(ctx),
Distribution::Arch => archlinux::upgrade_arch_linux(ctx),
2020-05-14 09:22:14 +03:00
Distribution::CentOS | Distribution::Fedora => upgrade_redhat(ctx),
2021-09-02 17:09:48 +00:00
Distribution::ClearLinux => upgrade_clearlinux(ctx),
2021-04-06 10:54:23 +03:00
Distribution::Debian => upgrade_debian(ctx),
Distribution::Gentoo => upgrade_gentoo(ctx),
2021-09-02 17:09:48 +00:00
Distribution::Suse => upgrade_suse(ctx),
Distribution::Void => upgrade_void(ctx),
Distribution::Solus => upgrade_solus(ctx),
Distribution::Exherbo => upgrade_exherbo(ctx),
Distribution::NixOS => upgrade_nixos(ctx),
Distribution::KDENeon => upgrade_neon(ctx),
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
Distribution::Bedrock => update_bedrock(ctx),
2019-02-11 14:10:06 +02:00
}
}
pub fn show_summary(self) {
if let Distribution::Arch = self {
2021-10-25 22:53:53 +03:00
archlinux::show_pacnew();
}
}
pub fn redhat_based(self) -> bool {
2020-10-24 14:46:38 -05:00
matches!(self, Distribution::CentOS | Distribution::Fedora)
}
}
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
fn update_bedrock(ctx: &ExecutionContext) -> Result<()> {
let sudo = require_option(ctx.sudo().as_ref(), String::from("Sudo required"))?;
ctx.run_type().execute(sudo).args(&["brl", "update"]);
let output = Command::new("brl").arg("list").output()?;
debug!("brl list: {:?} {:?}", output.stdout, output.stderr);
let parsed_output = String::from_utf8(output.stdout).unwrap();
for distribution in parsed_output.trim().split('\n') {
debug!("Bedrock distribution {}", distribution);
match distribution {
"arch" => archlinux::upgrade_arch_linux(ctx)?,
"debian" | "ubuntu" => upgrade_debian(ctx)?,
"centos" | "fedora" => upgrade_redhat(ctx)?,
"bedrock" => upgrade_bedrock_strata(ctx)?,
_ => {
warn!("Unknown distribution {}", distribution);
}
}
}
Ok(())
}
2020-06-11 19:11:57 +03:00
fn is_wsl() -> Result<bool> {
let output = Command::new("uname").arg("-r").check_output()?;
debug!("Uname output: {}", output);
Ok(output.contains("microsoft"))
}
2021-07-06 09:24:42 +03:00
fn upgrade_alpine_linux(ctx: &ExecutionContext) -> Result<()> {
let apk = require("apk")?;
let sudo = ctx.sudo().as_ref().unwrap();
ctx.run_type().execute(sudo).arg(&apk).arg("update").check_run()?;
ctx.run_type().execute(sudo).arg(&apk).arg("upgrade").check_run()
}
2020-05-14 09:22:14 +03:00
fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
if let Some(ostree) = which("rpm-ostree") {
if ctx.config().rpm_ostree() {
let mut command = ctx.run_type().execute(ostree);
command.arg("upgrade");
return command.check_run();
}
};
2020-05-14 09:22:14 +03:00
if let Some(sudo) = &ctx.sudo() {
let mut command = ctx.run_type().execute(&sudo);
command
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
.arg(which("dnf").unwrap_or_else(|| Path::new("yum").to_path_buf()))
.arg(if ctx.config().redhat_distro_sync() {
"distro-sync"
} else {
"upgrade"
});
2020-05-14 09:22:14 +03:00
if let Some(args) = ctx.config().dnf_arguments() {
command.args(args.split_whitespace());
}
if ctx.config().yes(Step::System) {
command.arg("-y");
}
command.check_run()?;
2018-06-12 21:28:32 +03:00
} else {
2018-12-05 11:34:08 +02:00
print_warning("No sudo detected. Skipping system upgrade");
2018-11-03 22:57:09 +02:00
}
Ok(())
}
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
fn upgrade_bedrock_strata(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = ctx.sudo() {
ctx.run_type().execute(&sudo).args(&["brl", "update"]).check_run()?;
} else {
print_warning("No sudo detected. Skipping system upgrade");
}
Ok(())
}
2021-09-02 17:09:48 +00:00
fn upgrade_suse(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = ctx.sudo() {
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
ctx.run_type().execute(&sudo).args(&["zypper", "refresh"]).check_run()?;
2018-11-03 22:57:09 +02:00
2021-09-02 17:09:48 +00:00
ctx.run_type()
.execute(&sudo)
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
.args(&["zypper", "dist-upgrade"])
2018-12-31 22:00:34 +02:00
.check_run()?;
2018-11-03 22:57:09 +02:00
} else {
2018-12-05 11:34:08 +02:00
print_warning("No sudo detected. Skipping system upgrade");
2018-11-20 14:38:23 +02:00
}
Ok(())
}
2021-09-02 17:09:48 +00:00
fn upgrade_void(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = ctx.sudo() {
2022-02-06 18:47:52 -03:00
let mut command = ctx.run_type().execute(&sudo);
command.args(&["xbps-install", "-Su", "xbps"]);
if ctx.config().yes(Step::System) {
command.arg("-y");
}
command.check_run()?;
2020-02-17 06:18:38 +00:00
2022-02-06 18:47:52 -03:00
let mut command = ctx.run_type().execute(&sudo);
command.args(&["xbps-install", "-u"]);
if ctx.config().yes(Step::System) {
command.arg("-y");
}
command.check_run()?;
2018-11-20 14:38:23 +02:00
} else {
2018-12-05 11:34:08 +02:00
print_warning("No sudo detected. Skipping system upgrade");
2018-06-12 21:28:32 +03:00
}
Ok(())
}
fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
let run_type = ctx.run_type();
if let Some(sudo) = &ctx.sudo() {
2018-10-21 15:08:36 +03:00
if let Some(layman) = which("layman") {
2021-10-28 22:05:35 +03:00
run_type.execute(&sudo).arg(layman).args(&["-s", "ALL"]).check_run()?;
2018-10-21 15:08:36 +03:00
}
println!("Syncing portage");
run_type
.execute(&sudo)
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
.args(&["emerge", "--sync"])
.args(
ctx.config()
.emerge_sync_flags()
.map(|s| s.split_whitespace().collect())
.unwrap_or_else(|| vec!["-q"]),
)
2018-12-31 22:00:34 +02:00
.check_run()?;
2018-10-21 15:08:36 +03:00
if let Some(eix_update) = which("eix-update") {
2018-12-31 22:00:34 +02:00
run_type.execute(&sudo).arg(eix_update).check_run()?;
2018-10-21 15:08:36 +03:00
}
run_type
.execute(&sudo)
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
.arg("emerge")
.args(
ctx.config()
.emerge_update_flags()
.map(|s| s.split_whitespace().collect())
.unwrap_or_else(|| vec!["-uDNa", "--with-bdeps=y", "world"]),
)
2018-12-31 22:00:34 +02:00
.check_run()?;
2018-10-21 15:08:36 +03:00
} else {
2018-12-05 11:34:08 +02:00
print_warning("No sudo detected. Skipping system upgrade");
2018-10-21 15:08:36 +03:00
}
Ok(())
}
2021-04-06 10:54:23 +03:00
fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = &ctx.sudo() {
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
let apt = which("apt-fast").unwrap_or_else(|| PathBuf::from("apt-get"));
2021-04-06 10:54:23 +03:00
ctx.run_type().execute(&sudo).arg(&apt).arg("update").check_run()?;
2021-04-06 10:54:23 +03:00
let mut command = ctx.run_type().execute(&sudo);
2019-11-20 09:09:10 +02:00
command.arg(&apt).arg("dist-upgrade");
if ctx.config().yes(Step::System) {
command.arg("-y");
}
2021-04-06 10:54:23 +03:00
if let Some(args) = ctx.config().apt_arguments() {
command.args(args.split_whitespace());
}
2019-11-20 09:09:10 +02:00
command.check_run()?;
2021-04-06 10:54:23 +03:00
if ctx.config().cleanup() {
ctx.run_type().execute(&sudo).arg(&apt).arg("clean").check_run()?;
2021-04-06 10:54:23 +03:00
let mut command = ctx.run_type().execute(&sudo);
2019-11-20 09:09:10 +02:00
command.arg(&apt).arg("autoremove");
if ctx.config().yes(Step::System) {
2019-11-20 09:09:10 +02:00
command.arg("-y");
}
command.check_run()?;
}
2018-06-12 21:28:32 +03:00
} else {
2018-12-05 11:34:08 +02:00
print_warning("No sudo detected. Skipping system upgrade");
2018-06-12 21:28:32 +03:00
}
Ok(())
}
2018-06-28 12:16:54 +03:00
2021-09-02 17:09:48 +00:00
fn upgrade_solus(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = ctx.sudo() {
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
ctx.run_type().execute(&sudo).args(&["eopkg", "upgrade"]).check_run()?;
2019-03-21 10:36:40 -07:00
} else {
print_warning("No sudo detected. Skipping system upgrade");
}
Ok(())
}
2021-10-25 21:33:58 +03:00
pub fn run_pacstall(ctx: &ExecutionContext) -> Result<()> {
let pacstall = require("pacstall")?;
2022-01-06 21:41:36 +02:00
print_separator("Pacstall");
ctx.run_type().execute(&pacstall).arg("-U").check_run()?;
ctx.run_type().execute(pacstall).arg("-Up").check_run()
2021-10-25 21:33:58 +03:00
}
2021-09-02 17:09:48 +00:00
fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = &ctx.sudo() {
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
ctx.run_type().execute(&sudo).args(&["swupd", "update"]).check_run()?;
} else {
print_warning("No sudo detected. Skipping system upgrade");
}
Ok(())
}
2021-09-02 17:09:48 +00:00
fn upgrade_exherbo(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = ctx.sudo() {
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
ctx.run_type().execute(&sudo).args(&["cave", "sync"]).check_run()?;
2021-09-02 17:09:48 +00:00
ctx.run_type()
.execute(&sudo)
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
.args(&["cave", "resolve", "world", "-c1", "-Cs", "-km", "-Km", "-x"])
.check_run()?;
2021-09-02 17:09:48 +00:00
if ctx.config().cleanup() {
ctx.run_type()
.execute(&sudo)
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
.args(&["cave", "purge", "-x"])
.check_run()?;
}
2021-09-02 17:09:48 +00:00
ctx.run_type()
.execute(&sudo)
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
.args(&["cave", "fix-linkage", "-x", "--", "-Cs"])
.check_run()?;
2021-09-02 17:09:48 +00:00
ctx.run_type()
.execute(&sudo)
Add Bedrock Linux support (fix #745) (#747) * Bedrock Linux (fix #745) * Add more distributions * fix * fix * Fix * Merge * Move pacnew to the correct location * Version bump * Correct spelling for GNOME Shell extensions update (#778) * fix gnome shell extensions update object path (#788) * config: ArchPackageManager should be snake_case (#784) * config: ArchPackageManager should be snake_case * Remove unnecessary strum macro * Add arch_package_manager to config.example.toml * Add release pipeline * Run GNOME update only when using GNOME * Delete travis file and appveyor * Bump * Support rust 1.51.0 (#789) * Cross compilation * Bump * fix: GNOME detection for customized version (#790) Signed-off-by: Noel Georgi <git@frezbo.dev> * Add a flag to disable showing Arch Linux news (fix #786) * Bump * Update pacstall (fix #769) * Add an option to force vim plug update (#795) * Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de> * Add new step pacdiff (#796) * Add Support for Spicetify (#798) * Look for ~/.config/emacs directory in Windows (fix #766) * Pass --force to doom when -y is set (fix #799) * Implement cleanup for flatpak (#801) * Cleanup flatpak * Fix compile error * Make sure we only move our values at the very end * Access config.cleanup() through ExecutionContext * Improve man page (#803) Wordings & argument format * Avoid running remote topgrade on the current host (fix #804) (#807) * Merge the command line and the configuration flags of --only and --disable (fix #805) (#806) * Merge the command line and the configuration flags of --only and --disable (fix #805) * Fix * Fix rust requirement in the readme * Selective yes (fix #802) (#808) * Selective yes flag (fix #802) * Selective yes flag (fix #802) * selective yes * MacOS * Fix bedrock detection * Bedrock fixes * format * Fedora fixes Co-authored-by: Björn Daase <bjoern.daase@gmail.com> Co-authored-by: modularTaco <37046961+modularTaco@users.noreply.github.com> Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: Noel Georgi <git@frezbo.dev> Co-authored-by: Manuel Hässig <mhaessig@users.noreply.github.com> Co-authored-by: Janek <27jf@pm.me>
2021-12-09 15:16:42 +02:00
.args(&["eclectic", "config", "interactive"])
.check_run()?;
} else {
print_warning("No sudo detected. Skipping system upgrade");
}
Ok(())
}
2021-09-02 17:09:48 +00:00
fn upgrade_nixos(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = ctx.sudo() {
ctx.run_type()
.execute(&sudo)
2021-10-28 22:05:35 +03:00
.args(&["/run/current-system/sw/bin/nixos-rebuild", "switch", "--upgrade"])
.check_run()?;
2021-09-02 17:09:48 +00:00
if ctx.config().cleanup() {
ctx.run_type()
.execute(&sudo)
2021-10-28 22:05:35 +03:00
.args(&["/run/current-system/sw/bin/nix-collect-garbage", "-d"])
.check_run()?;
}
} else {
print_warning("No sudo detected. Skipping system upgrade");
}
Ok(())
}
fn upgrade_neon(ctx: &ExecutionContext) -> Result<()> {
// KDE neon is ubuntu based but uses it's own manager, pkcon
// running apt update with KDE neon is an error
// in theory rpm based distributions use pkcon as well, though that
// seems rare
// if that comes up we need to create a Distribution::PackageKit or some such
if let Some(sudo) = &ctx.sudo() {
let pkcon = which("pkcon").unwrap();
// pkcon ignores update with update and refresh provided together
ctx.run_type().execute(&sudo).arg(&pkcon).arg("refresh").check_run()?;
let mut exe = ctx.run_type().execute(&sudo);
let cmd = exe.arg(&pkcon).arg("update");
if ctx.config().yes(Step::System) {
cmd.arg("-y");
}
if ctx.config().cleanup() {
cmd.arg("--autoremove");
}
// from pkcon man, exit code 5 is 'Nothing useful was done.'
cmd.check_run_with_codes(&[5])?;
}
Ok(())
}
pub fn run_needrestart(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
2020-08-21 23:04:36 +03:00
let sudo = require_option(sudo, String::from("sudo is not installed"))?;
2019-02-11 14:10:06 +02:00
let needrestart = require("needrestart")?;
let distribution = Distribution::detect()?;
if distribution.redhat_based() {
2020-08-21 23:04:36 +03:00
return Err(SkipStep(String::from("needrestart will be ran by the package manager")).into());
}
2018-06-28 12:16:54 +03:00
2019-02-11 14:10:06 +02:00
print_separator("Check for needed restarts");
2018-06-28 12:16:54 +03:00
2019-02-11 14:10:06 +02:00
run_type.execute(&sudo).arg(needrestart).check_run()?;
2018-08-19 14:45:23 +03:00
2019-02-11 14:10:06 +02:00
Ok(())
2018-06-28 12:16:54 +03:00
}
pub fn run_fwupdmgr(ctx: &ExecutionContext) -> Result<()> {
2019-02-25 15:10:28 +02:00
let fwupdmgr = require("fwupdmgr")?;
2020-06-11 19:11:57 +03:00
if is_wsl()? {
2020-08-21 23:04:36 +03:00
return Err(SkipStep(String::from("Should not run in WSL")).into());
2020-06-11 19:11:57 +03:00
}
2019-02-25 15:10:28 +02:00
print_separator("Firmware upgrades");
2018-08-19 14:45:23 +03:00
ctx.run_type()
.execute(&fwupdmgr)
.arg("refresh")
.check_run_with_codes(&[2])?;
let mut updmgr = ctx.run_type().execute(&fwupdmgr);
if ctx.config().firmware_upgrade() {
updmgr.arg("update");
if ctx.config().yes(Step::System) {
updmgr.arg("-y");
}
} else {
updmgr.arg("get-updates");
}
updmgr.check_run_with_codes(&[2])
2018-06-28 12:16:54 +03:00
}
pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
2019-02-25 15:10:28 +02:00
let flatpak = require("flatpak")?;
let sudo = require_option(ctx.sudo().as_ref(), String::from("sudo is not installed"))?;
let cleanup = ctx.config().cleanup();
let run_type = ctx.run_type();
2019-02-25 15:10:28 +02:00
print_separator("Flatpak User Packages");
run_type
.execute(&flatpak)
2021-10-28 22:05:35 +03:00
.args(&["update", "--user", "-y"])
2019-02-25 15:10:28 +02:00
.check_run()?;
if cleanup {
run_type
.execute(&flatpak)
.args(&["uninstall", "--user", "--unused"])
.check_run()?;
}
print_separator("Flatpak System Packages");
if ctx.config().flatpak_use_sudo() || std::env::var("SSH_CLIENT").is_ok() {
run_type
.execute(&sudo)
.arg(&flatpak)
2021-10-28 22:05:35 +03:00
.args(&["update", "--system", "-y"])
.check_run()?;
if cleanup {
run_type
.execute(sudo)
.arg(flatpak)
.args(&["uninstall", "--system", "--unused"])
.check_run()?;
}
} else {
run_type
.execute(&flatpak)
2021-10-28 22:05:35 +03:00
.args(&["update", "--system", "-y"])
.check_run()?;
if cleanup {
run_type
.execute(flatpak)
.args(&["uninstall", "--system", "--unused"])
.check_run()?;
}
}
Ok(())
}
pub fn run_snap(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
2020-08-21 23:04:36 +03:00
let sudo = require_option(sudo, String::from("sudo is not installed"))?;
2019-02-25 15:10:28 +02:00
let snap = require("snap")?;
2019-09-10 22:59:08 +03:00
if !PathBuf::from("/var/snapd.socket").exists() && !PathBuf::from("/run/snapd.socket").exists() {
2020-08-21 23:04:36 +03:00
return Err(SkipStep(String::from("Snapd socket does not exist")).into());
2018-08-19 14:45:23 +03:00
}
2019-02-25 15:10:28 +02:00
print_separator("snap");
2018-08-19 14:45:23 +03:00
run_type.execute(sudo).arg(snap).arg("refresh").check_run()
2018-06-28 12:16:54 +03:00
}
2018-10-02 13:25:02 +03:00
pub fn run_pihole_update(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
2020-08-21 23:04:36 +03:00
let sudo = require_option(sudo, String::from("sudo is not installed"))?;
let pihole = require("pihole")?;
Path::new("/opt/pihole/update.sh").require()?;
print_separator("pihole");
run_type.execute(sudo).arg(pihole).arg("-up").check_run()
}
pub fn run_config_update(ctx: &ExecutionContext) -> Result<()> {
let sudo = require_option(ctx.sudo().as_ref(), String::from("sudo is not installed"))?;
if ctx.config().yes(Step::ConfigUpdate) {
return Err(SkipStep("Skipped in --yes".to_string()).into());
}
2018-10-02 13:25:02 +03:00
2021-12-18 20:20:00 +02:00
if let Ok(etc_update) = require("etc-update") {
print_separator("Configuration update");
ctx.run_type().execute(sudo).arg(etc_update).check_run()?;
2021-12-18 20:20:00 +02:00
} else if let Ok(pacdiff) = require("pacdiff") {
if std::env::var("DIFFPROG").is_err() {
require("vim")?;
}
2021-11-06 19:55:38 +01:00
2021-12-18 20:20:00 +02:00
print_separator("Configuration update");
ctx.execute_elevated(&pacdiff, false)?.check_run()?;
2021-12-18 20:20:00 +02:00
}
2021-11-06 19:55:38 +01:00
2021-12-18 20:20:00 +02:00
Ok(())
2021-11-06 19:55:38 +01:00
}
#[cfg(test)]
mod tests {
use super::*;
fn test_template(os_release_file: &str, expected_distribution: Distribution) {
let os_release = Ini::load_from_str(os_release_file).unwrap();
assert_eq!(
Distribution::parse_os_release(&os_release).unwrap(),
expected_distribution
);
}
#[test]
fn test_arch_linux() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/arch"), Distribution::Arch);
test_template(include_str!("os_release/arch32"), Distribution::Arch);
}
#[test]
fn test_centos() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/centos"), Distribution::CentOS);
}
2020-03-13 06:48:46 -04:00
#[test]
fn test_rhel() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/rhel"), Distribution::CentOS);
2020-03-13 06:48:46 -04:00
}
#[test]
fn test_clearlinux() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/clearlinux"), Distribution::ClearLinux);
}
#[test]
fn test_debian() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/debian"), Distribution::Debian);
}
#[test]
fn test_ubuntu() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/ubuntu"), Distribution::Debian);
}
#[test]
fn test_mint() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/mint"), Distribution::Debian);
}
#[test]
fn test_opensuse() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/opensuse"), Distribution::Suse);
}
#[test]
fn test_oraclelinux() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/oracle"), Distribution::CentOS);
}
#[test]
fn test_fedora() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/fedora"), Distribution::Fedora);
}
#[test]
fn test_antergos() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/antergos"), Distribution::Arch);
}
#[test]
fn test_manjaro() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/manjaro"), Distribution::Arch);
}
#[test]
fn test_manjaro_arm() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/manjaro-arm"), Distribution::Arch);
}
#[test]
fn test_anarchy() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/anarchy"), Distribution::Arch);
}
#[test]
fn test_gentoo() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/gentoo"), Distribution::Gentoo);
}
#[test]
fn test_exherbo() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/exherbo"), Distribution::Exherbo);
}
2020-03-26 17:07:48 +02:00
#[test]
fn test_amazon_linux() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/amazon_linux"), Distribution::CentOS);
2020-03-26 17:07:48 +02:00
}
#[test]
fn test_nixos() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/nixos"), Distribution::NixOS);
}
#[test]
fn test_fedoraremixonwsl() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/fedoraremixforwsl"), Distribution::Fedora);
}
#[test]
fn test_pengwinonwsl() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/pengwinonwsl"), Distribution::Debian);
}
#[test]
fn test_artix() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/artix"), Distribution::Arch);
}
2020-08-29 07:24:00 +03:00
#[test]
fn test_garuda() {
2021-09-02 13:04:30 +00:00
test_template(include_str!("os_release/garuda"), Distribution::Arch);
2020-08-29 07:24:00 +03:00
}
2021-10-15 06:15:38 +03:00
#[test]
fn test_pureos() {
test_template(include_str!("os_release/pureos"), Distribution::Debian);
}
}