2019-12-11 23:05:38 +02:00
|
|
|
use crate::error::{SkipStep, TopgradeError};
|
2020-05-14 09:22:14 +03:00
|
|
|
use crate::execution_context::ExecutionContext;
|
2021-03-23 06:33:30 +02:00
|
|
|
use crate::executor::{CommandExt, RunType};
|
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};
|
2019-12-11 23:05:38 +02:00
|
|
|
use anyhow::Result;
|
2019-05-16 15:29:35 +03:00
|
|
|
use ini::Ini;
|
2019-08-15 09:15:35 +03:00
|
|
|
use log::debug;
|
2019-05-07 16:21:51 +03:00
|
|
|
use serde::Deserialize;
|
2019-08-15 09:15:35 +03:00
|
|
|
use std::env::var_os;
|
|
|
|
|
use std::ffi::OsString;
|
2019-09-28 20:26:03 +03:00
|
|
|
use std::path::{Path, PathBuf};
|
2020-06-11 19:11:57 +03:00
|
|
|
use std::process::Command;
|
2018-10-02 11:36:10 +03:00
|
|
|
use walkdir::WalkDir;
|
2018-06-07 16:19:11 +03:00
|
|
|
|
2019-05-07 16:21:51 +03:00
|
|
|
static OS_RELEASE_PATH: &str = "/etc/os-release";
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
|
#[serde(rename_all = "UPPERCASE")]
|
|
|
|
|
struct OsRelease {
|
|
|
|
|
id_like: Option<String>,
|
|
|
|
|
id: String,
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-06 10:28:07 +03:00
|
|
|
#[allow(clippy::upper_case_acronyms)]
|
2019-05-14 15:25:50 +03:00
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
2018-06-07 16:19:11 +03:00
|
|
|
pub enum Distribution {
|
2021-07-06 09:24:42 +03:00
|
|
|
Alpine,
|
2018-06-07 16:19:11 +03:00
|
|
|
Arch,
|
|
|
|
|
CentOS,
|
2019-11-13 12:18:42 +00:00
|
|
|
ClearLinux,
|
2018-06-07 16:19:11 +03:00
|
|
|
Fedora,
|
|
|
|
|
Debian,
|
2018-10-21 15:08:36 +03:00
|
|
|
Gentoo,
|
2019-05-07 16:21:51 +03:00
|
|
|
Suse,
|
2018-11-20 14:38:23 +02:00
|
|
|
Void,
|
2019-03-21 10:36:40 -07:00
|
|
|
Solus,
|
2019-08-22 19:49:12 +02:00
|
|
|
Exherbo,
|
2019-11-11 22:16:40 +02:00
|
|
|
NixOS,
|
2021-04-07 13:04:21 -07:00
|
|
|
KDENeon,
|
2018-06-07 16:19:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Distribution {
|
2019-12-11 23:05:38 +02:00
|
|
|
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-09-04 20:01:19 +02:00
|
|
|
Some("centos" | "rhel" | "ol") => Distribution::CentOS,
|
2019-11-13 12:18:42 +00:00
|
|
|
Some("clear-linux-os") => Distribution::ClearLinux,
|
2019-09-05 21:04:07 +03:00
|
|
|
Some("fedora") => Distribution::Fedora,
|
|
|
|
|
Some("void") => Distribution::Void,
|
2021-10-15 06:15:38 +03:00
|
|
|
Some("debian" | "pureos") => Distribution::Debian,
|
2021-09-04 20:01:19 +02:00
|
|
|
Some("arch" | "anarchy" | "manjaro-arm" | "garuda" | "artix") => Distribution::Arch,
|
2019-09-05 21:04:07 +03:00
|
|
|
Some("solus") => Distribution::Solus,
|
|
|
|
|
Some("gentoo") => Distribution::Gentoo,
|
|
|
|
|
Some("exherbo") => Distribution::Exherbo,
|
2019-11-11 22:16:40 +02:00
|
|
|
Some("nixos") => Distribution::NixOS,
|
2021-04-07 13:04:21 -07:00
|
|
|
Some("neon") => Distribution::KDENeon,
|
2020-06-15 14:33:28 +02:00
|
|
|
_ => {
|
|
|
|
|
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);
|
2021-10-14 05:23:39 -04:00
|
|
|
} else if id_like.contains(&"alpine") {
|
|
|
|
|
return Ok(Distribution::Alpine);
|
2020-06-15 14:33:28 +02:00
|
|
|
} else if id_like.contains(&"fedora") {
|
|
|
|
|
return Ok(Distribution::Fedora);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Err(TopgradeError::UnknownLinuxDistribution.into());
|
|
|
|
|
}
|
2019-05-16 15:29:35 +03:00
|
|
|
})
|
2019-05-07 16:21:51 +03:00
|
|
|
}
|
2019-03-21 10:36:40 -07:00
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
pub fn detect() -> Result<Self> {
|
2019-05-07 16:21:51 +03:00
|
|
|
if PathBuf::from(OS_RELEASE_PATH).exists() {
|
2019-12-11 23:05:38 +02:00
|
|
|
let os_release = Ini::load_from_file(OS_RELEASE_PATH)?;
|
2019-05-14 15:25:50 +03:00
|
|
|
|
|
|
|
|
return Self::parse_os_release(&os_release);
|
2019-04-14 11:25:40 +03:00
|
|
|
}
|
|
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
Err(TopgradeError::UnknownLinuxDistribution.into())
|
2018-06-07 16:19:11 +03:00
|
|
|
}
|
2018-10-02 10:46:38 +03:00
|
|
|
|
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-10-03 08:12:43 +03:00
|
|
|
|
2019-02-11 14:10:06 +02:00
|
|
|
match self {
|
2021-07-06 09:24:42 +03:00
|
|
|
Distribution::Alpine => upgrade_alpine_linux(ctx),
|
2020-05-15 21:10:01 +03:00
|
|
|
Distribution::Arch => 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),
|
2020-06-19 10:34:45 +03:00
|
|
|
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),
|
2021-04-07 13:04:21 -07:00
|
|
|
Distribution::KDENeon => upgrade_neon(ctx),
|
2019-02-11 14:10:06 +02:00
|
|
|
}
|
2018-10-02 10:46:38 +03:00
|
|
|
}
|
2018-10-02 11:36:10 +03:00
|
|
|
|
|
|
|
|
pub fn show_summary(self) {
|
|
|
|
|
if let Distribution::Arch = self {
|
|
|
|
|
show_pacnew();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-30 08:15:35 +03:00
|
|
|
|
|
|
|
|
pub fn redhat_based(self) -> bool {
|
2020-10-24 14:46:38 -05:00
|
|
|
matches!(self, Distribution::CentOS | Distribution::Fedora)
|
2020-07-30 08:15:35 +03:00
|
|
|
}
|
2018-10-02 11:36:10 +03:00
|
|
|
}
|
|
|
|
|
|
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"))
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 11:36:10 +03:00
|
|
|
pub fn show_pacnew() {
|
|
|
|
|
let mut iter = WalkDir::new("/etc")
|
|
|
|
|
.into_iter()
|
2019-04-14 11:35:18 +03:00
|
|
|
.filter_map(Result::ok)
|
2018-10-02 11:36:10 +03:00
|
|
|
.filter(|f| {
|
|
|
|
|
f.path()
|
|
|
|
|
.extension()
|
|
|
|
|
.filter(|ext| ext == &"pacnew" || ext == &"pacsave")
|
|
|
|
|
.is_some()
|
2018-12-11 16:00:19 +02:00
|
|
|
})
|
|
|
|
|
.peekable();
|
2018-10-02 11:36:10 +03:00
|
|
|
|
|
|
|
|
if iter.peek().is_some() {
|
|
|
|
|
println!("\nPacman backup configuration files found:");
|
|
|
|
|
|
|
|
|
|
for entry in iter {
|
|
|
|
|
println!("{}", entry.path().display());
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-07 16:19:11 +03:00
|
|
|
}
|
2018-06-12 21:28:32 +03:00
|
|
|
|
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-15 21:10:01 +03:00
|
|
|
fn upgrade_arch_linux(ctx: &ExecutionContext) -> Result<()> {
|
2019-07-15 11:09:13 +03:00
|
|
|
let pacman = which("powerpill").unwrap_or_else(|| PathBuf::from("/usr/bin/pacman"));
|
2020-05-15 21:10:01 +03:00
|
|
|
let yes = ctx.config().yes();
|
|
|
|
|
let sudo = ctx.sudo();
|
|
|
|
|
let run_type = ctx.run_type();
|
|
|
|
|
let cleanup = ctx.config().cleanup();
|
2019-07-15 09:40:12 +03:00
|
|
|
|
2019-08-15 09:15:35 +03:00
|
|
|
let path = {
|
|
|
|
|
let mut path = OsString::from("/usr/bin:");
|
|
|
|
|
path.push(var_os("PATH").unwrap());
|
|
|
|
|
path
|
|
|
|
|
};
|
|
|
|
|
debug!("Running Arch update with path: {:?}", path);
|
|
|
|
|
|
2021-02-10 17:32:15 +01:00
|
|
|
let yay = which("yay");
|
|
|
|
|
if let Some(yay) = &yay {
|
2019-10-07 20:18:11 +03:00
|
|
|
run_type
|
|
|
|
|
.execute(&yay)
|
|
|
|
|
.arg("-Pw")
|
|
|
|
|
.spawn()
|
|
|
|
|
.and_then(|mut p| p.wait())
|
|
|
|
|
.ok();
|
2021-02-10 17:32:15 +01:00
|
|
|
}
|
2019-10-07 20:18:11 +03:00
|
|
|
|
2021-02-10 17:32:15 +01:00
|
|
|
if let Some(yay) = yay.or_else(|| which("paru")) {
|
2019-11-20 09:10:15 +02:00
|
|
|
let mut command = run_type.execute(&yay);
|
2019-09-28 15:45:05 +03:00
|
|
|
|
|
|
|
|
command
|
2019-07-15 09:40:12 +03:00
|
|
|
.arg("--pacman")
|
2019-11-20 09:10:15 +02:00
|
|
|
.arg(&pacman)
|
2019-07-15 09:40:12 +03:00
|
|
|
.arg("-Syu")
|
2020-05-15 21:10:01 +03:00
|
|
|
.args(ctx.config().yay_arguments().split_whitespace())
|
2019-09-28 15:45:05 +03:00
|
|
|
.env("PATH", path);
|
|
|
|
|
|
|
|
|
|
if yes {
|
|
|
|
|
command.arg("--noconfirm");
|
|
|
|
|
}
|
|
|
|
|
command.check_run()?;
|
2019-11-20 09:10:15 +02:00
|
|
|
|
|
|
|
|
if cleanup {
|
|
|
|
|
let mut command = run_type.execute(&yay);
|
|
|
|
|
command.arg("--pacman").arg(&pacman).arg("-Scc");
|
|
|
|
|
if yes {
|
|
|
|
|
command.arg("--noconfirm");
|
|
|
|
|
}
|
|
|
|
|
command.check_run()?;
|
|
|
|
|
}
|
2020-05-15 21:10:01 +03:00
|
|
|
} else if let Some(trizen) = which("trizen") {
|
|
|
|
|
let mut command = run_type.execute(&trizen);
|
|
|
|
|
|
|
|
|
|
command
|
|
|
|
|
.arg("-Syu")
|
|
|
|
|
.args(ctx.config().trizen_arguments().split_whitespace())
|
|
|
|
|
.env("PATH", path);
|
|
|
|
|
|
|
|
|
|
if yes {
|
|
|
|
|
command.arg("--noconfirm");
|
|
|
|
|
}
|
|
|
|
|
command.check_run()?;
|
|
|
|
|
|
|
|
|
|
if cleanup {
|
|
|
|
|
let mut command = run_type.execute(&trizen);
|
|
|
|
|
command.arg("-Sc");
|
|
|
|
|
if yes {
|
|
|
|
|
command.arg("--noconfirm");
|
|
|
|
|
}
|
|
|
|
|
command.check_run()?;
|
|
|
|
|
}
|
2018-07-10 07:29:41 +03:00
|
|
|
} else if let Some(sudo) = &sudo {
|
2019-09-28 15:45:05 +03:00
|
|
|
let mut command = run_type.execute(&sudo);
|
2019-11-20 09:10:15 +02:00
|
|
|
command.arg(&pacman).arg("-Syu").env("PATH", path);
|
2019-09-28 15:45:05 +03:00
|
|
|
if yes {
|
|
|
|
|
command.arg("--noconfirm");
|
|
|
|
|
}
|
|
|
|
|
command.check_run()?;
|
2018-06-12 21:28:32 +03:00
|
|
|
|
2019-11-20 09:10:15 +02:00
|
|
|
if cleanup {
|
|
|
|
|
let mut command = run_type.execute(&sudo);
|
|
|
|
|
command.arg(&pacman).arg("-Scc");
|
|
|
|
|
if yes {
|
|
|
|
|
command.arg("--noconfirm");
|
|
|
|
|
}
|
|
|
|
|
command.check_run()?;
|
2018-12-23 10:47:45 +02:00
|
|
|
}
|
2019-11-20 09:10:15 +02:00
|
|
|
} else {
|
|
|
|
|
print_warning("Neither sudo nor yay detected. Skipping system upgrade");
|
2018-12-23 10:47:45 +02:00
|
|
|
}
|
|
|
|
|
|
2018-06-12 21:28:32 +03:00
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-14 09:22:14 +03:00
|
|
|
fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
|
2021-05-13 14:57:29 -04:00
|
|
|
let _ = if let Some(ostree) = Path::new("/usr/bin/rpm-ostree").if_exists() {
|
|
|
|
|
if ctx.config().rpm_ostree() {
|
|
|
|
|
let mut command = ctx.run_type().execute(ostree);
|
|
|
|
|
command.arg("upgrade");
|
|
|
|
|
if ctx.config().yes() {
|
|
|
|
|
command.arg("-y");
|
|
|
|
|
}
|
2020-07-21 10:05:57 +03:00
|
|
|
|
2021-05-13 14:57:29 -04:00
|
|
|
return command.check_run();
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-07-21 10:05:57 +03:00
|
|
|
|
2020-05-14 09:22:14 +03:00
|
|
|
if let Some(sudo) = &ctx.sudo() {
|
|
|
|
|
let mut command = ctx.run_type().execute(&sudo);
|
2020-12-21 09:45:28 +02:00
|
|
|
command
|
|
|
|
|
.arg(
|
|
|
|
|
Path::new("/usr/bin/dnf-3")
|
|
|
|
|
.if_exists()
|
|
|
|
|
.unwrap_or_else(|| Path::new("/usr/bin/yum")),
|
|
|
|
|
)
|
2020-12-26 09:17:54 +02:00
|
|
|
.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() {
|
2019-09-28 15:45:05 +03: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-11-03 22:57:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-02 17:09:48 +00:00
|
|
|
fn upgrade_suse(ctx: &ExecutionContext) -> Result<()> {
|
|
|
|
|
if let Some(sudo) = ctx.sudo() {
|
|
|
|
|
ctx.run_type()
|
2018-12-31 13:26:17 +02:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/zypper", "refresh"])
|
2018-12-31 22:00:34 +02:00
|
|
|
.check_run()?;
|
2018-11-03 22:57:09 +02:00
|
|
|
|
2021-09-02 17:09:48 +00:00
|
|
|
ctx.run_type()
|
2018-12-31 13:26:17 +02:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/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() {
|
|
|
|
|
ctx.run_type()
|
2020-02-17 06:18:38 +00:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/xbps-install", "-Su", "xbps"])
|
2020-02-17 06:18:38 +00:00
|
|
|
.check_run()?;
|
|
|
|
|
|
2021-09-02 17:09:48 +00:00
|
|
|
ctx.run_type()
|
2020-02-17 06:18:38 +00:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/xbps-install", "-u"])
|
2020-02-17 06:18:38 +00:00
|
|
|
.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(())
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-19 10:34:45 +03:00
|
|
|
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-09-04 20:01:19 +02:00
|
|
|
run_type.execute(&sudo).arg(layman).args(["-s", "ALL"]).check_run()?;
|
2018-10-21 15:08:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
println!("Syncing portage");
|
2018-12-31 13:26:17 +02:00
|
|
|
run_type
|
|
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/emerge", "--sync"])
|
2020-06-19 10:34:45 +03:00
|
|
|
.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
|
|
|
}
|
|
|
|
|
|
2018-12-31 13:26:17 +02:00
|
|
|
run_type
|
|
|
|
|
.execute(&sudo)
|
2018-10-21 15:08:36 +03:00
|
|
|
.arg("/usr/bin/emerge")
|
2020-06-19 10:34:45 +03:00
|
|
|
.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() {
|
2021-01-12 21:08:40 +02:00
|
|
|
let apt = which("apt-fast").unwrap_or_else(|| PathBuf::from("/usr/bin/apt-get"));
|
2021-04-06 10:54:23 +03:00
|
|
|
ctx.run_type().execute(&sudo).arg(&apt).arg("update").check_run()?;
|
2019-09-28 15:45:05 +03:00
|
|
|
|
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");
|
2021-04-06 10:54:23 +03:00
|
|
|
if ctx.config().yes() {
|
2019-09-28 15:45:05 +03:00
|
|
|
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()?;
|
2018-12-16 23:22:59 -08:00
|
|
|
|
2021-04-06 10:54:23 +03:00
|
|
|
if ctx.config().cleanup() {
|
|
|
|
|
ctx.run_type().execute(&sudo).arg(&apt).arg("clean").check_run()?;
|
2018-12-16 23:22:59 -08:00
|
|
|
|
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");
|
2021-04-06 10:54:23 +03:00
|
|
|
if ctx.config().yes() {
|
2019-11-20 09:09:10 +02:00
|
|
|
command.arg("-y");
|
|
|
|
|
}
|
|
|
|
|
command.check_run()?;
|
2018-12-16 23:22:59 -08:00
|
|
|
}
|
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() {
|
|
|
|
|
ctx.run_type()
|
2019-03-21 13:10:54 -07:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/eopkg", "upgrade"])
|
2019-03-21 13:10:54 -07:00
|
|
|
.check_run()?;
|
2019-03-21 10:36:40 -07:00
|
|
|
} else {
|
|
|
|
|
print_warning("No sudo detected. Skipping system upgrade");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-02 17:09:48 +00:00
|
|
|
fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
|
|
|
|
|
if let Some(sudo) = &ctx.sudo() {
|
|
|
|
|
ctx.run_type()
|
2019-11-13 12:18:42 +00:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/swupd", "update"])
|
2019-11-13 12:18:42 +00:00
|
|
|
.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() {
|
|
|
|
|
ctx.run_type()
|
|
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/cave", "sync"])
|
2021-09-02 17:09:48 +00:00
|
|
|
.check_run()?;
|
2019-08-22 19:49:12 +02:00
|
|
|
|
2021-09-02 17:09:48 +00:00
|
|
|
ctx.run_type()
|
2019-08-22 19:49:12 +02:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/cave", "resolve", "world", "-c1", "-Cs", "-km", "-Km", "-x"])
|
2019-08-22 19:49:12 +02:00
|
|
|
.check_run()?;
|
|
|
|
|
|
2021-09-02 17:09:48 +00:00
|
|
|
if ctx.config().cleanup() {
|
|
|
|
|
ctx.run_type()
|
2019-08-22 19:49:12 +02:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/cave", "purge", "-x"])
|
2019-08-22 19:49:12 +02:00
|
|
|
.check_run()?;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-02 17:09:48 +00:00
|
|
|
ctx.run_type()
|
2019-08-22 19:49:12 +02:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/cave", "fix-linkage", "-x", "--", "-Cs"])
|
2019-08-22 19:49:12 +02:00
|
|
|
.check_run()?;
|
|
|
|
|
|
2021-09-02 17:09:48 +00:00
|
|
|
ctx.run_type()
|
2019-08-22 19:49:12 +02:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/usr/bin/eclectic", "config", "interactive"])
|
2019-08-22 19:49:12 +02:00
|
|
|
.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()
|
2019-11-11 22:16:40 +02:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/run/current-system/sw/bin/nixos-rebuild", "switch", "--upgrade"])
|
2019-11-11 22:16:40 +02:00
|
|
|
.check_run()?;
|
|
|
|
|
|
2021-09-02 17:09:48 +00:00
|
|
|
if ctx.config().cleanup() {
|
|
|
|
|
ctx.run_type()
|
2019-11-11 22:16:40 +02:00
|
|
|
.execute(&sudo)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["/run/current-system/sw/bin/nix-collect-garbage", "-d"])
|
2019-11-11 22:16:40 +02:00
|
|
|
.check_run()?;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
print_warning("No sudo detected. Skipping system upgrade");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-07 13:04:21 -07:00
|
|
|
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() {
|
|
|
|
|
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(())
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
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")?;
|
2020-07-30 08:15:35 +03:00
|
|
|
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());
|
2020-07-30 08:15:35 +03:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2021-03-23 06:33:30 +02: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
|
|
|
|
2021-03-23 06:33:30 +02:00
|
|
|
ctx.run_type()
|
|
|
|
|
.execute(&fwupdmgr)
|
|
|
|
|
.arg("refresh")
|
|
|
|
|
.check_run_with_codes(&[2])?;
|
2019-11-04 22:49:22 +02:00
|
|
|
|
2021-06-30 11:15:18 +02:00
|
|
|
let mut updmgr = ctx.run_type().execute(&fwupdmgr);
|
2019-11-04 22:49:22 +02:00
|
|
|
|
2021-06-30 11:15:18 +02:00
|
|
|
if ctx.config().firmware_upgrade() {
|
|
|
|
|
updmgr.arg("update");
|
|
|
|
|
if ctx.config().yes() {
|
|
|
|
|
updmgr.arg("-y");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
updmgr.arg("get-updates");
|
2021-03-23 06:33:30 +02:00
|
|
|
}
|
2021-06-30 11:15:18 +02:00
|
|
|
updmgr.check_run_with_codes(&[2])
|
2018-06-28 12:16:54 +03:00
|
|
|
}
|
|
|
|
|
|
2021-06-30 12:37:41 +02:00
|
|
|
pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
|
2019-02-25 15:10:28 +02:00
|
|
|
let flatpak = require("flatpak")?;
|
2021-06-30 12:37:41 +02:00
|
|
|
let sudo = require_option(ctx.sudo().as_ref(), String::from("sudo is not installed"))?;
|
|
|
|
|
let run_type = ctx.run_type();
|
2019-02-25 15:10:28 +02:00
|
|
|
print_separator("Flatpak User Packages");
|
|
|
|
|
|
|
|
|
|
run_type
|
|
|
|
|
.execute(&flatpak)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["update", "--user", "-y"])
|
2019-02-25 15:10:28 +02:00
|
|
|
.check_run()?;
|
2021-06-30 12:37:41 +02:00
|
|
|
|
|
|
|
|
print_separator("Flatpak System Packages");
|
2021-07-06 09:32:14 +03:00
|
|
|
if ctx.config().flatpak_use_sudo() || std::env::var("SSH_CLIENT").is_ok() {
|
2021-06-30 12:37:41 +02:00
|
|
|
run_type
|
|
|
|
|
.execute(sudo)
|
|
|
|
|
.arg(flatpak)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["update", "--system", "-y"])
|
2021-06-30 12:37:41 +02:00
|
|
|
.check_run()
|
|
|
|
|
} else {
|
|
|
|
|
run_type
|
|
|
|
|
.execute(&flatpak)
|
2021-09-04 20:01:19 +02:00
|
|
|
.args(["update", "--system", "-y"])
|
2021-06-30 12:37:41 +02:00
|
|
|
.check_run()
|
|
|
|
|
}
|
2018-10-02 14:30:10 +03:00
|
|
|
}
|
|
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
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
|
|
|
|
2019-05-15 10:59:05 +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
|
|
|
|
2019-12-11 23:05:38 +02: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"))?;
|
2019-05-15 12:08:15 +02:00
|
|
|
let pihole = require("pihole")?;
|
2020-03-17 15:11:53 +02:00
|
|
|
Path::new("/opt/pihole/update.sh").require()?;
|
2019-05-15 12:08:15 +02:00
|
|
|
|
|
|
|
|
print_separator("pihole");
|
|
|
|
|
|
|
|
|
|
run_type.execute(sudo).arg(pihole).arg("-up").check_run()
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
pub fn run_etc_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"))?;
|
2019-06-02 08:46:02 +03:00
|
|
|
let etc_update = require("etc-update")?;
|
2019-02-25 15:10:28 +02:00
|
|
|
print_separator("etc-update");
|
2018-10-02 13:25:02 +03:00
|
|
|
|
2019-05-15 10:59:05 +03:00
|
|
|
run_type.execute(sudo).arg(etc_update).check_run()
|
2018-10-02 13:25:02 +03:00
|
|
|
}
|
2019-05-14 15:25:50 +03:00
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
fn test_template(os_release_file: &str, expected_distribution: Distribution) {
|
2019-05-16 15:29:35 +03:00
|
|
|
let os_release = Ini::load_from_str(os_release_file).unwrap();
|
2019-05-14 15:25:50 +03:00
|
|
|
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);
|
2019-05-14 15:25:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_centos() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/centos"), Distribution::CentOS);
|
2019-05-14 15:25:50 +03:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2019-11-13 12:18:42 +00:00
|
|
|
#[test]
|
|
|
|
|
fn test_clearlinux() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/clearlinux"), Distribution::ClearLinux);
|
2019-11-13 12:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-14 15:25:50 +03:00
|
|
|
#[test]
|
|
|
|
|
fn test_debian() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/debian"), Distribution::Debian);
|
2019-05-14 15:25:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_ubuntu() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/ubuntu"), Distribution::Debian);
|
2019-05-14 15:25:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_mint() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/mint"), Distribution::Debian);
|
2019-05-14 15:25:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_opensuse() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/opensuse"), Distribution::Suse);
|
2019-05-14 15:25:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_oraclelinux() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/oracle"), Distribution::CentOS);
|
2019-05-14 15:25:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_fedora() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/fedora"), Distribution::Fedora);
|
2019-05-14 15:25:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_antergos() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/antergos"), Distribution::Arch);
|
2019-05-14 15:25:50 +03:00
|
|
|
}
|
2019-05-16 13:38:00 +02:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_manjaro() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/manjaro"), Distribution::Arch);
|
2019-05-16 13:38:00 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-17 00:19:28 -06:00
|
|
|
#[test]
|
|
|
|
|
fn test_manjaro_arm() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/manjaro-arm"), Distribution::Arch);
|
2020-02-17 00:19:28 -06:00
|
|
|
}
|
|
|
|
|
|
2019-07-10 11:51:39 +02:00
|
|
|
#[test]
|
|
|
|
|
fn test_anarchy() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/anarchy"), Distribution::Arch);
|
2019-07-10 11:51:39 +02:00
|
|
|
}
|
2019-08-14 14:34:46 +03:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_gentoo() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/gentoo"), Distribution::Gentoo);
|
2019-08-14 14:34:46 +03:00
|
|
|
}
|
2019-08-22 19:49:12 +02:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_exherbo() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/exherbo"), Distribution::Exherbo);
|
2019-08-22 19:49:12 +02:00
|
|
|
}
|
2019-11-11 22:16:40 +02:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2019-11-11 22:16:40 +02:00
|
|
|
#[test]
|
|
|
|
|
fn test_nixos() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/nixos"), Distribution::NixOS);
|
2019-11-11 22:16:40 +02:00
|
|
|
}
|
2020-06-15 14:33:28 +02:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_fedoraremixonwsl() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/fedoraremixforwsl"), Distribution::Fedora);
|
2020-06-15 14:33:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_pengwinonwsl() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/pengwinonwsl"), Distribution::Debian);
|
2020-06-15 14:33:28 +02:00
|
|
|
}
|
2020-08-27 21:21:12 +03:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_artix() {
|
2021-09-02 13:04:30 +00:00
|
|
|
test_template(include_str!("os_release/artix"), Distribution::Arch);
|
2020-08-27 21:21:12 +03:00
|
|
|
}
|
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);
|
|
|
|
|
}
|
2019-05-14 15:25:50 +03:00
|
|
|
}
|