Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identify Rocky and Alma #360

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions os_info/src/linux/file_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -127,7 +126,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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -557,6 +567,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";
Expand Down
4 changes: 3 additions & 1 deletion os_info/src/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -51,6 +52,7 @@ mod tests {
| Type::Raspbian
| Type::Redhat
| Type::RedHatEnterprise
| Type::RockyLinux
| Type::Solus
| Type::SUSE
| Type::Ubuntu
Expand Down
18 changes: 18 additions & 0 deletions os_info/src/linux/tests/AlmaLinux-9.0/etc/os-release
Original file line number Diff line number Diff line change
@@ -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"
17 changes: 17 additions & 0 deletions os_info/src/linux/tests/RockyLinux-9.2/etc/os-release
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 6 additions & 0 deletions os_info/src/os_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use std::fmt::{self, Display, Formatter};
pub enum Type {
/// IBM AIX (<https://en.wikipedia.org/wiki/IBM_AIX>).
AIX,
/// AlmaLinux (<https://en.wikipedia.org/wiki/AlmaLinux>).
AlmaLinux,
/// Alpaquita Linux (<https://bell-sw.com/alpaquita-linux/>).
Alpaquita,
/// Alpine Linux (<https://en.wikipedia.org/wiki/Alpine_Linux>).
Expand Down Expand Up @@ -82,6 +84,8 @@ pub enum Type {
RedHatEnterprise,
/// Redox (<https://en.wikipedia.org/wiki/Redox_(operating_system)>).
Redox,
/// Rocky Linux (<https://en.wikipedia.org/wiki/Rocky_Linux>).
RockyLinux,
/// Solus (<https://en.wikipedia.org/wiki/Solus_(operating_system)>).
Solus,
/// SUSE Linux Enterprise Server (<https://en.wikipedia.org/wiki/SUSE_Linux_Enterprise>).
Expand All @@ -105,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"),
Expand All @@ -120,6 +125,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:?}"),
}
Expand Down
Loading