Skip to content

Commit

Permalink
Merge pull request #328 from leavelet/master
Browse files Browse the repository at this point in the history
Add openEuler and OpenCloudOS support
  • Loading branch information
stanislav-tkach committed Jan 1, 2023
2 parents 75ef20a + eb9977d commit 5e42e34
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions os_info/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ mod tests {
Type::Manjaro,
Type::Mariner,
Type::NixOS,
Type::OpenCloudOS,
Type::openEuler,
Type::openSUSE,
Type::OracleLinux,
Type::Pop,
Expand Down
25 changes: 25 additions & 0 deletions os_info/src/linux/file_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
"mariner" => Some(Type::Mariner),
//"nexus" => Nexus
"nixos" => Some(Type::NixOS),
"opencloudos" => Some(Type::OpenCloudOS),
"openEuler" => Some(Type::openEuler),
"ol" => Some(Type::OracleLinux),
"opensuse" => Some(Type::openSUSE),
"opensuse-leap" => Some(Type::openSUSE),
Expand Down Expand Up @@ -398,6 +400,29 @@ mod tests {
assert_eq!(info, None);
}

#[test]
fn opencloudos_os_release() {
let root = "src/linux/tests/OpenCloudOS";

let info = retrieve(&DISTRIBUTIONS, root).unwrap();
assert_eq!(info.os_type(), Type::OpenCloudOS);
assert_eq!(info.version, Version::Semantic(8, 6, 0));
assert_eq!(info.edition, None);
assert_eq!(info.codename, None);
}

#[test]
fn openeuler_os_release() {
let root = "src/linux/tests/openEuler";

let info = retrieve(&DISTRIBUTIONS, root).unwrap();
assert_eq!(info.os_type(), Type::openEuler);
assert_eq!(info.version, Version::Semantic(22, 3, 0));
assert_eq!(info.edition, None);
assert_eq!(info.codename, None);

}

#[test]
fn oracle_linux_os_release() {
let root = "src/linux/tests/OracleLinux";
Expand Down
2 changes: 2 additions & 0 deletions os_info/src/linux/lsb_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub fn get() -> Option<Info> {
Some("ManjaroLinux") => Type::Manjaro,
Some("Mariner") => Type::Mariner,
Some("NixOS") => Type::NixOS,
Some("OpenCloudOS") => Type::OpenCloudOS,
Some("openEuler") => Type::openEuler,
Some("openSUSE") => Type::openSUSE,
Some("OracleServer") => Type::OracleLinux,
Some("Pop") => Type::Pop,
Expand Down
2 changes: 2 additions & 0 deletions os_info/src/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ mod tests {
| Type::Manjaro
| Type::Mariner
| Type::NixOS
| Type::OpenCloudOS
| Type::openEuler
| Type::openSUSE
| Type::OracleLinux
| Type::Pop
Expand Down
9 changes: 9 additions & 0 deletions os_info/src/linux/tests/OpenCloudOS/etc/os-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
NAME="OpenCloudOS"
VERSION="8.6"
ID="opencloudos"
ID_LIKE="rhel fedora centos"
VERSION_ID="8.6"
PLATFORM_ID="platform:oc8"
PRETTY_NAME="OpenCloudOS 8.6"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:opencloudos:opencloudos:8"
6 changes: 6 additions & 0 deletions os_info/src/linux/tests/openEuler/etc/os-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
NAME="openEuler"
VERSION="22.03 LTS"
ID="openEuler"
VERSION_ID="22.03"
PRETTY_NAME="openEuler 22.03 LTS"
ANSI_COLOR="0;31"
4 changes: 4 additions & 0 deletions os_info/src/os_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ pub enum Type {
NixOS,
/// OpenBSD (<https://en.wikipedia.org/wiki/OpenBSD>).
OpenBSD,
/// OpenCloudOS (<https://www.opencloudos.org>).
OpenCloudOS,
/// openEuler (<https://en.wikipedia.org/wiki/EulerOS>).
openEuler,
/// openSUSE (<https://en.wikipedia.org/wiki/OpenSUSE>).
openSUSE,
/// Oracle Linux (<https://en.wikipedia.org/wiki/Oracle_Linux>).
Expand Down

0 comments on commit 5e42e34

Please sign in to comment.