os: add support for Exherbo (#202)

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
This commit is contained in:
Marc-Antoine Perennou
2019-08-22 19:49:12 +02:00
committed by Roey Darwish Dror
parent fda52486b3
commit 110eecede1
2 changed files with 47 additions and 0 deletions

View File

@@ -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<PathBuf>, run_type: RunType) -> Result<(), Error>
Ok(())
}
fn upgrade_exherbo(sudo: &Option<PathBuf>, 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);
}
}

View File

@@ -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/"