Skip to content

Commit

Permalink
Add support for AlmaLinux
Browse files Browse the repository at this point in the history
Had to remove adjacent empty line to please Rustfmt.

Signed-off-by: Yann Dirson <[email protected]>
  • Loading branch information
ydirson committed Feb 2, 2024
1 parent 4c869dd commit 2cfaf55
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
14 changes: 12 additions & 2 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 @@ -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
3 changes: 2 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 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"
3 changes: 3 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 @@ -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"),
Expand Down

0 comments on commit 2cfaf55

Please sign in to comment.