os_info/linux/
mod.rs

1mod file_release;
2mod lsb_release;
3
4use log::trace;
5
6use crate::{architecture, bitness, Info, Type};
7
8pub fn current_platform() -> Info {
9    trace!("linux::current_platform is called");
10
11    let mut info = lsb_release::get()
12        .or_else(file_release::get)
13        .unwrap_or_else(|| Info::with_type(Type::Linux));
14    info.bitness = bitness::get();
15    info.architecture = architecture::get();
16
17    trace!("Returning {:?}", info);
18    info
19}
20
21#[cfg(test)]
22mod tests {
23    use super::*;
24
25    #[test]
26    fn os_type() {
27        let version = current_platform();
28        match version.os_type() {
29            Type::AlmaLinux
30            | Type::Alpaquita
31            | Type::Alpine
32            | Type::Amazon
33            | Type::Arch
34            | Type::Artix
35            | Type::Bluefin
36            | Type::CachyOS
37            | Type::CentOS
38            | Type::Debian
39            | Type::EndeavourOS
40            | Type::Fedora
41            | Type::Garuda
42            | Type::Gentoo
43            | Type::Kali
44            | Type::Linux
45            | Type::Mabox
46            | Type::Manjaro
47            | Type::Mariner
48            | Type::NixOS
49            | Type::Nobara
50            | Type::Uos
51            | Type::OpenCloudOS
52            | Type::openEuler
53            | Type::openSUSE
54            | Type::OracleLinux
55            | Type::Pop
56            | Type::Raspbian
57            | Type::Redhat
58            | Type::RedHatEnterprise
59            | Type::RockyLinux
60            | Type::Solus
61            | Type::SUSE
62            | Type::Ubuntu
63            | Type::Ultramarine
64            | Type::Void
65            | Type::Mint => (),
66            os_type => {
67                panic!("Unexpected OS type: {}", os_type);
68            }
69        }
70    }
71}