summaryrefslogtreecommitdiffstats
path: root/vendor/os_info/src/linux
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/os_info/src/linux')
-rw-r--r--vendor/os_info/src/linux/file_release.rs574
-rw-r--r--vendor/os_info/src/linux/lsb_release.rs518
-rw-r--r--vendor/os_info/src/linux/mod.rs62
-rw-r--r--vendor/os_info/src/linux/tests/Alpaquita/etc/os-release8
-rw-r--r--vendor/os_info/src/linux/tests/Alpine/etc/alpine-release1
-rw-r--r--vendor/os_info/src/linux/tests/Alpine_3_12/etc/os-release6
-rw-r--r--vendor/os_info/src/linux/tests/Amazon_1/etc/os-release9
-rw-r--r--vendor/os_info/src/linux/tests/Amazon_2/etc/os-release9
-rw-r--r--vendor/os_info/src/linux/tests/Arch/etc/os-release11
-rw-r--r--vendor/os_info/src/linux/tests/ArchARM/etc/os-release11
-rw-r--r--vendor/os_info/src/linux/tests/Artix/etc/os-release9
-rw-r--r--vendor/os_info/src/linux/tests/CentOS/etc/centos-release1
-rw-r--r--vendor/os_info/src/linux/tests/CentOS_7/etc/os-release15
-rw-r--r--vendor/os_info/src/linux/tests/CentOS_Stream/etc/os-release13
-rw-r--r--vendor/os_info/src/linux/tests/CentOS_Unknown/etc/centos-release1
-rw-r--r--vendor/os_info/src/linux/tests/Debian_11/etc/os-release9
-rw-r--r--vendor/os_info/src/linux/tests/Fedora/etc/fedora-release1
-rw-r--r--vendor/os_info/src/linux/tests/Fedora_32/etc/os-release21
-rw-r--r--vendor/os_info/src/linux/tests/Fedora_35/etc/os-release21
-rw-r--r--vendor/os_info/src/linux/tests/Fedora_Unknown/etc/fedora-release1
-rw-r--r--vendor/os_info/src/linux/tests/Mariner/etc/mariner-release2
-rw-r--r--vendor/os_info/src/linux/tests/Mariner_Unknown/etc/mariner-release1
-rw-r--r--vendor/os_info/src/linux/tests/Mint/etc/os-release12
-rw-r--r--vendor/os_info/src/linux/tests/NixOS/etc/os-release11
-rw-r--r--vendor/os_info/src/linux/tests/OpenCloudOS/etc/os-release9
-rw-r--r--vendor/os_info/src/linux/tests/OracleLinux/etc/os-release18
-rw-r--r--vendor/os_info/src/linux/tests/OracleLinux/etc/redhat-release1
-rw-r--r--vendor/os_info/src/linux/tests/RedHatEnterprise/etc/redhat-release1
-rw-r--r--vendor/os_info/src/linux/tests/RedHatEnterprise_7/etc/os-release17
-rw-r--r--vendor/os_info/src/linux/tests/RedHatEnterprise_8/etc/os-release16
-rw-r--r--vendor/os_info/src/linux/tests/RedHatEnterprise_Unknown/etc/redhat-release0
-rw-r--r--vendor/os_info/src/linux/tests/SUSE_12/etc/os-release7
-rw-r--r--vendor/os_info/src/linux/tests/SUSE_15/etc/os-release8
-rw-r--r--vendor/os_info/src/linux/tests/Ubuntu/etc/os-release12
-rw-r--r--vendor/os_info/src/linux/tests/none_invalid_os_release/etc/os-release2
-rw-r--r--vendor/os_info/src/linux/tests/openEuler/etc/os-release6
36 files changed, 1424 insertions, 0 deletions
diff --git a/vendor/os_info/src/linux/file_release.rs b/vendor/os_info/src/linux/file_release.rs
new file mode 100644
index 0000000..e9cb6c3
--- /dev/null
+++ b/vendor/os_info/src/linux/file_release.rs
@@ -0,0 +1,574 @@
+// spell-checker:ignore sles
+
+use std::{fmt, fs::File, io::Read, path::Path};
+
+use log::{trace, warn};
+
+use crate::{matcher::Matcher, Bitness, Info, Type, Version};
+
+pub fn get() -> Option<Info> {
+ retrieve(&DISTRIBUTIONS, "/")
+}
+
+fn retrieve(distributions: &[ReleaseInfo], root: &str) -> Option<Info> {
+ for release_info in distributions {
+ let path = Path::new(root).join(release_info.path);
+
+ if !path.exists() {
+ trace!("Path '{}' doesn't exist", release_info.path);
+ continue;
+ }
+
+ let mut file = match File::open(&path) {
+ Ok(val) => val,
+ Err(e) => {
+ warn!("Unable to open {:?} file: {:?}", &path, e);
+ continue;
+ }
+ };
+
+ let mut file_content = String::new();
+ if let Err(e) = file.read_to_string(&mut file_content) {
+ warn!("Unable to read {:?} file: {:?}", &path, e);
+ continue;
+ }
+
+ let os_type = (release_info.os_type)(&file_content);
+
+ // If os_type is indeterminate, try the next release_info
+ if os_type.is_none() {
+ continue;
+ }
+
+ let version = (release_info.version)(&file_content);
+
+ return Some(Info {
+ os_type: os_type.unwrap(),
+ version: version.unwrap_or(Version::Unknown),
+ bitness: Bitness::Unknown,
+ ..Default::default()
+ });
+ }
+
+ // Failed to determine os info
+ None
+}
+
+/// Struct containing information on how to parse distribution info from a release file.
+#[derive(Clone)]
+struct ReleaseInfo<'a> {
+ /// Relative path to the release file this struct corresponds to from root.
+ path: &'a str,
+
+ /// A closure that determines the os type from the release file contents.
+ os_type: for<'b> fn(&'b str) -> Option<Type>,
+
+ /// A closure that determines the os version from the release file contents.
+ version: for<'b> fn(&'b str) -> Option<Version>,
+}
+
+impl fmt::Debug for ReleaseInfo<'_> {
+ fn fmt<'a>(&'a self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("ReleaseInfo")
+ .field("path", &self.path)
+ .field("os_type", &(self.os_type as fn(&'a str) -> Option<Type>))
+ .field("version", &(self.version as fn(&'a str) -> Option<Version>))
+ .finish()
+ }
+}
+
+/// List of all supported distributions and the information on how to parse their version from the
+/// release file.
+static DISTRIBUTIONS: [ReleaseInfo; 6] = [
+ // Keep this first; most modern distributions have this file.
+ ReleaseInfo {
+ path: "etc/os-release",
+ os_type: |release| {
+ Matcher::KeyValue { key: "ID" }
+ .find(release)
+ .and_then(|id| match id.as_str() {
+ // os-release information collected from
+ // https://github.com/chef/os_release
+
+ //"almalinux" => Alma
+ "alpaquita" => Some(Type::Alpaquita),
+ "alpine" => Some(Type::Alpine),
+ "amzn" => Some(Type::Amazon),
+ //"antergos" => Antergos
+ //"aosc" => AOSC
+ "arch" => Some(Type::Arch),
+ "archarm" => Some(Type::Arch),
+ "artix" => Some(Type::Artix),
+ "centos" => Some(Type::CentOS),
+ //"clear-linux-os" => ClearLinuxOS
+ //"clearos" => ClearOS
+ //"coreos"
+ //"cumulus-linux" => Cumulus
+ "debian" => Some(Type::Debian),
+ //"devuan" => Devuan
+ //"elementary" => Elementary
+ "fedora" => Some(Type::Fedora),
+ //"gentoo" => Gentoo
+ //"ios_xr" => ios_xr
+ //"kali" => Kali
+ //"mageia" => Mageia
+ //"manjaro" => Manjaro
+ "linuxmint" => Some(Type::Mint),
+ "mariner" => Some(Type::Mariner),
+ //"nexus" => Nexus
+ "nixos" => Some(Type::NixOS),
+ "opencloudos" => Some(Type::OpenCloudOS),
+ "openEuler" => Some(Type::openEuler),
+ "ol" => Some(Type::OracleLinux),
+ "opensuse" => Some(Type::openSUSE),
+ "opensuse-leap" => Some(Type::openSUSE),
+ //"rancheros" => RancherOS
+ //"raspbian" => Raspbian
+ // note XBian also uses "raspbian"
+ "rhel" => Some(Type::RedHatEnterprise),
+ //"rocky" => Rocky
+ //"sabayon" => Sabayon
+ //"scientific" => Scientific
+ //"slackware" => Slackware
+ "sled" => Some(Type::SUSE), // SUSE desktop
+ "sles" => Some(Type::SUSE),
+ "sles_sap" => Some(Type::SUSE), // SUSE SAP
+ "ubuntu" => Some(Type::Ubuntu),
+ //"virtuozzo" => Virtuozzo
+ //"void" => Void
+ //"XCP-ng" => xcp-ng
+ //"xenenterprise" => xcp-ng
+ //"xenserver" => xcp-ng
+ _ => None,
+ })
+ },
+ version: |release| {
+ Matcher::KeyValue { key: "VERSION_ID" }
+ .find(release)
+ .map(Version::from_string)
+ },
+ },
+ // Older distributions must have their specific release file parsed.
+ ReleaseInfo {
+ path: "etc/mariner-release",
+ os_type: |_| Some(Type::Mariner),
+ version: |release| {
+ Matcher::PrefixedVersion {
+ prefix: "CBL-Mariner",
+ }
+ .find(release)
+ .map(Version::from_string)
+ },
+ },
+ ReleaseInfo {
+ path: "etc/centos-release",
+ os_type: |_| Some(Type::CentOS),
+ version: |release| {
+ Matcher::PrefixedVersion { prefix: "release" }
+ .find(release)
+ .map(Version::from_string)
+ },
+ },
+ ReleaseInfo {
+ path: "etc/fedora-release",
+ os_type: |_| Some(Type::Fedora),
+ version: |release| {
+ Matcher::PrefixedVersion { prefix: "release" }
+ .find(release)
+ .map(Version::from_string)
+ },
+ },
+ ReleaseInfo {
+ path: "etc/alpine-release",
+ os_type: |_| Some(Type::Alpine),
+ version: |release| Matcher::AllTrimmed.find(release).map(Version::from_string),
+ },
+ ReleaseInfo {
+ path: "etc/redhat-release",
+ os_type: |_| Some(Type::RedHatEnterprise),
+ version: |release| {
+ Matcher::PrefixedVersion { prefix: "release" }
+ .find(release)
+ .map(Version::from_string)
+ },
+ },
+];
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use pretty_assertions::assert_eq;
+
+ #[test]
+ fn alpaquita_os_release() {
+ let root = "src/linux/tests/Alpaquita";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Alpaquita);
+ assert_eq!(info.version, Version::Semantic(23, 0, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn alpine_3_12_os_release() {
+ let root = "src/linux/tests/Alpine_3_12";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Alpine);
+ assert_eq!(info.version, Version::Semantic(3, 12, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn alpine_release() {
+ let root = "src/linux/tests/Alpine";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Alpine);
+ assert_eq!(info.version, Version::Custom("A.B.C".to_owned()));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn amazon_1_os_release() {
+ let root = "src/linux/tests/Amazon_1";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Amazon);
+ assert_eq!(info.version, Version::Semantic(2018, 3, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn amazon_2_os_release() {
+ let root = "src/linux/tests/Amazon_2";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Amazon);
+ assert_eq!(info.version, Version::Semantic(2, 0, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn arch_os_release() {
+ let root = "src/linux/tests/Arch";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Arch);
+ assert_eq!(info.version, Version::Unknown);
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn archarm_os_release() {
+ let root = "src/linux/tests/ArchARM";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Arch);
+ assert_eq!(info.version, Version::Unknown);
+ assert_eq!(info.edition, None);
+ 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";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::CentOS);
+ assert_eq!(info.version, Version::Semantic(7, 0, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn centos_stream_os_release() {
+ let root = "src/linux/tests/CentOS_Stream";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::CentOS);
+ assert_eq!(info.version, Version::Semantic(8, 0, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn centos_release() {
+ let root = "src/linux/tests/CentOS";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::CentOS);
+ assert_eq!(info.version, Version::Custom("XX".to_owned()));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn centos_release_unknown() {
+ let root = "src/linux/tests/CentOS_Unknown";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::CentOS);
+ assert_eq!(info.version, Version::Unknown);
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn debian_11_os_release() {
+ let root = "src/linux/tests/Debian_11";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Debian);
+ assert_eq!(info.version, Version::Semantic(11, 0, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn fedora_32_os_release() {
+ let root = "src/linux/tests/Fedora_32";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Fedora);
+ assert_eq!(info.version, Version::Semantic(32, 0, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn fedora_35_os_release() {
+ let root = "src/linux/tests/Fedora_35";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Fedora);
+ assert_eq!(info.version, Version::Semantic(35, 0, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn fedora_release() {
+ let root = "src/linux/tests/Fedora";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Fedora);
+ assert_eq!(info.version, Version::Semantic(26, 0, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn fedora_release_unknown() {
+ let root = "src/linux/tests/Fedora_Unknown";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Fedora);
+ assert_eq!(info.version, Version::Unknown);
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn mariner_release() {
+ let root = "src/linux/tests/Mariner";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Mariner);
+ assert_eq!(info.version, Version::Semantic(2, 0, 20220210));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn mariner_release_unknown() {
+ let root = "src/linux/tests/Mariner_Unknown";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Mariner);
+ assert_eq!(info.version, Version::Unknown);
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn mint_os_release() {
+ let root = "src/linux/tests/Mint";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Mint);
+ assert_eq!(info.version, Version::Semantic(20, 0, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn nixos_os_release() {
+ let root = "src/linux/tests/NixOS";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::NixOS);
+ assert_eq!(
+ info.version,
+ Version::Custom("21.05pre275822.916ee862e87".to_string())
+ );
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn none_invalid_os_release() {
+ let root = "src/linux/tests/none_invalid_os_release";
+
+ let info = retrieve(&DISTRIBUTIONS, root);
+ assert_eq!(info, None);
+ }
+
+ #[test]
+ fn none_no_release() {
+ let root = "src/linux/tests/none_no_release";
+
+ let info = retrieve(&DISTRIBUTIONS, root);
+ assert_eq!(info, None);
+ }
+
+ #[test]
+ fn none_no_path() {
+ let root = "src/linux/tests/none_no_path";
+
+ let info = retrieve(&DISTRIBUTIONS, root);
+ assert_eq!(info, None);
+ }
+
+ #[test]
+ fn opencloudos_os_release() {
+ let root = "src/linux/tests/OpenCloudOS";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::OpenCloudOS);
+ assert_eq!(info.version, Version::Semantic(8, 6, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn openeuler_os_release() {
+ let root = "src/linux/tests/openEuler";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::openEuler);
+ assert_eq!(info.version, Version::Semantic(22, 3, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn oracle_linux_os_release() {
+ let root = "src/linux/tests/OracleLinux";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::OracleLinux);
+ assert_eq!(info.version, Version::Semantic(8, 1, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn rhel_8_os_release() {
+ let root = "src/linux/tests/RedHatEnterprise_8";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::RedHatEnterprise);
+ assert_eq!(info.version, Version::Semantic(8, 2, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn rhel_7_os_release() {
+ let root = "src/linux/tests/RedHatEnterprise_7";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::RedHatEnterprise);
+ assert_eq!(info.version, Version::Semantic(7, 9, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn redhat_release() {
+ let root = "src/linux/tests/RedHatEnterprise";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::RedHatEnterprise);
+ assert_eq!(info.version, Version::Custom("XX".to_owned()));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn redhat_release_unknown() {
+ let root = "src/linux/tests/RedHatEnterprise_Unknown";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::RedHatEnterprise);
+ assert_eq!(info.version, Version::Unknown);
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn suse_12_os_release() {
+ let root = "src/linux/tests/SUSE_12";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::SUSE);
+ assert_eq!(info.version, Version::Semantic(12, 5, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn suse_15_os_release() {
+ let root = "src/linux/tests/SUSE_15";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::SUSE);
+ assert_eq!(info.version, Version::Semantic(15, 2, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn ubuntu_os_release() {
+ let root = "src/linux/tests/Ubuntu";
+
+ let info = retrieve(&DISTRIBUTIONS, root).unwrap();
+ assert_eq!(info.os_type(), Type::Ubuntu);
+ assert_eq!(info.version, Version::Semantic(18, 10, 0));
+ assert_eq!(info.edition, None);
+ assert_eq!(info.codename, None);
+ }
+
+ #[test]
+ fn release_info_debug() {
+ dbg!("{:?}", &DISTRIBUTIONS[0]);
+ }
+}
diff --git a/vendor/os_info/src/linux/lsb_release.rs b/vendor/os_info/src/linux/lsb_release.rs
new file mode 100644
index 0000000..a494fce
--- /dev/null
+++ b/vendor/os_info/src/linux/lsb_release.rs
@@ -0,0 +1,518 @@
+// spell-checker:ignore codename, noarch, rhel, ootpa, maipo
+
+use std::process::Command;
+
+use log::{debug, trace};
+
+use crate::{matcher::Matcher, Info, Type, Version};
+
+pub fn get() -> Option<Info> {
+ let release = retrieve()?;
+
+ let version = match release.version.as_deref() {
+ Some("rolling") => Version::Rolling(None),
+ Some(v) => Version::Custom(v.to_owned()),
+ None => Version::Unknown,
+ };
+
+ let os_type = match release.distribution.as_ref().map(String::as_ref) {
+ Some("Alpaquita") => Type::Alpaquita,
+ 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,
+ Some("Fedora") | Some("Fedora Linux") => Type::Fedora,
+ Some("Garuda") => Type::Garuda,
+ Some("Gentoo") => Type::Gentoo,
+ Some("Linuxmint") => Type::Mint,
+ Some("MaboxLinux") => Type::Mabox,
+ Some("ManjaroLinux") => Type::Manjaro,
+ Some("Mariner") => Type::Mariner,
+ Some("NixOS") => Type::NixOS,
+ Some("OpenCloudOS") => Type::OpenCloudOS,
+ Some("openEuler") => Type::openEuler,
+ Some("openSUSE") => Type::openSUSE,
+ Some("OracleServer") => Type::OracleLinux,
+ Some("Pop") => Type::Pop,
+ Some("Raspbian") => Type::Raspbian,
+ Some("RedHatEnterprise") | Some("RedHatEnterpriseServer") => Type::RedHatEnterprise,
+ Some("Solus") => Type::Solus,
+ Some("SUSE") => Type::SUSE,
+ Some("Ubuntu") => Type::Ubuntu,
+ _ => Type::Linux,
+ };
+
+ Some(Info {
+ os_type,
+ version,
+ codename: release.codename,
+ ..Default::default()
+ })
+}
+
+struct LsbRelease {
+ pub distribution: Option<String>,
+ pub version: Option<String>,
+ pub codename: Option<String>,
+}
+
+fn retrieve() -> Option<LsbRelease> {
+ match Command::new("lsb_release").arg("-a").output() {
+ Ok(output) => {
+ trace!("lsb_release command returned {:?}", output);
+ Some(parse(&String::from_utf8_lossy(&output.stdout)))
+ }
+ Err(e) => {
+ debug!("lsb_release command failed with {:?}", e);
+ None
+ }
+ }
+}
+
+fn parse(output: &str) -> LsbRelease {
+ trace!("Trying to parse {:?}", output);
+
+ let distribution = Matcher::PrefixedWord {
+ prefix: "Distributor ID:",
+ }
+ .find(output);
+
+ let codename = Matcher::PrefixedWord {
+ prefix: "Codename:",
+ }
+ .find(output)
+ .filter(|c| c != "n/a");
+
+ let version = Matcher::PrefixedVersion { prefix: "Release:" }.find(output);
+
+ trace!(
+ "Parsed as '{:?}' distribution and '{:?}' version",
+ distribution,
+ version
+ );
+
+ LsbRelease {
+ distribution,
+ version,
+ codename,
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use pretty_assertions::assert_eq;
+
+ #[test]
+ fn debian() {
+ let parse_results = parse(file());
+ assert_eq!(parse_results.distribution, Some("Debian".to_string()));
+ assert_eq!(parse_results.version, Some("7.8".to_string()));
+ assert_eq!(parse_results.codename, Some("wheezy".to_string()));
+ }
+
+ #[test]
+ fn alpaquita() {
+ let parse_results = parse(alpaquita_file());
+ assert_eq!(parse_results.distribution, Some("Alpaquita".to_string()));
+ assert_eq!(parse_results.version, Some("23".to_string()));
+ assert_eq!(parse_results.codename, None);
+ }
+
+ #[test]
+ fn arch() {
+ let parse_results = parse(arch_file());
+ assert_eq!(parse_results.distribution, Some("Arch".to_string()));
+ assert_eq!(parse_results.version, Some("rolling".to_string()));
+ 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());
+ assert_eq!(parse_results.distribution, Some("Fedora".to_string()));
+ assert_eq!(parse_results.version, Some("26".to_string()));
+ assert_eq!(parse_results.codename, Some("TwentySix".to_string()));
+ }
+
+ #[test]
+ fn ubuntu() {
+ let parse_results = parse(ubuntu_file());
+ assert_eq!(parse_results.distribution, Some("Ubuntu".to_string()));
+ assert_eq!(parse_results.version, Some("16.04".to_string()));
+ assert_eq!(parse_results.codename, Some("xenial".to_string()));
+ }
+
+ #[test]
+ fn mint() {
+ let parse_results = parse(mint_file());
+ assert_eq!(parse_results.distribution, Some("Linuxmint".to_string()));
+ assert_eq!(parse_results.version, Some("20".to_string()));
+ assert_eq!(parse_results.codename, Some("ulyana".to_string()));
+ }
+
+ #[test]
+ fn nixos() {
+ let parse_results = parse(nixos_file());
+ assert_eq!(parse_results.distribution, Some("NixOS".to_string()));
+ assert_eq!(
+ parse_results.version,
+ Some("21.05pre275822.916ee862e87".to_string())
+ );
+ assert_eq!(parse_results.codename, Some("okapi".to_string()));
+ }
+
+ #[test]
+ fn amazon1() {
+ let parse_results = parse(amazon1_file());
+ assert_eq!(parse_results.distribution, Some("AmazonAMI".to_string()));
+ assert_eq!(parse_results.version, Some("2018.03".to_string()));
+ assert_eq!(parse_results.codename, None);
+ }
+
+ #[test]
+ fn amazon2() {
+ let parse_results = parse(amazon2_file());
+ assert_eq!(parse_results.distribution, Some("Amazon".to_string()));
+ assert_eq!(parse_results.version, Some("2".to_string()));
+ assert_eq!(parse_results.codename, Some("Karoo".to_string()));
+ }
+
+ #[test]
+ fn redhat_enterprise_8() {
+ let parse_results = parse(rhel8_file());
+ assert_eq!(
+ parse_results.distribution,
+ Some("RedHatEnterprise".to_string())
+ );
+ assert_eq!(parse_results.version, Some("8.1".to_string()));
+ assert_eq!(parse_results.codename, Some("Ootpa".to_string()));
+ }
+
+ #[test]
+ fn redhat_enterprise_7() {
+ let parse_results = parse(rhel7_file());
+ assert_eq!(
+ parse_results.distribution,
+ Some("RedHatEnterpriseServer".to_string())
+ );
+ assert_eq!(parse_results.version, Some("7.7".to_string()));
+ assert_eq!(parse_results.codename, Some("Maipo".to_string()));
+ }
+
+ #[test]
+ fn redhat_enterprise_6() {
+ let parse_results = parse(rhel6_file());
+ assert_eq!(
+ parse_results.distribution,
+ Some("RedHatEnterpriseServer".to_string())
+ );
+ assert_eq!(parse_results.version, Some("6.10".to_string()));
+ assert_eq!(parse_results.codename, Some("Santiago".to_string()));
+ }
+
+ #[test]
+ fn suse_enterprise_15_1() {
+ let parse_results = parse(suse_enterprise15_1_file());
+ assert_eq!(parse_results.distribution, Some("SUSE".to_string()));
+ assert_eq!(parse_results.version, Some("15.1".to_string()));
+ assert_eq!(parse_results.codename, None);
+ }
+
+ #[test]
+ fn suse_enterprise_12_5() {
+ let parse_results = parse(suse_enterprise12_5_file());
+ assert_eq!(parse_results.distribution, Some("SUSE".to_string()));
+ assert_eq!(parse_results.version, Some("12.5".to_string()));
+ assert_eq!(parse_results.codename, None);
+ }
+
+ #[test]
+ fn open_suse_15_1() {
+ let parse_results = parse(open_suse_15_1_file());
+ assert_eq!(parse_results.distribution, Some("openSUSE".to_string()));
+ assert_eq!(parse_results.version, Some("15.1".to_string()));
+ assert_eq!(parse_results.codename, None);
+ }
+
+ #[test]
+ fn oracle_linux_7_5() {
+ let parse_results = parse(oracle_server_linux_7_5_file());
+ assert_eq!(parse_results.distribution, Some("OracleServer".to_string()));
+ assert_eq!(parse_results.version, Some("7.5".to_string()));
+ assert_eq!(parse_results.codename, None);
+ }
+
+ #[test]
+ fn oracle_linux_8_1() {
+ let parse_results = parse(oracle_server_linux_8_1_file());
+ assert_eq!(parse_results.distribution, Some("OracleServer".to_string()));
+ assert_eq!(parse_results.version, Some("8.1".to_string()));
+ assert_eq!(parse_results.codename, None);
+ }
+
+ #[test]
+ fn pop_os_20_04_lts() {
+ let parse_results = parse(pop_os_20_04_lts_file());
+ assert_eq!(parse_results.distribution, Some("Pop".to_string()));
+ assert_eq!(parse_results.version, Some("20.04".to_string()));
+ assert_eq!(parse_results.codename, Some("focal".to_string()));
+ }
+
+ #[test]
+ fn solus_4_1() {
+ let parse_results = parse(solus_4_1_file());
+ assert_eq!(parse_results.distribution, Some("Solus".to_string()));
+ assert_eq!(parse_results.version, Some("4.1".to_string()));
+ assert_eq!(parse_results.codename, Some("fortitude".to_string()));
+ }
+
+ #[test]
+ fn manjaro() {
+ let parse_results = parse(manjaro_19_0_2_file());
+ assert_eq!(parse_results.distribution, Some("ManjaroLinux".to_string()));
+ assert_eq!(parse_results.version, Some("19.0.2".to_string()));
+ assert_eq!(parse_results.codename, None);
+ }
+
+ #[test]
+ fn mariner() {
+ let parse_results = parse(mariner_file());
+ assert_eq!(parse_results.distribution, Some("Mariner".to_string()));
+ assert_eq!(parse_results.version, Some("2.0.20220210".to_string()));
+ assert_eq!(parse_results.codename, Some("Mariner".to_string()));
+ }
+
+ #[test]
+ fn endeavouros() {
+ let parse_results = parse(endeavouros_file());
+ assert_eq!(parse_results.distribution, Some("EndeavourOS".to_string()));
+ assert_eq!(parse_results.version, Some("rolling".to_string()));
+ assert_eq!(parse_results.codename, None);
+ }
+
+ #[test]
+ fn raspbian() {
+ let parse_results = parse(raspberry_os_file());
+ assert_eq!(parse_results.distribution, Some("Raspbian".to_string()));
+ assert_eq!(parse_results.version, Some("10".to_string()));
+ assert_eq!(parse_results.codename, None);
+ }
+
+ fn file() -> &'static str {
+ "\nDistributor ID: Debian\n\
+ Description: Debian GNU/Linux 7.8 (wheezy)\n\
+ Release: 7.8\n\
+ Codename: wheezy\n\
+ "
+ }
+
+ fn alpaquita_file() -> &'static str {
+ "\nDistributor ID: Alpaquita\n\
+ Description: BellSoft Alpaquita Linux Stream 23 (musl)\n\
+ Release: 23\n\
+ Codename: n/a"
+ }
+
+ fn arch_file() -> &'static str {
+ "\nLSB Version: 1.4\n\
+ Distributor ID: Arch\n\
+ Description: Arch Linux\n\
+ Release: rolling\n\
+ 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\
+ Description: Fedora release 26 (Twenty Six)\n\
+ Release: 26\n\
+ Codename: TwentySix\n\
+ "
+ }
+
+ fn ubuntu_file() -> &'static str {
+ "Distributor ID: Ubuntu\n\
+ Description: Ubuntu 16.04.5 LTS\n\
+ Release: 16.04\n\
+ Codename: xenial"
+ }
+
+ fn mint_file() -> &'static str {
+ "Distributor ID: Linuxmint\n\
+ Description: Linux Mint 20\n\
+ Release: 20\n\
+ Codename: ulyana"
+ }
+
+ fn nixos_file() -> &'static str {
+ "Distributor ID: NixOS\n\
+ Description: NixOS 21.05 (Okapi)\n\
+ Release: 21.05pre275822.916ee862e87\n\
+ Codename: okapi"
+ }
+
+ // Amazon Linux 1 uses a separate Distributor ID and Release format from Amazon Linux 2
+ fn amazon1_file() -> &'static str {
+ "LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch\n\
+ Distributor ID: AmazonAMI\n\
+ Description: Amazon Linux AMI release 2018.03\n\
+ Release: 2018.03\n\
+ Codename: n/a\n\
+ "
+ }
+
+ // Amazon Linux 2 uses a separate Distributor ID and Release format from Amazon Linux 1
+ fn amazon2_file() -> &'static str {
+ "LSB Version: :core-4.1-amd64:core-4.1-noarch\n\
+ Distributor ID: Amazon\n\
+ Description: Amazon Linux release 2 (Karoo)\n\
+ Release: 2\n\
+ Codename: Karoo\n\
+ "
+ }
+
+ fn rhel8_file() -> &'static str {
+ "LSB Version: :core-4.1-amd64:core-4.1-noarch\n\
+ Distributor ID: RedHatEnterprise\n\
+ Description: Red Hat Enterprise Linux release 8.1 (Ootpa)\n\
+ Release: 8.1\n\
+ Codename: Ootpa\n\
+ "
+ }
+
+ fn rhel7_file() -> &'static str {
+ "LSB Version: :core-4.1-amd64:core-4.1-noarch\n\
+ Distributor ID: RedHatEnterpriseServer\n\
+ Description: Red Hat Enterprise Linux Server release 7.7 (Maipo)\n\
+ Release: 7.7\n\
+ Codename: Maipo\n\
+ "
+ }
+
+ fn rhel6_file() -> &'static str {
+ "LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch\n\
+ Distributor ID: RedHatEnterpriseServer\n\
+ Description: Red Hat Enterprise Linux Server release 6.10 (Santiago)\n\
+ Release: 6.10\n\
+ Codename: Santiago\n\
+ "
+ }
+
+ fn suse_enterprise15_1_file() -> &'static str {
+ "LSB Version: n/a\n\
+ Distributor ID: SUSE\n\
+ Description: SUSE Linux Enterprise Server 15 SP1\n\
+ Release: 15.1\n\
+ Codename: n/a\n\
+ "
+ }
+
+ fn suse_enterprise12_5_file() -> &'static str {
+ "LSB Version: n/a\n\
+ Distributor ID: SUSE\n\
+ Description: SUSE Linux Enterprise Server 12 SP5\n\
+ Release: 12.5\n\
+ Codename: n/a\n\
+ "
+ }
+
+ fn raspberry_os_file() -> &'static str {
+ "LSB Version: n/a\n\
+ Distributor ID: Raspbian\n\
+ Description: Raspbian GNU/Linux 10 (buster)\n\
+ Release: 10\n\
+ Codename: n/a\n\
+ "
+ }
+
+ fn open_suse_15_1_file() -> &'static str {
+ "LSB Version: n/a\n\
+ Distributor ID: openSUSE\n\
+ Description: openSUSE Leap 15.1\n\
+ Release: 15.1\n\
+ Codename: n/a\n\
+ "
+ }
+
+ fn oracle_server_linux_7_5_file() -> &'static str {
+ "LSB Version: :core-4.1-amd64:core-4.1-noarch\n\
+ Distributor ID: OracleServer\n\
+ Description: Oracle Linux Server release 7.5\n\
+ Release: 7.5\n\
+ Codename: n/a\n\
+ "
+ }
+
+ fn oracle_server_linux_8_1_file() -> &'static str {
+ "LSB Version: :core-4.1-amd64:core-4.1-noarch\n\
+ Distributor ID: OracleServer\n\
+ Description: Oracle Linux Server release 8.1\n\
+ Release: 8.1\n\
+ Codename: n/a\n\
+ "
+ }
+
+ fn pop_os_20_04_lts_file() -> &'static str {
+ "No LSB modules are available.\n\
+ Distributor ID: Pop\n\
+ Description: Pop!_OS 20.04 LTS\n\
+ Release: 20.04\n\
+ Codename: focal\n\
+ "
+ }
+
+ fn solus_4_1_file() -> &'static str {
+ "LSB Version: 1.4\n\
+ Distributor ID: Solus\n\
+ Description: Solus\n\
+ Release: 4.1\n\
+ Codename: fortitude\n\
+ "
+ }
+
+ fn manjaro_19_0_2_file() -> &'static str {
+ "LSB Version: n/a\n\
+ Distributor ID: ManjaroLinux\n\
+ Description: Manjaro Linux\n\
+ Release: 19.0.2\n\
+ Codename: n/a\n\
+ "
+ }
+
+ fn mariner_file() -> &'static str {
+ "LSB Version: n/a\n\
+ Distributor ID: Mariner\n\
+ Description: CBL-Mariner 2.0.20220210\n\
+ Release: 2.0.20220210\n\
+ Codename: Mariner\n\
+ "
+ }
+
+ fn endeavouros_file() -> &'static str {
+ "LSB Version: 1.4\n\
+ Distributor ID: EndeavourOS\n\
+ Description: EndeavourOS Linux\n\
+ Release: rolling\n\
+ Codename: n/a\n\
+ "
+ }
+}
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);
+ }
+ }
+ }
+}
diff --git a/vendor/os_info/src/linux/tests/Alpaquita/etc/os-release b/vendor/os_info/src/linux/tests/Alpaquita/etc/os-release
new file mode 100644
index 0000000..4c47ccd
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Alpaquita/etc/os-release
@@ -0,0 +1,8 @@
+NAME="BellSoft Alpaquita Linux Stream"
+ID=alpaquita
+ID_LIKE=alpine
+VERSION_ID=23
+PRETTY_NAME="BellSoft Alpaquita Linux Stream 23 (musl)"
+HOME_URL="https://bell-sw.com/"
+BUG_REPORT_URL="https://bell-sw.com/support/"
+LIBC_TYPE=musl
diff --git a/vendor/os_info/src/linux/tests/Alpine/etc/alpine-release b/vendor/os_info/src/linux/tests/Alpine/etc/alpine-release
new file mode 100644
index 0000000..8656231
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Alpine/etc/alpine-release
@@ -0,0 +1 @@
+A.B.C
diff --git a/vendor/os_info/src/linux/tests/Alpine_3_12/etc/os-release b/vendor/os_info/src/linux/tests/Alpine_3_12/etc/os-release
new file mode 100644
index 0000000..c2e6bc6
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Alpine_3_12/etc/os-release
@@ -0,0 +1,6 @@
+NAME="Alpine Linux"
+ID=alpine
+VERSION_ID=3.12.0
+PRETTY_NAME="Alpine Linux v3.12"
+HOME_URL="https://alpinelinux.org/"
+BUG_REPORT_URL="https://bugs.alpinelinux.org/"
diff --git a/vendor/os_info/src/linux/tests/Amazon_1/etc/os-release b/vendor/os_info/src/linux/tests/Amazon_1/etc/os-release
new file mode 100644
index 0000000..b2b1a07
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Amazon_1/etc/os-release
@@ -0,0 +1,9 @@
+NAME="Amazon Linux AMI"
+VERSION="2018.03"
+ID="amzn"
+ID_LIKE="rhel fedora"
+VERSION_ID="2018.03"
+PRETTY_NAME="Amazon Linux AMI 2018.03"
+ANSI_COLOR="0;33"
+CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
+HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
diff --git a/vendor/os_info/src/linux/tests/Amazon_2/etc/os-release b/vendor/os_info/src/linux/tests/Amazon_2/etc/os-release
new file mode 100644
index 0000000..07a4507
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Amazon_2/etc/os-release
@@ -0,0 +1,9 @@
+NAME="Amazon Linux"
+VERSION="2"
+ID="amzn"
+ID_LIKE="centos rhel fedora"
+VERSION_ID="2"
+PRETTY_NAME="Amazon Linux 2"
+ANSI_COLOR="0;33"
+CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
+HOME_URL="https://amazonlinux.com/"
diff --git a/vendor/os_info/src/linux/tests/Arch/etc/os-release b/vendor/os_info/src/linux/tests/Arch/etc/os-release
new file mode 100644
index 0000000..8662a54
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Arch/etc/os-release
@@ -0,0 +1,11 @@
+NAME="Arch Linux"
+PRETTY_NAME="Arch Linux"
+ID=arch
+BUILD_ID=rolling
+ANSI_COLOR="38;2;23;147;209"
+HOME_URL="https://archlinux.org/"
+DOCUMENTATION_URL="https://wiki.archlinux.org/"
+SUPPORT_URL="https://bbs.archlinux.org/"
+BUG_REPORT_URL="https://bugs.archlinux.org/"
+PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
+LOGO=archlinux-logo
diff --git a/vendor/os_info/src/linux/tests/ArchARM/etc/os-release b/vendor/os_info/src/linux/tests/ArchARM/etc/os-release
new file mode 100644
index 0000000..6218b0e
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/ArchARM/etc/os-release
@@ -0,0 +1,11 @@
+NAME="Arch Linux ARM"
+PRETTY_NAME="Arch Linux ARM"
+ID=archarm
+ID_LIKE=arch
+BUILD_ID=rolling
+ANSI_COLOR="38;2;23;147;209"
+HOME_URL="https://archlinuxarm.org/"
+DOCUMENTATION_URL="https://archlinuxarm.org/wiki"
+SUPPORT_URL="https://archlinuxarm.org/forum"
+BUG_REPORT_URL="https://github.com/archlinuxarm/PKGBUILDs/issues"
+LOGO=archlinux-logo
diff --git a/vendor/os_info/src/linux/tests/Artix/etc/os-release b/vendor/os_info/src/linux/tests/Artix/etc/os-release
new file mode 100644
index 0000000..26279ce
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Artix/etc/os-release
@@ -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"
diff --git a/vendor/os_info/src/linux/tests/CentOS/etc/centos-release b/vendor/os_info/src/linux/tests/CentOS/etc/centos-release
new file mode 100644
index 0000000..359ef00
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/CentOS/etc/centos-release
@@ -0,0 +1 @@
+Centos Linux release XX
diff --git a/vendor/os_info/src/linux/tests/CentOS_7/etc/os-release b/vendor/os_info/src/linux/tests/CentOS_7/etc/os-release
new file mode 100644
index 0000000..c276e3a
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/CentOS_7/etc/os-release
@@ -0,0 +1,15 @@
+NAME="CentOS Linux"
+VERSION="7 (Core)"
+ID="centos"
+ID_LIKE="rhel fedora"
+VERSION_ID="7"
+PRETTY_NAME="CentOS Linux 7 (Core)"
+ANSI_COLOR="0;31"
+CPE_NAME="cpe:/o:centos:centos:7"
+HOME_URL="https://www.centos.org/"
+BUG_REPORT_URL="https://bugs.centos.org/"
+
+CENTOS_MANTISBT_PROJECT="CentOS-7"
+CENTOS_MANTISBT_PROJECT_VERSION="7"
+REDHAT_SUPPORT_PRODUCT="centos"
+REDHAT_SUPPORT_PRODUCT_VERSION="7"
diff --git a/vendor/os_info/src/linux/tests/CentOS_Stream/etc/os-release b/vendor/os_info/src/linux/tests/CentOS_Stream/etc/os-release
new file mode 100644
index 0000000..8948e12
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/CentOS_Stream/etc/os-release
@@ -0,0 +1,13 @@
+NAME="CentOS Stream"
+VERSION="8"
+ID="centos"
+ID_LIKE="rhel fedora"
+VERSION_ID="8"
+PLATFORM_ID="platform:el8"
+PRETTY_NAME="CentOS Stream 8"
+ANSI_COLOR="0;31"
+CPE_NAME="cpe:/o:centos:centos:8"
+HOME_URL="https://centos.org/"
+BUG_REPORT_URL="https://bugzilla.redhat.com/"
+REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
+REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
diff --git a/vendor/os_info/src/linux/tests/CentOS_Unknown/etc/centos-release b/vendor/os_info/src/linux/tests/CentOS_Unknown/etc/centos-release
new file mode 100644
index 0000000..e6b865b
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/CentOS_Unknown/etc/centos-release
@@ -0,0 +1 @@
+Centos Linux
diff --git a/vendor/os_info/src/linux/tests/Debian_11/etc/os-release b/vendor/os_info/src/linux/tests/Debian_11/etc/os-release
new file mode 100644
index 0000000..611cf74
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Debian_11/etc/os-release
@@ -0,0 +1,9 @@
+PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
+NAME="Debian GNU/Linux"
+VERSION_ID="11"
+VERSION="11 (bullseye)"
+VERSION_CODENAME=bullseye
+ID=debian
+HOME_URL="https://www.debian.org/"
+SUPPORT_URL="https://www.debian.org/support"
+BUG_REPORT_URL="https://bugs.debian.org/"
diff --git a/vendor/os_info/src/linux/tests/Fedora/etc/fedora-release b/vendor/os_info/src/linux/tests/Fedora/etc/fedora-release
new file mode 100644
index 0000000..f2641f4
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Fedora/etc/fedora-release
@@ -0,0 +1 @@
+Fedora release 26 (Twenty Six)
diff --git a/vendor/os_info/src/linux/tests/Fedora_32/etc/os-release b/vendor/os_info/src/linux/tests/Fedora_32/etc/os-release
new file mode 100644
index 0000000..234ecf1
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Fedora_32/etc/os-release
@@ -0,0 +1,21 @@
+NAME=Fedora
+VERSION="32 (Cloud Edition)"
+ID=fedora
+VERSION_ID=32
+VERSION_CODENAME=""
+PLATFORM_ID="platform:f32"
+PRETTY_NAME="Fedora 32 (Cloud Edition)"
+ANSI_COLOR="0;34"
+LOGO=fedora-logo-icon
+CPE_NAME="cpe:/o:fedoraproject:fedora:32"
+HOME_URL="https://fedoraproject.org/"
+DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/"
+SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
+BUG_REPORT_URL="https://bugzilla.redhat.com/"
+REDHAT_BUGZILLA_PRODUCT="Fedora"
+REDHAT_BUGZILLA_PRODUCT_VERSION=32
+REDHAT_SUPPORT_PRODUCT="Fedora"
+REDHAT_SUPPORT_PRODUCT_VERSION=32
+PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
+VARIANT="Cloud Edition"
+VARIANT_ID=cloud
diff --git a/vendor/os_info/src/linux/tests/Fedora_35/etc/os-release b/vendor/os_info/src/linux/tests/Fedora_35/etc/os-release
new file mode 100644
index 0000000..9178d6d
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Fedora_35/etc/os-release
@@ -0,0 +1,21 @@
+NAME="Fedora Linux"
+VERSION="35 (Workstation Edition)"
+ID=fedora
+VERSION_ID=35
+VERSION_CODENAME=""
+PLATFORM_ID="platform:f35"
+PRETTY_NAME="Fedora Linux 35 (Workstation Edition)"
+ANSI_COLOR="0;38;2;60;110;180"
+LOGO=fedora-logo-icon
+CPE_NAME="cpe:/o:fedoraproject:fedora:35"
+HOME_URL="https://fedoraproject.org/"
+DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f35/system-administrators-guide/"
+SUPPORT_URL="https://ask.fedoraproject.org/"
+BUG_REPORT_URL="https://bugzilla.redhat.com/"
+REDHAT_BUGZILLA_PRODUCT="Fedora"
+REDHAT_BUGZILLA_PRODUCT_VERSION=35
+REDHAT_SUPPORT_PRODUCT="Fedora"
+REDHAT_SUPPORT_PRODUCT_VERSION=35
+PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
+VARIANT="Workstation Edition"
+VARIANT_ID=workstation
diff --git a/vendor/os_info/src/linux/tests/Fedora_Unknown/etc/fedora-release b/vendor/os_info/src/linux/tests/Fedora_Unknown/etc/fedora-release
new file mode 100644
index 0000000..adc0115
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Fedora_Unknown/etc/fedora-release
@@ -0,0 +1 @@
+Fedora (Foo Bar)
diff --git a/vendor/os_info/src/linux/tests/Mariner/etc/mariner-release b/vendor/os_info/src/linux/tests/Mariner/etc/mariner-release
new file mode 100644
index 0000000..f4bceb4
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Mariner/etc/mariner-release
@@ -0,0 +1,2 @@
+CBL-Mariner 2.0.20220210
+MARINER_BUILD_NUMBER=0d11c66
diff --git a/vendor/os_info/src/linux/tests/Mariner_Unknown/etc/mariner-release b/vendor/os_info/src/linux/tests/Mariner_Unknown/etc/mariner-release
new file mode 100644
index 0000000..d64fd53
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Mariner_Unknown/etc/mariner-release
@@ -0,0 +1 @@
+CBL-Mariner \ No newline at end of file
diff --git a/vendor/os_info/src/linux/tests/Mint/etc/os-release b/vendor/os_info/src/linux/tests/Mint/etc/os-release
new file mode 100644
index 0000000..825d928
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Mint/etc/os-release
@@ -0,0 +1,12 @@
+NAME="Linux Mint"
+VERSION="20 (Ulyana)"
+ID=linuxmint
+ID_LIKE=ubuntu
+PRETTY_NAME="Linux Mint 20"
+VERSION_ID="20"
+HOME_URL="https://www.linuxmint.com/"
+SUPPORT_URL="https://forums.linuxmint.com/"
+BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
+PRIVACY_POLICY_URL="https://www.linuxmint.com/"
+VERSION_CODENAME=ulyana
+UBUNTU_CODENAME=focal
diff --git a/vendor/os_info/src/linux/tests/NixOS/etc/os-release b/vendor/os_info/src/linux/tests/NixOS/etc/os-release
new file mode 100644
index 0000000..b93cf4d
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/NixOS/etc/os-release
@@ -0,0 +1,11 @@
+NAME=NixOS
+ID=nixos
+VERSION="21.05pre275822.916ee862e87 (Okapi)"
+VERSION_CODENAME=okapi
+VERSION_ID="21.05pre275822.916ee862e87"
+PRETTY_NAME="NixOS 21.05 (Okapi)"
+LOGO="nix-snowflake"
+HOME_URL="https://nixos.org/"
+DOCUMENTATION_URL="https://nixos.org/learn.html"
+SUPPORT_URL="https://nixos.org/community.html"
+BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"
diff --git a/vendor/os_info/src/linux/tests/OpenCloudOS/etc/os-release b/vendor/os_info/src/linux/tests/OpenCloudOS/etc/os-release
new file mode 100644
index 0000000..4bc4580
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/OpenCloudOS/etc/os-release
@@ -0,0 +1,9 @@
+NAME="OpenCloudOS"
+VERSION="8.6"
+ID="opencloudos"
+ID_LIKE="rhel fedora centos"
+VERSION_ID="8.6"
+PLATFORM_ID="platform:oc8"
+PRETTY_NAME="OpenCloudOS 8.6"
+ANSI_COLOR="0;31"
+CPE_NAME="cpe:/o:opencloudos:opencloudos:8" \ No newline at end of file
diff --git a/vendor/os_info/src/linux/tests/OracleLinux/etc/os-release b/vendor/os_info/src/linux/tests/OracleLinux/etc/os-release
new file mode 100644
index 0000000..1594788
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/OracleLinux/etc/os-release
@@ -0,0 +1,18 @@
+NAME="Oracle Linux Server"
+VERSION="8.1"
+ID="ol"
+ID_LIKE="fedora"
+VARIANT="Server"
+VARIANT_ID="server"
+VERSION_ID="8.1"
+PLATFORM_ID="platform:el8"
+PRETTY_NAME="Oracle Linux Server 8.1"
+ANSI_COLOR="0;31"
+CPE_NAME="cpe:/o:oracle:linux:8:1:server"
+HOME_URL="https://linux.oracle.com/"
+BUG_REPORT_URL="https://bugzilla.oracle.com/"
+
+ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
+ORACLE_BUGZILLA_PRODUCT_VERSION=8.1
+ORACLE_SUPPORT_PRODUCT="Oracle Linux"
+ORACLE_SUPPORT_PRODUCT_VERSION=8.1
diff --git a/vendor/os_info/src/linux/tests/OracleLinux/etc/redhat-release b/vendor/os_info/src/linux/tests/OracleLinux/etc/redhat-release
new file mode 100644
index 0000000..994041e
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/OracleLinux/etc/redhat-release
@@ -0,0 +1 @@
+Redhat Linux release XX \ No newline at end of file
diff --git a/vendor/os_info/src/linux/tests/RedHatEnterprise/etc/redhat-release b/vendor/os_info/src/linux/tests/RedHatEnterprise/etc/redhat-release
new file mode 100644
index 0000000..ff4da1d
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/RedHatEnterprise/etc/redhat-release
@@ -0,0 +1 @@
+Redhat Linux release XX
diff --git a/vendor/os_info/src/linux/tests/RedHatEnterprise_7/etc/os-release b/vendor/os_info/src/linux/tests/RedHatEnterprise_7/etc/os-release
new file mode 100644
index 0000000..ec038b1
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/RedHatEnterprise_7/etc/os-release
@@ -0,0 +1,17 @@
+NAME="Red Hat Enterprise Linux Server"
+VERSION="7.9 (Maipo)"
+ID="rhel"
+ID_LIKE="fedora"
+VARIANT="Server"
+VARIANT_ID="server"
+VERSION_ID="7.9"
+PRETTY_NAME="Red Hat Enterprise Linux Server 7.9 (Maipo)"
+ANSI_COLOR="0;31"
+CPE_NAME="cpe:/o:redhat:enterprise_linux:7.9:GA:server"
+HOME_URL="https://www.redhat.com/"
+BUG_REPORT_URL="https://bugzilla.redhat.com/"
+
+REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
+REDHAT_BUGZILLA_PRODUCT_VERSION=7.9
+REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
+REDHAT_SUPPORT_PRODUCT_VERSION="7.9"
diff --git a/vendor/os_info/src/linux/tests/RedHatEnterprise_8/etc/os-release b/vendor/os_info/src/linux/tests/RedHatEnterprise_8/etc/os-release
new file mode 100644
index 0000000..1d5515b
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/RedHatEnterprise_8/etc/os-release
@@ -0,0 +1,16 @@
+NAME="Red Hat Enterprise Linux"
+VERSION="8.2 (Ootpa)"
+ID="rhel"
+ID_LIKE="fedora"
+VERSION_ID="8.2"
+PLATFORM_ID="platform:el8"
+PRETTY_NAME="Red Hat Enterprise Linux 8.2 (Ootpa)"
+ANSI_COLOR="0;31"
+CPE_NAME="cpe:/o:redhat:enterprise_linux:8.2:GA"
+HOME_URL="https://www.redhat.com/"
+BUG_REPORT_URL="https://bugzilla.redhat.com/"
+
+REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
+REDHAT_BUGZILLA_PRODUCT_VERSION=8.2
+REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
+REDHAT_SUPPORT_PRODUCT_VERSION="8.2"
diff --git a/vendor/os_info/src/linux/tests/RedHatEnterprise_Unknown/etc/redhat-release b/vendor/os_info/src/linux/tests/RedHatEnterprise_Unknown/etc/redhat-release
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/RedHatEnterprise_Unknown/etc/redhat-release
diff --git a/vendor/os_info/src/linux/tests/SUSE_12/etc/os-release b/vendor/os_info/src/linux/tests/SUSE_12/etc/os-release
new file mode 100644
index 0000000..2de3f28
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/SUSE_12/etc/os-release
@@ -0,0 +1,7 @@
+NAME="SLES"
+VERSION="12-SP5"
+VERSION_ID="12.5"
+PRETTY_NAME="SUSE Linux Enterprise Server 12 SP5"
+ID="sles"
+ANSI_COLOR="0;32"
+CPE_NAME="cpe:/o:suse:sles:12:sp5"
diff --git a/vendor/os_info/src/linux/tests/SUSE_15/etc/os-release b/vendor/os_info/src/linux/tests/SUSE_15/etc/os-release
new file mode 100644
index 0000000..54fafb5
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/SUSE_15/etc/os-release
@@ -0,0 +1,8 @@
+NAME="SLES"
+VERSION="15-SP2"
+VERSION_ID="15.2"
+PRETTY_NAME="SUSE Linux Enterprise Server 15 SP2"
+ID="sles"
+ID_LIKE="suse"
+ANSI_COLOR="0;32"
+CPE_NAME="cpe:/o:suse:sles:15:sp2"
diff --git a/vendor/os_info/src/linux/tests/Ubuntu/etc/os-release b/vendor/os_info/src/linux/tests/Ubuntu/etc/os-release
new file mode 100644
index 0000000..2369e58
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/Ubuntu/etc/os-release
@@ -0,0 +1,12 @@
+NAME="Ubuntu"
+VERSION="18.10 (Cosmic Cuttlefish)"
+ID=ubuntu
+ID_LIKE=debian
+PRETTY_NAME="Ubuntu 18.10"
+VERSION_ID="18.10"
+HOME_URL="https://www.ubuntu.com/"
+SUPPORT_URL="https://help.ubuntu.com/"
+BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
+PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
+VERSION_CODENAME=cosmic
+UBUNTU_CODENAME=cosmic
diff --git a/vendor/os_info/src/linux/tests/none_invalid_os_release/etc/os-release b/vendor/os_info/src/linux/tests/none_invalid_os_release/etc/os-release
new file mode 100644
index 0000000..92258e6
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/none_invalid_os_release/etc/os-release
@@ -0,0 +1,2 @@
+ID="Lorem ipsum dolor sit amet"
+VERSION_ID="It's all greek to me"
diff --git a/vendor/os_info/src/linux/tests/openEuler/etc/os-release b/vendor/os_info/src/linux/tests/openEuler/etc/os-release
new file mode 100644
index 0000000..bd72dd8
--- /dev/null
+++ b/vendor/os_info/src/linux/tests/openEuler/etc/os-release
@@ -0,0 +1,6 @@
+NAME="openEuler"
+VERSION="22.03 LTS"
+ID="openEuler"
+VERSION_ID="22.03"
+PRETTY_NAME="openEuler 22.03 LTS"
+ANSI_COLOR="0;31" \ No newline at end of file