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