feat: support Vanilla Linux (#447)
This commit is contained in:
@@ -32,6 +32,7 @@ pub enum Distribution {
|
|||||||
PCLinuxOS,
|
PCLinuxOS,
|
||||||
Suse,
|
Suse,
|
||||||
SuseMicro,
|
SuseMicro,
|
||||||
|
Vanilla,
|
||||||
Void,
|
Void,
|
||||||
Solus,
|
Solus,
|
||||||
Exherbo,
|
Exherbo,
|
||||||
@@ -43,6 +44,7 @@ impl Distribution {
|
|||||||
fn parse_os_release(os_release: &Ini) -> Result<Self> {
|
fn parse_os_release(os_release: &Ini) -> Result<Self> {
|
||||||
let section = os_release.general_section();
|
let section = os_release.general_section();
|
||||||
let id = section.get("ID");
|
let id = section.get("ID");
|
||||||
|
let name = section.get("NAME");
|
||||||
let variant: Option<Vec<&str>> = section.get("VARIANT").map(|s| s.split_whitespace().collect());
|
let variant: Option<Vec<&str>> = section.get("VARIANT").map(|s| s.split_whitespace().collect());
|
||||||
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());
|
||||||
|
|
||||||
@@ -74,6 +76,11 @@ impl Distribution {
|
|||||||
Some("openmandriva") => Distribution::OpenMandriva,
|
Some("openmandriva") => Distribution::OpenMandriva,
|
||||||
Some("pclinuxos") => Distribution::PCLinuxOS,
|
Some("pclinuxos") => Distribution::PCLinuxOS,
|
||||||
_ => {
|
_ => {
|
||||||
|
if let Some(name) = name {
|
||||||
|
if name.contains("Vanilla") {
|
||||||
|
return Ok(Distribution::Vanilla);
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Some(id_like) = id_like {
|
if let Some(id_like) = id_like {
|
||||||
if id_like.contains(&"debian") || id_like.contains(&"ubuntu") {
|
if id_like.contains(&"debian") || id_like.contains(&"ubuntu") {
|
||||||
return Ok(Distribution::Debian);
|
return Ok(Distribution::Debian);
|
||||||
@@ -127,6 +134,7 @@ impl Distribution {
|
|||||||
Distribution::Suse => upgrade_suse(ctx),
|
Distribution::Suse => upgrade_suse(ctx),
|
||||||
Distribution::SuseMicro => upgrade_suse_micro(ctx),
|
Distribution::SuseMicro => upgrade_suse_micro(ctx),
|
||||||
Distribution::OpenSuseTumbleweed => upgrade_opensuse_tumbleweed(ctx),
|
Distribution::OpenSuseTumbleweed => upgrade_opensuse_tumbleweed(ctx),
|
||||||
|
Distribution::Vanilla => upgrade_vanilla(ctx),
|
||||||
Distribution::Void => upgrade_void(ctx),
|
Distribution::Void => upgrade_void(ctx),
|
||||||
Distribution::Solus => upgrade_solus(ctx),
|
Distribution::Solus => upgrade_solus(ctx),
|
||||||
Distribution::Exherbo => upgrade_exherbo(ctx),
|
Distribution::Exherbo => upgrade_exherbo(ctx),
|
||||||
@@ -343,6 +351,26 @@ fn upgrade_pclinuxos(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn upgrade_vanilla(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
let apx = require("apx")?;
|
||||||
|
|
||||||
|
let mut update = ctx.run_type().execute(&apx);
|
||||||
|
update.args(["update", "--all"]);
|
||||||
|
if ctx.config().yes(Step::System) {
|
||||||
|
update.arg("-y");
|
||||||
|
}
|
||||||
|
update.status_checked()?;
|
||||||
|
|
||||||
|
let mut upgrade = ctx.run_type().execute(&apx);
|
||||||
|
update.args(["upgrade", "--all"]);
|
||||||
|
if ctx.config().yes(Step::System) {
|
||||||
|
upgrade.arg("-y");
|
||||||
|
}
|
||||||
|
upgrade.status_checked()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn upgrade_void(ctx: &ExecutionContext) -> Result<()> {
|
fn upgrade_void(ctx: &ExecutionContext) -> Result<()> {
|
||||||
if let Some(sudo) = ctx.sudo() {
|
if let Some(sudo) = ctx.sudo() {
|
||||||
let mut command = ctx.run_type().execute(sudo);
|
let mut command = ctx.run_type().execute(sudo);
|
||||||
@@ -1006,4 +1034,9 @@ mod tests {
|
|||||||
fn test_deepin() {
|
fn test_deepin() {
|
||||||
test_template(include_str!("os_release/deepin"), Distribution::Debian);
|
test_template(include_str!("os_release/deepin"), Distribution::Debian);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_vanilla() {
|
||||||
|
test_template(include_str!("os_release/vanilla"), Distribution::Vanilla);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/steps/os/os_release/vanilla
Normal file
12
src/steps/os/os_release/vanilla
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
PRETTY_NAME="VanillaOS 22.10 all"
|
||||||
|
NAME="VanillaOS"
|
||||||
|
VERSION_ID="22.10"
|
||||||
|
VERSION="22.10 all"
|
||||||
|
VERSION_CODENAME="kinetic"
|
||||||
|
ID=ubuntu
|
||||||
|
ID_LIKE=debian
|
||||||
|
HOME_URL="https://github.com/vanilla-os"
|
||||||
|
SUPPORT_URL="https://github.com/vanilla-os"
|
||||||
|
BUG_REPORT_URL="https://github.com/vanilla-os"
|
||||||
|
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
|
||||||
|
UBUNTU_CODENAME="kinetic"
|
||||||
Reference in New Issue
Block a user