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

Add support for Artix Linux #342

Merged
merged 1 commit into from
Mar 13, 2023
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Right now, the following operating system types can be returned:
- Amazon Linux AMI
- Android
- Arch Linux
- Artix Linux
- CentOS
- Debian
- DragonFly BSD
Expand Down
9 changes: 9 additions & 0 deletions os_info/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ mod tests {
Type::Amazon,
Type::Android,
Type::Arch,
Type::Artix,
Type::CentOS,
Type::Debian,
Type::Emscripten,
Expand Down Expand Up @@ -281,6 +282,14 @@ mod tests {
},
"Arch Linux Rolling Release [unknown bitness]",
),
(
Info {
os_type: Type::Artix,
version: Version::Rolling(None),
..Default::default()
},
"Artix Linux Rolling Release [unknown bitness]",
),
(
Info {
os_type: Type::Manjaro,
Expand Down
13 changes: 12 additions & 1 deletion os_info/src/linux/file_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
//"aosc" => AOSC
"arch" => Some(Type::Arch),
"archarm" => Some(Type::Arch),
//"artix" => Artix
"artix" => Some(Type::Artix),
"centos" => Some(Type::CentOS),
//"clear-linux-os" => ClearLinuxOS
//"clearos" => ClearOS
Expand Down Expand Up @@ -264,6 +264,17 @@ mod tests {
assert_eq!(info.codename, None);
}

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

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

#[test]
fn centos_7_os_release() {
let root = "src/linux/tests/CentOS_7";
Expand Down
17 changes: 17 additions & 0 deletions os_info/src/linux/lsb_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub fn get() -> Option<Info> {
let os_type = match release.distribution.as_ref().map(String::as_ref) {
Some("Amazon") | Some("AmazonAMI") => Type::Amazon,
Some("Arch") => Type::Arch,
Some("Artix") => Type::Artix,
Some("CentOS") => Type::CentOS,
Some("Debian") => Type::Debian,
Some("EndeavourOS") => Type::EndeavourOS,
Expand Down Expand Up @@ -119,6 +120,14 @@ mod tests {
assert_eq!(parse_results.codename, None);
}

#[test]
fn artix() {
let parse_results = parse(artix_file());
assert_eq!(parse_results.distribution, Some("Artix".to_string()));
assert_eq!(parse_results.version, Some("rolling".to_string()));
assert_eq!(parse_results.codename, None);
}

#[test]
fn fedora() {
let parse_results = parse(fedora_file());
Expand Down Expand Up @@ -307,6 +316,14 @@ mod tests {
Codename: n/a"
}

fn artix_file() -> &'static str {
"\nLSB Version: n/a\n\
Distributor ID: Artix\n\
Description: Artix Linux\n\
Release: rolling\n\
Codename: n/a"
}

fn fedora_file() -> &'static str {
"\nLSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch\n\
Distributor ID: Fedora\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 @@ -29,6 +29,7 @@ mod tests {
Type::Alpine
| Type::Amazon
| Type::Arch
| Type::Artix
| Type::CentOS
| Type::Debian
| Type::EndeavourOS
Expand Down
9 changes: 9 additions & 0 deletions os_info/src/linux/tests/Artix/etc/os-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
NAME="Artix Linux"
PRETTY_NAME="Artix Linux"
ID=artix
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://artixlinux.org/"
DOCUMENTATION_URL="https://wiki.artixlinux.org/"
SUPPORT_URL="https://forum.artixlinux.org/"
BUG_REPORT_URL="https://gitea.artixlinux.org/artix"
4 changes: 4 additions & 0 deletions os_info/src/os_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub enum Type {
Android,
/// Arch Linux (<https://en.wikipedia.org/wiki/Arch_Linux>).
Arch,
/// Artix Linux (<https://en.wikipedia.org/wiki/Artix_Linux>).
Artix,
/// CentOS (<https://en.wikipedia.org/wiki/CentOS>).
CentOS,
/// Debian (<https://en.wikipedia.org/wiki/Debian>).
Expand Down Expand Up @@ -98,6 +100,7 @@ impl Display for Type {
Type::Alpine => write!(f, "Alpine Linux"),
Type::Amazon => write!(f, "Amazon Linux AMI"),
Type::Arch => write!(f, "Arch Linux"),
Type::Artix => write!(f, "Artix Linux"),
Type::DragonFly => write!(f, "DragonFly BSD"),
Type::Garuda => write!(f, "Garuda Linux"),
Type::Gentoo => write!(f, "Gentoo Linux"),
Expand Down Expand Up @@ -131,6 +134,7 @@ mod tests {
(Type::Amazon, "Amazon Linux AMI"),
(Type::Android, "Android"),
(Type::Arch, "Arch Linux"),
(Type::Artix, "Artix Linux"),
(Type::CentOS, "CentOS"),
(Type::Debian, "Debian"),
(Type::DragonFly, "DragonFly BSD"),
Expand Down