Skip to content

Commit

Permalink
Merge pull request #365 from MysticalDevil/master
Browse files Browse the repository at this point in the history
Add support for VoidLinux
  • Loading branch information
stanislav-tkach authored Mar 6, 2024
2 parents 5b5e49b + 756e4aa commit f691b0c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cspell-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ xenenterprise
xenial
xenserver
ultramarine
kuma
voidlinux
kuma
1 change: 1 addition & 0 deletions os_info/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ mod tests {
Type::SUSE,
Type::Ubuntu,
Type::Ultramarine,
Type::Void,
Type::Mint,
Type::Unknown,
Type::Windows,
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 @@ -136,7 +136,7 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
"ubuntu" => Some(Type::Ubuntu),
"ultramarine" => Some(Type::Ultramarine),
//"virtuozzo" => Virtuozzo
//"void" => Void
"void" => Some(Type::Void),
//"XCP-ng" => xcp-ng
//"xenenterprise" => xcp-ng
//"xenserver" => xcp-ng
Expand Down Expand Up @@ -623,6 +623,17 @@ mod tests {
assert_eq!(info.codename, None);
}

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

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

#[test]
fn release_info_debug() {
dbg!("{:?}", &DISTRIBUTIONS[0]);
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 @@ -43,6 +43,7 @@ pub fn get() -> Option<Info> {
Some("SUSE") => Type::SUSE,
Some("Ubuntu") => Type::Ubuntu,
Some("UltramarineLinux") => Type::Ultramarine,
Some("VoidLinux") => Type::Void,
_ => Type::Linux,
};

Expand Down Expand Up @@ -322,6 +323,13 @@ mod tests {
assert_eq!(parse_results.codename, Some("kuma".to_string()));
}

#[test]
fn void_linux() {
let parse_results = parse(void_file());
assert_eq!(parse_results.distribution, Some("Void".to_string()));
assert_eq!(parse_results.version, Some("rolling".to_string()));
}

#[test]
fn raspbian() {
let parse_results = parse(raspberry_os_file());
Expand Down Expand Up @@ -553,4 +561,13 @@ mod tests {
Codename: kuma\n\
"
}

fn void_file() -> &'static str {
"LSB Version: n/a\n\
Distributor ID: Void\n\
Description: Void Linux\n\
Release: rolling\n\
Codename: n/a\n\
"
}
}
1 change: 1 addition & 0 deletions os_info/src/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ mod tests {
| Type::SUSE
| Type::Ubuntu
| Type::Ultramarine
| Type::Void
| Type::Mint => (),
os_type => {
panic!("Unexpected OS type: {}", os_type);
Expand Down
8 changes: 8 additions & 0 deletions os_info/src/linux/tests/Void/etc/os-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NAME="Void"
ID="void"
PRETTY_NAME="Void Linux"
HOME_URL="https://voidlinux.org/"
DOCUMENTATION_URL="https://docs.voidlinux.org/"
LOGO="void-logo"
ANSI_COLOR="0;38;2;71;128;97"
DISTRIB_ID="void"
4 changes: 4 additions & 0 deletions os_info/src/os_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ pub enum Type {
Ubuntu,
/// Ultramarine (<https://ultramarine-linux.org/>).
Ultramarine,
/// Void Linux (<https://en.wikipedia.org/wiki/Void_Linux>).
Void,
/// Unknown operating system.
Unknown,
/// Windows (<https://en.wikipedia.org/wiki/Microsoft_Windows>).
Expand Down Expand Up @@ -130,6 +132,7 @@ impl Display for Type {
Type::RockyLinux => write!(f, "Rocky Linux"),
Type::SUSE => write!(f, "SUSE Linux Enterprise Server"),
Type::Ultramarine => write!(f, "Ultramarine Linux"),
Type::Void => write!(f, "Void Linux"),
_ => write!(f, "{self:?}"),
}
}
Expand Down Expand Up @@ -182,6 +185,7 @@ mod tests {
(Type::SUSE, "SUSE Linux Enterprise Server"),
(Type::Ubuntu, "Ubuntu"),
(Type::Ultramarine, "Ultramarine Linux"),
(Type::Void, "Void Linux"),
(Type::Unknown, "Unknown"),
(Type::Windows, "Windows"),
];
Expand Down

0 comments on commit f691b0c

Please sign in to comment.