Skip to content

Commit

Permalink
add support for Uos Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
WangMengabc committed Apr 17, 2024
1 parent 5890843 commit a00ee73
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions cspell-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ musl
netbsd
nixos
nobara
uos
openbsd
opencloudos
openeuler
Expand Down
1 change: 1 addition & 0 deletions os_info/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ mod tests {
Type::Mariner,
Type::NixOS,
Type::Nobara,
Type::Uos,
Type::OpenCloudOS,
Type::openEuler,
Type::openSUSE,
Expand Down
12 changes: 12 additions & 0 deletions os_info/src/linux/file_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
//"nexus" => Nexus
"nixos" => Some(Type::NixOS),
"nobara" => Some(Type::Nobara),
"Uos" => Some(Type::Uos),
"opencloudos" => Some(Type::OpenCloudOS),
"openEuler" => Some(Type::openEuler),
"ol" => Some(Type::OracleLinux),
Expand Down Expand Up @@ -469,6 +470,17 @@ mod tests {
assert_eq!(info.codename, None);
}

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

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

#[test]
fn none_invalid_os_release() {
let root = "src/linux/tests/none_invalid_os_release";
Expand Down
20 changes: 20 additions & 0 deletions os_info/src/linux/lsb_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub fn get() -> Option<Info> {
Some("Mariner") => Type::Mariner,
Some("NixOS") => Type::NixOS,
Some("NobaraLinux") => Type::Nobara,
Some("Uos") => Type::Uos,
Some("OpenCloudOS") => Type::OpenCloudOS,
Some("openEuler") => Type::openEuler,
Some("openSUSE") => Type::openSUSE,
Expand Down Expand Up @@ -195,6 +196,17 @@ mod tests {
assert_eq!(parse_results.codename, None);
}

#[test]
fn Uos() {

Check warning on line 200 in os_info/src/linux/lsb_release.rs

View workflow job for this annotation

GitHub Actions / Linux

function `Uos` should have a snake case name
let parse_results = parse(uos_file());
assert_eq!(
parse_results.distribution,
Some("uos".to_string())
);
assert_eq!(parse_results.version, Some("20".to_string()));
assert_eq!(parse_results.codename, Some("eagle".to_string()));
}

#[test]
fn amazon1() {
let parse_results = parse(amazon1_file());
Expand Down Expand Up @@ -428,6 +440,14 @@ mod tests {
"
}

fn uos_file() -> &'static str {
"Distributor ID: uos\n\
Description: UnionTech OS 20\n\
Release: 20\n\
Codename: eagle\n\
"
}

// Amazon Linux 1 uses a separate Distributor ID and Release format from Amazon Linux 2
fn amazon1_file() -> &'static str {
"LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch\n\
Expand Down
1 change: 1 addition & 0 deletions os_info/src/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ mod tests {
| Type::Mariner
| Type::NixOS
| Type::Nobara
| Type::Uos
| Type::OpenCloudOS
| Type::openEuler
| Type::openSUSE
Expand Down
8 changes: 8 additions & 0 deletions os_info/src/linux/tests/Uos/etc/os-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PRETTY_NAME="UnionTech OS Desktop 20 Pro"
NAME="Uos"
VERSION_ID="20"
VERSION="20"
ID=Uos
HOME_URL="https://www.chinauos.com/"
BUG_REPORT_URL="http://bbs.chinauos.com"
VERSION_CODENAME=eagle
4 changes: 4 additions & 0 deletions os_info/src/os_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub enum Type {
NixOS,
/// Nobara (<https://nobaraproject.org/>).
Nobara,
/// Uos (<https://www.chinauos.com/>).
Uos,
/// OpenBSD (<https://en.wikipedia.org/wiki/OpenBSD>).
OpenBSD,
/// OpenCloudOS (<https://www.opencloudos.org>).
Expand Down Expand Up @@ -128,6 +130,7 @@ impl Display for Type {
Type::MidnightBSD => write!(f, "Midnight BSD"),
Type::Mint => write!(f, "Linux Mint"),
Type::Nobara => write!(f, "Nobara Linux"),
Type::Uos => write!(f, "Uos"),
Type::openEuler => write!(f, "EulerOS"),
Type::OracleLinux => write!(f, "Oracle Linux"),
Type::Pop => write!(f, "Pop!_OS"),
Expand Down Expand Up @@ -185,6 +188,7 @@ mod tests {
(Type::NetBSD, "NetBSD"),
(Type::NixOS, "NixOS"),
(Type::Nobara, "Nobara Linux"),
(Type::Uos, "Uos"),
(Type::OpenCloudOS, "OpenCloudOS"),
(Type::OpenBSD, "OpenBSD"),
(Type::openEuler, "EulerOS"),
Expand Down

0 comments on commit a00ee73

Please sign in to comment.