From 4c869ddabfdb5836307d078eca89fd8183855858 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Fri, 2 Feb 2024 13:45:16 +0100 Subject: [PATCH 1/2] Add support for Rocky Linux Signed-off-by: Yann Dirson --- os_info/src/linux/file_release.rs | 13 ++++++++++++- os_info/src/linux/mod.rs | 1 + .../linux/tests/RockyLinux-9.2/etc/os-release | 17 +++++++++++++++++ os_info/src/os_type.rs | 3 +++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 os_info/src/linux/tests/RockyLinux-9.2/etc/os-release diff --git a/os_info/src/linux/file_release.rs b/os_info/src/linux/file_release.rs index e3d5b2b..a8eab92 100644 --- a/os_info/src/linux/file_release.rs +++ b/os_info/src/linux/file_release.rs @@ -127,7 +127,7 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [ //"raspbian" => Raspbian // note XBian also uses "raspbian" "rhel" => Some(Type::RedHatEnterprise), - //"rocky" => Rocky + "rocky" => Some(Type::RockyLinux), //"sabayon" => Sabayon //"scientific" => Scientific //"slackware" => Slackware @@ -557,6 +557,17 @@ mod tests { assert_eq!(info.codename, None); } + #[test] + fn rocky_9_2_release() { + let root = "src/linux/tests/RockyLinux-9.2"; + + let info = retrieve(&DISTRIBUTIONS, root).unwrap(); + assert_eq!(info.os_type(), Type::RockyLinux); + assert_eq!(info.version, Version::Semantic(9, 2, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + #[test] fn suse_12_os_release() { let root = "src/linux/tests/SUSE_12"; diff --git a/os_info/src/linux/mod.rs b/os_info/src/linux/mod.rs index 8cc394c..f6276db 100644 --- a/os_info/src/linux/mod.rs +++ b/os_info/src/linux/mod.rs @@ -51,6 +51,7 @@ mod tests { | Type::Raspbian | Type::Redhat | Type::RedHatEnterprise + | Type::RockyLinux | Type::Solus | Type::SUSE | Type::Ubuntu diff --git a/os_info/src/linux/tests/RockyLinux-9.2/etc/os-release b/os_info/src/linux/tests/RockyLinux-9.2/etc/os-release new file mode 100644 index 0000000..fe42f18 --- /dev/null +++ b/os_info/src/linux/tests/RockyLinux-9.2/etc/os-release @@ -0,0 +1,17 @@ +NAME="Rocky Linux" +VERSION="9.2 (Blue Onyx)" +ID="rocky" +ID_LIKE="rhel centos fedora" +VERSION_ID="9.2" +PLATFORM_ID="platform:el9" +PRETTY_NAME="Rocky Linux 9.2 (Blue Onyx)" +ANSI_COLOR="0;32" +LOGO="fedora-logo-icon" +CPE_NAME="cpe:/o:rocky:rocky:9::baseos" +HOME_URL="https://rockylinux.org/" +BUG_REPORT_URL="https://bugs.rockylinux.org/" +SUPPORT_END="2032-05-31" +ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9" +ROCKY_SUPPORT_PRODUCT_VERSION="9.2" +REDHAT_SUPPORT_PRODUCT="Rocky Linux" +REDHAT_SUPPORT_PRODUCT_VERSION="9.2" diff --git a/os_info/src/os_type.rs b/os_info/src/os_type.rs index 1592561..6be1da6 100644 --- a/os_info/src/os_type.rs +++ b/os_info/src/os_type.rs @@ -82,6 +82,8 @@ pub enum Type { RedHatEnterprise, /// Redox (). Redox, + /// Rocky Linux (). + RockyLinux, /// Solus (). Solus, /// SUSE Linux Enterprise Server (). @@ -120,6 +122,7 @@ impl Display for Type { Type::Raspbian => write!(f, "Raspberry Pi OS"), Type::Redhat => write!(f, "Red Hat Linux"), Type::RedHatEnterprise => write!(f, "Red Hat Enterprise Linux"), + Type::RockyLinux => write!(f, "Rocky Linux"), Type::SUSE => write!(f, "SUSE Linux Enterprise Server"), _ => write!(f, "{self:?}"), } From 2cfaf55e0bf689e46ebae773c3a92d3b8b339f36 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Fri, 2 Feb 2024 15:38:36 +0100 Subject: [PATCH 2/2] Add support for AlmaLinux Had to remove adjacent empty line to please Rustfmt. Signed-off-by: Yann Dirson --- os_info/src/linux/file_release.rs | 14 ++++++++++++-- os_info/src/linux/mod.rs | 3 ++- .../linux/tests/AlmaLinux-9.0/etc/os-release | 18 ++++++++++++++++++ os_info/src/os_type.rs | 3 +++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 os_info/src/linux/tests/AlmaLinux-9.0/etc/os-release diff --git a/os_info/src/linux/file_release.rs b/os_info/src/linux/file_release.rs index a8eab92..797ddd7 100644 --- a/os_info/src/linux/file_release.rs +++ b/os_info/src/linux/file_release.rs @@ -89,8 +89,7 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [ .and_then(|id| match id.as_str() { // os-release information collected from // https://github.com/chef/os_release - - //"almalinux" => Alma + "almalinux" => Some(Type::AlmaLinux), "alpaquita" => Some(Type::Alpaquita), "alpine" => Some(Type::Alpine), "amzn" => Some(Type::Amazon), @@ -200,6 +199,17 @@ mod tests { use super::*; use pretty_assertions::assert_eq; + #[test] + fn almalinux_9_0_release() { + let root = "src/linux/tests/AlmaLinux-9.0"; + + let info = retrieve(&DISTRIBUTIONS, root).unwrap(); + assert_eq!(info.os_type(), Type::AlmaLinux); + assert_eq!(info.version, Version::Semantic(9, 0, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + #[test] fn alpaquita_os_release() { let root = "src/linux/tests/Alpaquita"; diff --git a/os_info/src/linux/mod.rs b/os_info/src/linux/mod.rs index f6276db..c1b472c 100644 --- a/os_info/src/linux/mod.rs +++ b/os_info/src/linux/mod.rs @@ -26,7 +26,8 @@ mod tests { fn os_type() { let version = current_platform(); match version.os_type() { - Type::Alpaquita + Type::AlmaLinux + | Type::Alpaquita | Type::Alpine | Type::Amazon | Type::Arch diff --git a/os_info/src/linux/tests/AlmaLinux-9.0/etc/os-release b/os_info/src/linux/tests/AlmaLinux-9.0/etc/os-release new file mode 100644 index 0000000..27501a5 --- /dev/null +++ b/os_info/src/linux/tests/AlmaLinux-9.0/etc/os-release @@ -0,0 +1,18 @@ +NAME="AlmaLinux" +VERSION="9.0 (Emerald Puma)" +ID="almalinux" +ID_LIKE="rhel centos fedora" +VERSION_ID="9.0" +PLATFORM_ID="platform:el9" +PRETTY_NAME="AlmaLinux 9.0 (Emerald Puma)" +ANSI_COLOR="0;34" +LOGO="fedora-logo-icon" +CPE_NAME="cpe:/o:almalinux:almalinux:9::baseos" +HOME_URL="https://almalinux.org/" +DOCUMENTATION_URL="https://wiki.almalinux.org/" +BUG_REPORT_URL="https://bugs.almalinux.org/" + +ALMALINUX_MANTISBT_PROJECT="AlmaLinux-9" +ALMALINUX_MANTISBT_PROJECT_VERSION="9.0" +REDHAT_SUPPORT_PRODUCT="AlmaLinux" +REDHAT_SUPPORT_PRODUCT_VERSION="9.0" diff --git a/os_info/src/os_type.rs b/os_info/src/os_type.rs index 6be1da6..4516d24 100644 --- a/os_info/src/os_type.rs +++ b/os_info/src/os_type.rs @@ -8,6 +8,8 @@ use std::fmt::{self, Display, Formatter}; pub enum Type { /// IBM AIX (). AIX, + /// AlmaLinux (). + AlmaLinux, /// Alpaquita Linux (). Alpaquita, /// Alpine Linux (). @@ -107,6 +109,7 @@ impl Display for Type { match *self { Type::Alpaquita => write!(f, "Alpaquita Linux"), Type::Alpine => write!(f, "Alpine Linux"), + Type::AlmaLinux => write!(f, "AlmaLinux"), Type::Amazon => write!(f, "Amazon Linux AMI"), Type::Arch => write!(f, "Arch Linux"), Type::Artix => write!(f, "Artix Linux"),