From 362ce4f4f92bc25db731083d1b4d9c91eda6aa9f Mon Sep 17 00:00:00 2001 From: Mike Wood Date: Sun, 7 Jan 2024 19:48:48 -0500 Subject: [PATCH] fix(os) consider Fedora Kinoite and other immutable distros to be the FedoraImmutable (#638) * fix(os) consider Fedora Kinoite to be the Fedora Silverblue distribution * fix(os) support additional Fedora immutable variants Rename FedoraSilverblue Distribution to FedoraImmutable. Add test cases for Onyx, Sericea and Silverblue. Rename upgrade method to match distribution. Fixes #637 --- src/steps/os/linux.rs | 25 +++++++++++++++++++----- src/steps/os/os_release/fedorakinoite | 23 ++++++++++++++++++++++ src/steps/os/os_release/fedoraonyx | 22 +++++++++++++++++++++ src/steps/os/os_release/fedorasericea | 22 +++++++++++++++++++++ src/steps/os/os_release/fedorasilverblue | 22 +++++++++++++++++++++ 5 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 src/steps/os/os_release/fedorakinoite create mode 100644 src/steps/os/os_release/fedoraonyx create mode 100644 src/steps/os/os_release/fedorasericea create mode 100644 src/steps/os/os_release/fedorasilverblue diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 1e24a125..1dbf7c2d 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -24,7 +24,7 @@ pub enum Distribution { CentOS, ClearLinux, Fedora, - FedoraSilverblue, + FedoraImmutable, Debian, Gentoo, OpenMandriva, @@ -54,8 +54,12 @@ impl Distribution { Some("clear-linux-os") => Distribution::ClearLinux, Some("fedora") | Some("nobara") => { return if let Some(variant) = variant { - if variant.contains(&"Silverblue") { - Ok(Distribution::FedoraSilverblue) + if variant.contains(&"Silverblue") + || variant.contains(&"Kinoite") + || variant.contains(&"Sericea") + || variant.contains(&"Onyx") + { + Ok(Distribution::FedoraImmutable) } else { Ok(Distribution::Fedora) } @@ -131,7 +135,7 @@ impl Distribution { Distribution::Alpine => upgrade_alpine_linux(ctx), Distribution::Arch => archlinux::upgrade_arch_linux(ctx), Distribution::CentOS | Distribution::Fedora => upgrade_redhat(ctx), - Distribution::FedoraSilverblue => upgrade_fedora_silverblue(ctx), + Distribution::FedoraImmutable => upgrade_fedora_immutable(ctx), Distribution::ClearLinux => upgrade_clearlinux(ctx), Distribution::Debian => upgrade_debian(ctx), Distribution::Gentoo => upgrade_gentoo(ctx), @@ -230,7 +234,7 @@ fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> { Ok(()) } -fn upgrade_fedora_silverblue(ctx: &ExecutionContext) -> Result<()> { +fn upgrade_fedora_immutable(ctx: &ExecutionContext) -> Result<()> { let ostree = require("rpm-ostree")?; let mut command = ctx.run_type().execute(ostree); command.arg("upgrade"); @@ -1036,6 +1040,17 @@ mod tests { test_template(include_str!("os_release/fedora"), Distribution::Fedora); } + #[test] + fn test_fedora_immutable() { + test_template( + include_str!("os_release/fedorasilverblue"), + Distribution::FedoraImmutable, + ); + test_template(include_str!("os_release/fedorakinoite"), Distribution::FedoraImmutable); + test_template(include_str!("os_release/fedoraonyx"), Distribution::FedoraImmutable); + test_template(include_str!("os_release/fedorasericea"), Distribution::FedoraImmutable); + } + #[test] fn test_manjaro() { test_template(include_str!("os_release/manjaro"), Distribution::Arch); diff --git a/src/steps/os/os_release/fedorakinoite b/src/steps/os/os_release/fedorakinoite new file mode 100644 index 00000000..e6b450af --- /dev/null +++ b/src/steps/os/os_release/fedorakinoite @@ -0,0 +1,23 @@ +NAME="Fedora Linux" +VERSION="39.20240105.0 (Kinoite)" +ID=fedora +VERSION_ID=39 +VERSION_CODENAME="" +PLATFORM_ID="platform:f39" +PRETTY_NAME="Fedora Linux 39.20240105.0 (Kinoite)" +ANSI_COLOR="0;38;2;60;110;180" +LOGO=fedora-logo-icon +CPE_NAME="cpe:/o:fedoraproject:fedora:39" +DEFAULT_HOSTNAME="fedora" +HOME_URL="https://kinoite.fedoraproject.org" +DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora-kinoite/" +SUPPORT_URL="https://ask.fedoraproject.org/" +BUG_REPORT_URL="https://pagure.io/fedora-kde/SIG/issues" +REDHAT_BUGZILLA_PRODUCT="Fedora" +REDHAT_BUGZILLA_PRODUCT_VERSION=39 +REDHAT_SUPPORT_PRODUCT="Fedora" +REDHAT_SUPPORT_PRODUCT_VERSION=39 +SUPPORT_END=2024-11-12 +VARIANT="Kinoite" +VARIANT_ID=kinoite +OSTREE_VERSION='39.20240105.0' diff --git a/src/steps/os/os_release/fedoraonyx b/src/steps/os/os_release/fedoraonyx new file mode 100644 index 00000000..7a74255f --- /dev/null +++ b/src/steps/os/os_release/fedoraonyx @@ -0,0 +1,22 @@ +NAME="Fedora Linux" +VERSION="39 (Onyx)" +ID=fedora +VERSION_ID=39 +VERSION_CODENAME="" +PLATFORM_ID="platform:f39" +PRETTY_NAME="Fedora Linux 39 (Onyx)" +ANSI_COLOR="0;38;2;60;110;180" +LOGO=fedora-logo-icon +CPE_NAME="cpe:/o:fedoraproject:fedora:39" +DEFAULT_HOSTNAME="fedora" +HOME_URL="https://fedoraproject.org/onyx/" +DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora-onyx/" +SUPPORT_URL="https://ask.fedoraproject.org/" +BUG_REPORT_URL="https://bugzilla.redhat.com/" +REDHAT_BUGZILLA_PRODUCT="Fedora" +REDHAT_BUGZILLA_PRODUCT_VERSION=39 +REDHAT_SUPPORT_PRODUCT="Fedora" +REDHAT_SUPPORT_PRODUCT_VERSION=39 +SUPPORT_END=2024-05-14 +VARIANT="Onyx" +VARIANT_ID=onyx diff --git a/src/steps/os/os_release/fedorasericea b/src/steps/os/os_release/fedorasericea new file mode 100644 index 00000000..69992c38 --- /dev/null +++ b/src/steps/os/os_release/fedorasericea @@ -0,0 +1,22 @@ +NAME="Fedora Linux" +VERSION="39 (Sericea)" +ID=fedora +VERSION_ID=39 +VERSION_CODENAME="" +PLATFORM_ID="platform:f39" +PRETTY_NAME="Fedora Linux 39 (Sericea)" +ANSI_COLOR="0;38;2;60;110;180" +LOGO=fedora-logo-icon +CPE_NAME="cpe:/o:fedoraproject:fedora:39" +DEFAULT_HOSTNAME="fedora" +HOME_URL="https://fedoraproject.org/sericea/" +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=39 +REDHAT_SUPPORT_PRODUCT="Fedora" +REDHAT_SUPPORT_PRODUCT_VERSION=39 +SUPPORT_END=2024-05-14 +VARIANT="Sericea" +VARIANT_ID=sericea diff --git a/src/steps/os/os_release/fedorasilverblue b/src/steps/os/os_release/fedorasilverblue new file mode 100644 index 00000000..d350710c --- /dev/null +++ b/src/steps/os/os_release/fedorasilverblue @@ -0,0 +1,22 @@ +NAME="Fedora Linux" +VERSION="39 (Silverblue)" +ID=fedora +VERSION_ID=39 +VERSION_CODENAME="" +PLATFORM_ID="platform:f39" +PRETTY_NAME="Fedora Linux 39 (Silverblue)" +ANSI_COLOR="0;38;2;60;110;180" +LOGO=fedora-logo-icon +CPE_NAME="cpe:/o:fedoraproject:fedora:39" +DEFAULT_HOSTNAME="fedora" +HOME_URL="https://silverblue.fedoraproject.org" +DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora-silverblue/" +SUPPORT_URL="https://ask.fedoraproject.org/" +BUG_REPORT_URL="https://github.com/fedora-silverblue/issue-tracker/issues" +REDHAT_BUGZILLA_PRODUCT="Fedora" +REDHAT_BUGZILLA_PRODUCT_VERSION=39 +REDHAT_SUPPORT_PRODUCT="Fedora" +REDHAT_SUPPORT_PRODUCT_VERSION=39 +SUPPORT_END=2024-05-14 +VARIANT="Silverblue" +VARIANT_ID=silverblue