summaryrefslogtreecommitdiffstats
path: root/vendor/os_info/src/linux/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/os_info/src/linux/mod.rs')
-rw-r--r--vendor/os_info/src/linux/mod.rs62
1 files changed, 62 insertions, 0 deletions
diff --git a/vendor/os_info/src/linux/mod.rs b/vendor/os_info/src/linux/mod.rs
new file mode 100644
index 0000000..ac5c8cc
--- /dev/null
+++ b/vendor/os_info/src/linux/mod.rs
@@ -0,0 +1,62 @@
+mod file_release;
+mod lsb_release;
+
+use log::trace;
+
+use crate::{architecture, 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();
+ info.architecture = architecture::get();
+
+ trace!("Returning {:?}", info);
+ info
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn os_type() {
+ let version = current_platform();
+ match version.os_type() {
+ Type::Alpaquita
+ | Type::Alpine
+ | Type::Amazon
+ | Type::Arch
+ | Type::Artix
+ | Type::CentOS
+ | Type::Debian
+ | Type::EndeavourOS
+ | Type::Fedora
+ | Type::Garuda
+ | Type::Gentoo
+ | Type::Linux
+ | Type::Mabox
+ | Type::Manjaro
+ | Type::Mariner
+ | Type::NixOS
+ | Type::OpenCloudOS
+ | Type::openEuler
+ | 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);
+ }
+ }
+ }
+}