From 110eecede16afc70b28c51f1508be79da7b454c9 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Thu, 22 Aug 2019 19:49:12 +0200 Subject: [PATCH] os: add support for Exherbo (#202) Signed-off-by: Marc-Antoine Perennou --- src/steps/os/linux.rs | 40 +++++++++++++++++++++++++++++++++ src/steps/os/os_release/exherbo | 7 ++++++ 2 files changed, 47 insertions(+) create mode 100644 src/steps/os/os_release/exherbo diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index ecdb1515..da04f680 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -30,6 +30,7 @@ pub enum Distribution { Suse, Void, Solus, + Exherbo, } impl Distribution { @@ -50,6 +51,7 @@ impl Distribution { (Some("void"), _) => Distribution::Void, (Some("solus"), _) => Distribution::Solus, (Some("gentoo"), _) => Distribution::Gentoo, + (Some("exherbo"), _) => Distribution::Exherbo, _ => Err(ErrorKind::UnknownLinuxDistribution)?, }) } @@ -77,6 +79,7 @@ impl Distribution { Distribution::Suse => upgrade_suse(&sudo, run_type), Distribution::Void => upgrade_void(&sudo, run_type), Distribution::Solus => upgrade_solus(&sudo, run_type), + Distribution::Exherbo => upgrade_exherbo(&sudo, cleanup, run_type), } } @@ -260,6 +263,38 @@ fn upgrade_solus(sudo: &Option, run_type: RunType) -> Result<(), Error> Ok(()) } +fn upgrade_exherbo(sudo: &Option, cleanup: bool, run_type: RunType) -> Result<(), Error> { + if let Some(sudo) = &sudo { + run_type.execute(&sudo).args(&["/usr/bin/cave", "sync"]).check_run()?; + + run_type + .execute(&sudo) + .args(&["/usr/bin/cave", "resolve", "world", "-c1", "-Cs", "-km", "-Km", "-x"]) + .check_run()?; + + if cleanup { + run_type + .execute(&sudo) + .args(&["/usr/bin/cave", "purge", "-x"]) + .check_run()?; + } + + run_type + .execute(&sudo) + .args(&["/usr/bin/cave", "fix-linkage", "-x", "--", "-Cs"]) + .check_run()?; + + run_type + .execute(&sudo) + .args(&["/usr/bin/eclectic", "config", "interactive"]) + .check_run()?; + } else { + print_warning("No sudo detected. Skipping system upgrade"); + } + + Ok(()) +} + pub fn run_needrestart(sudo: Option<&PathBuf>, run_type: RunType) -> Result<(), Error> { let sudo = require_option(sudo)?; let needrestart = require("needrestart")?; @@ -409,4 +444,9 @@ mod tests { fn test_gentoo() { test_template(&include_str!("os_release/gentoo"), Distribution::Gentoo); } + + #[test] + fn test_exherbo() { + test_template(&include_str!("os_release/exherbo"), Distribution::Exherbo); + } } diff --git a/src/steps/os/os_release/exherbo b/src/steps/os/os_release/exherbo new file mode 100644 index 00000000..944c9b44 --- /dev/null +++ b/src/steps/os/os_release/exherbo @@ -0,0 +1,7 @@ +NAME="Exherbo" +PRETTY_NAME="Exherbo Linux" +ID="exherbo" +ANSI_COLOR="0;32" +HOME_URL="https://www.exherbo.org/" +SUPPORT_URL="irc://irc.freenode.net/#exherbo" +BUG_REPORT_URL="https://bugs.exherbo.org/"