fix: uBlue OS should be detected as FedoraImmutable (#1043)
* refactor(parse_os_release): Don't rely on specific `ID`s for Fedora Immutable Instead match `ID=fedora` or `ID_LIKE=fedora` and decide wether or not the distro is immutable by `VARIANT`. * feat: add aurora,bluefin,coreos support The `os_release`s came from the following images: - ghcr.io/ublue-os/aurora:93f0fd9f20b3 - ghcr.io/ublue-os/bluefin:5d37394a5d4b - ghcr.io/ublue-os/ucore:63cd1200c344 * fix: bazzite should be detected as FedoraImmutable * squash me: cargo fmt --------- Co-authored-by: Steve Lau <stevelauc@outlook.com>
This commit is contained in:
@@ -60,19 +60,7 @@ impl Distribution {
|
||||
Some("wolfi") => Distribution::Wolfi,
|
||||
Some("centos") | Some("rhel") | Some("ol") => Distribution::CentOS,
|
||||
Some("clear-linux-os") => Distribution::ClearLinux,
|
||||
Some("fedora") => {
|
||||
return if let Some(variant) = variant {
|
||||
match variant {
|
||||
"Silverblue" | "Kinoite" | "Sericea" | "Onyx" | "IoT Edition" | "Sway Atomic" => {
|
||||
Ok(Distribution::FedoraImmutable)
|
||||
}
|
||||
_ => Ok(Distribution::Fedora),
|
||||
}
|
||||
} else {
|
||||
Ok(Distribution::Fedora)
|
||||
};
|
||||
}
|
||||
|
||||
Some("fedora") => Distribution::match_fedora_variant(&variant),
|
||||
Some("nilrt") => Distribution::NILRT,
|
||||
Some("nobara") => Distribution::Nobara,
|
||||
Some("void") => Distribution::Void,
|
||||
@@ -109,7 +97,7 @@ impl Distribution {
|
||||
} else if id_like.contains(&"alpine") {
|
||||
return Ok(Distribution::Alpine);
|
||||
} else if id_like.contains(&"fedora") {
|
||||
return Ok(Distribution::Fedora);
|
||||
return Ok(Distribution::match_fedora_variant(&variant));
|
||||
}
|
||||
}
|
||||
return Err(TopgradeError::UnknownLinuxDistribution.into());
|
||||
@@ -117,6 +105,15 @@ impl Distribution {
|
||||
})
|
||||
}
|
||||
|
||||
fn match_fedora_variant(variant: &Option<&str>) -> Self {
|
||||
if let Some("Silverblue" | "Kinoite" | "Sericea" | "Onyx" | "IoT Edition" | "Sway Atomic" | "CoreOS") = variant
|
||||
{
|
||||
Distribution::FedoraImmutable
|
||||
} else {
|
||||
Distribution::Fedora
|
||||
}
|
||||
}
|
||||
|
||||
pub fn detect() -> Result<Self> {
|
||||
if PathBuf::from("/bedrock").exists() {
|
||||
return Ok(Distribution::Bedrock);
|
||||
@@ -1288,4 +1285,24 @@ mod tests {
|
||||
fn test_nilrt() {
|
||||
test_template(include_str!("os_release/nilrt"), Distribution::NILRT);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_coreos() {
|
||||
test_template(include_str!("os_release/coreos"), Distribution::FedoraImmutable);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_aurora() {
|
||||
test_template(include_str!("os_release/aurora"), Distribution::FedoraImmutable);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bluefin() {
|
||||
test_template(include_str!("os_release/bluefin"), Distribution::FedoraImmutable);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bazzite() {
|
||||
test_template(include_str!("os_release/bazzite"), Distribution::FedoraImmutable);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user