Support Alpine Linux (fix #736(
This commit is contained in:
@@ -25,6 +25,7 @@ struct OsRelease {
|
|||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum Distribution {
|
pub enum Distribution {
|
||||||
|
Alpine,
|
||||||
Arch,
|
Arch,
|
||||||
CentOS,
|
CentOS,
|
||||||
ClearLinux,
|
ClearLinux,
|
||||||
@@ -46,6 +47,7 @@ impl Distribution {
|
|||||||
let id_like: Option<Vec<&str>> = section.get("ID_LIKE").map(|s| s.split_whitespace().collect());
|
let id_like: Option<Vec<&str>> = section.get("ID_LIKE").map(|s| s.split_whitespace().collect());
|
||||||
|
|
||||||
Ok(match id {
|
Ok(match id {
|
||||||
|
Some("alpine") => Distribution::Alpine,
|
||||||
Some("centos") | Some("rhel") | Some("ol") => Distribution::CentOS,
|
Some("centos") | Some("rhel") | Some("ol") => Distribution::CentOS,
|
||||||
Some("clear-linux-os") => Distribution::ClearLinux,
|
Some("clear-linux-os") => Distribution::ClearLinux,
|
||||||
Some("fedora") => Distribution::Fedora,
|
Some("fedora") => Distribution::Fedora,
|
||||||
@@ -93,6 +95,7 @@ impl Distribution {
|
|||||||
let cleanup = ctx.config().cleanup();
|
let cleanup = ctx.config().cleanup();
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
|
Distribution::Alpine => upgrade_alpine_linux(ctx),
|
||||||
Distribution::Arch => upgrade_arch_linux(ctx),
|
Distribution::Arch => upgrade_arch_linux(ctx),
|
||||||
Distribution::CentOS | Distribution::Fedora => upgrade_redhat(ctx),
|
Distribution::CentOS | Distribution::Fedora => upgrade_redhat(ctx),
|
||||||
Distribution::ClearLinux => upgrade_clearlinux(&sudo, run_type),
|
Distribution::ClearLinux => upgrade_clearlinux(&sudo, run_type),
|
||||||
@@ -145,6 +148,14 @@ pub fn show_pacnew() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
|
||||||
fn upgrade_arch_linux(ctx: &ExecutionContext) -> Result<()> {
|
fn upgrade_arch_linux(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let pacman = which("powerpill").unwrap_or_else(|| PathBuf::from("/usr/bin/pacman"));
|
let pacman = which("powerpill").unwrap_or_else(|| PathBuf::from("/usr/bin/pacman"));
|
||||||
let yes = ctx.config().yes();
|
let yes = ctx.config().yes();
|
||||||
|
|||||||
Reference in New Issue
Block a user