fix: Fedora Sway Atomic should be recognized as FedoraImmutable (#795)

* fix: Fedora Sway Atomic should be recognized as FedoraImmutable

* style: fmt
This commit is contained in:
SteveLauC
2024-05-11 11:20:43 +08:00
committed by GitHub
parent 767f0d91f4
commit 4d66431aad
2 changed files with 33 additions and 10 deletions

View File

@@ -48,7 +48,7 @@ impl Distribution {
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 name = section.get("NAME");
let variant: Option<Vec<&str>> = section.get("VARIANT").map(|s| s.split_whitespace().collect()); let variant = section.get("VARIANT");
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 {
@@ -58,15 +58,11 @@ impl Distribution {
Some("clear-linux-os") => Distribution::ClearLinux, Some("clear-linux-os") => Distribution::ClearLinux,
Some("fedora") => { Some("fedora") => {
return if let Some(variant) = variant { return if let Some(variant) = variant {
if variant.contains(&"Silverblue") match variant {
|| variant.contains(&"Kinoite") "Silverblue" | "Kinoite" | "Sericea" | "Onyx" | "IoT Edition" | "Sway Atomic" => {
|| variant.contains(&"Sericea")
|| variant.contains(&"Onyx")
|| variant.contains(&"IoT")
{
Ok(Distribution::FedoraImmutable) Ok(Distribution::FedoraImmutable)
} else { }
Ok(Distribution::Fedora) _ => Ok(Distribution::Fedora),
} }
} else { } else {
Ok(Distribution::Fedora) Ok(Distribution::Fedora)
@@ -1144,6 +1140,10 @@ mod tests {
test_template(include_str!("os_release/fedoraonyx"), Distribution::FedoraImmutable); test_template(include_str!("os_release/fedoraonyx"), Distribution::FedoraImmutable);
test_template(include_str!("os_release/fedorasericea"), Distribution::FedoraImmutable); test_template(include_str!("os_release/fedorasericea"), Distribution::FedoraImmutable);
test_template(include_str!("os_release/fedoraiot"), Distribution::FedoraImmutable); test_template(include_str!("os_release/fedoraiot"), Distribution::FedoraImmutable);
test_template(
include_str!("os_release/fedoraswayatomic"),
Distribution::FedoraImmutable,
);
} }
#[test] #[test]

View File

@@ -0,0 +1,23 @@
NAME="Fedora Linux"
VERSION="40.20240426.0 (Sway Atomic)"
ID=fedora
VERSION_ID=40
VERSION_CODENAME=""
PLATFORM_ID="platform:f40"
PRETTY_NAME="Fedora Linux 40.20240426.0 (Sway Atomic)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:40"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/atomic-desktops/sway/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora-sericea/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://gitlab.com/fedora/sigs/sway/SIG/-/issues"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=40
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=40
SUPPORT_END=2025-05-13
VARIANT="Sway Atomic"
VARIANT_ID=sway-atomic
OSTREE_VERSION='40.20240426.0'