summaryrefslogtreecommitdiffstats
path: root/vendor/os_info/src
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/os_info/src')
-rw-r--r--vendor/os_info/src/architecture.rs32
-rw-r--r--vendor/os_info/src/info.rs40
-rw-r--r--vendor/os_info/src/lib.rs10
-rw-r--r--vendor/os_info/src/linux/file_release.rs85
-rw-r--r--vendor/os_info/src/linux/lsb_release.rs36
-rw-r--r--vendor/os_info/src/linux/mod.rs10
-rw-r--r--vendor/os_info/src/linux/tests/Alpaquita/etc/os-release8
-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/Debian_11/etc/os-release9
-rw-r--r--vendor/os_info/src/linux/tests/OpenCloudOS/etc/os-release9
-rw-r--r--vendor/os_info/src/linux/tests/openEuler/etc/os-release6
-rw-r--r--vendor/os_info/src/macos/mod.rs3
-rw-r--r--vendor/os_info/src/netbsd/mod.rs3
-rw-r--r--vendor/os_info/src/openbsd/mod.rs3
-rw-r--r--vendor/os_info/src/os_type.rs16
-rw-r--r--vendor/os_info/src/version.rs8
-rw-r--r--vendor/os_info/src/windows/winapi.rs38
19 files changed, 319 insertions, 28 deletions
diff --git a/vendor/os_info/src/architecture.rs b/vendor/os_info/src/architecture.rs
new file mode 100644
index 000000000..d6de08b2c
--- /dev/null
+++ b/vendor/os_info/src/architecture.rs
@@ -0,0 +1,32 @@
+use std::process::Command;
+
+use log::error;
+
+pub fn get() -> Option<String> {
+ Command::new("uname")
+ .arg("-m")
+ .output()
+ .map_err(|e| {
+ error!("Cannot invoke 'uname` to get architecture type: {:?}", e);
+ })
+ .ok()
+ .and_then(|out| {
+ if out.status.success() {
+ Some(String::from_utf8_lossy(&out.stdout).trim_end().to_owned())
+ } else {
+ log::error!("'uname' invocation error: {:?}", out);
+ None
+ }
+ })
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn uname_nonempty() {
+ let val = get().expect("uname failed");
+ assert!(!val.is_empty());
+ }
+}
diff --git a/vendor/os_info/src/info.rs b/vendor/os_info/src/info.rs
index 85b699330..91e6cc3cb 100644
--- a/vendor/os_info/src/info.rs
+++ b/vendor/os_info/src/info.rs
@@ -15,7 +15,7 @@ use super::{Bitness, Type, Version};
/// use os_info;
///
/// let info = os_info::get();
-/// println!("OS information: {}", info);
+/// println!("OS information: {info}");
/// ```
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
@@ -26,11 +26,13 @@ pub struct Info {
pub(crate) version: Version,
/// Operating system edition.
pub(crate) edition: Option<String>,
- /// Operating system edition.
+ /// Operating system codename.
pub(crate) codename: Option<String>,
/// Operating system architecture in terms of how many bits compose the basic values it can deal
/// with. See `Bitness` for details.
pub(crate) bitness: Bitness,
+ /// Processor architecture.
+ pub(crate) architecture: Option<String>,
}
impl Info {
@@ -47,6 +49,7 @@ impl Info {
/// assert_eq!(None, info.edition());
/// assert_eq!(None, info.codename());
/// assert_eq!(Bitness::Unknown, info.bitness());
+ /// assert_eq!(None, info.architecture());
/// ```
pub fn unknown() -> Self {
Self {
@@ -55,6 +58,7 @@ impl Info {
edition: None,
codename: None,
bitness: Bitness::Unknown,
+ architecture: None,
}
}
@@ -72,6 +76,7 @@ impl Info {
/// assert_eq!(None, info.edition());
/// assert_eq!(None, info.codename());
/// assert_eq!(Bitness::Unknown, info.bitness());
+ /// assert_eq!(None, info.architecture());
/// ```
pub fn with_type(os_type: Type) -> Self {
Self {
@@ -147,6 +152,19 @@ impl Info {
pub fn bitness(&self) -> Bitness {
self.bitness
}
+
+ /// Returns operating system architecture.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use os_info::Info;
+ ///
+ /// let info = Info::unknown();
+ /// assert_eq!(None, info.architecture());
+ pub fn architecture(&self) -> Option<&str> {
+ self.architecture.as_ref().map(String::as_ref)
+ }
}
impl Default for Info {
@@ -162,10 +180,10 @@ impl Display for Info {
write!(f, " {}", self.version)?;
}
if let Some(ref edition) = self.edition {
- write!(f, " ({})", edition)?;
+ write!(f, " ({edition})")?;
}
if let Some(ref codename) = self.codename {
- write!(f, " ({})", codename)?;
+ write!(f, " ({codename})")?;
}
write!(f, " [{}]", self.bitness)
}
@@ -184,16 +202,19 @@ mod tests {
assert_eq!(None, info.edition());
assert_eq!(None, info.codename());
assert_eq!(Bitness::Unknown, info.bitness());
+ assert_eq!(None, info.architecture());
}
#[test]
fn with_type() {
let types = [
Type::Redox,
+ Type::Alpaquita,
Type::Alpine,
Type::Amazon,
Type::Android,
Type::Arch,
+ Type::Artix,
Type::CentOS,
Type::Debian,
Type::Emscripten,
@@ -205,6 +226,8 @@ mod tests {
Type::Manjaro,
Type::Mariner,
Type::NixOS,
+ Type::OpenCloudOS,
+ Type::openEuler,
Type::openSUSE,
Type::OracleLinux,
Type::Pop,
@@ -262,6 +285,14 @@ mod tests {
),
(
Info {
+ os_type: Type::Artix,
+ version: Version::Rolling(None),
+ ..Default::default()
+ },
+ "Artix Linux Rolling Release [unknown bitness]",
+ ),
+ (
+ Info {
os_type: Type::Manjaro,
version: Version::Rolling(Some("2020.05.24".to_owned())),
..Default::default()
@@ -299,6 +330,7 @@ mod tests {
edition: Some("edition".to_owned()),
codename: Some("codename".to_owned()),
bitness: Bitness::X64,
+ architecture: Some("architecture".to_owned()),
},
"Mac OS 10.2.0 (edition) (codename) [64-bit]",
),
diff --git a/vendor/os_info/src/lib.rs b/vendor/os_info/src/lib.rs
index a1a6746ec..83c7f3875 100644
--- a/vendor/os_info/src/lib.rs
+++ b/vendor/os_info/src/lib.rs
@@ -70,6 +70,13 @@ mod imp;
#[path = "unknown/mod.rs"]
mod imp;
+#[cfg(any(
+ target_os = "linux",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd"
+))]
+mod architecture;
mod bitness;
mod info;
#[cfg(not(windows))]
@@ -97,7 +104,7 @@ pub use crate::{bitness::Bitness, info::Info, os_type::Type, version::Version};
/// let info = os_info::get();
///
/// // Print full information:
-/// println!("OS information: {}", info);
+/// println!("OS information: {info}");
///
/// // Print information separately:
/// println!("Type: {}", info.os_type());
@@ -105,6 +112,7 @@ pub use crate::{bitness::Bitness, info::Info, os_type::Type, version::Version};
/// println!("Edition: {:?}", info.edition());
/// println!("Codename: {:?}", info.codename());
/// println!("Bitness: {}", info.bitness());
+/// println!("Architecture: {:?}", info.architecture());
/// ```
pub fn get() -> Info {
imp::current_platform()
diff --git a/vendor/os_info/src/linux/file_release.rs b/vendor/os_info/src/linux/file_release.rs
index 119c85560..e9cb6c3f7 100644
--- a/vendor/os_info/src/linux/file_release.rs
+++ b/vendor/os_info/src/linux/file_release.rs
@@ -91,18 +91,20 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
// 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),
- //"artix" => Artix
+ "archarm" => Some(Type::Arch),
+ "artix" => Some(Type::Artix),
"centos" => Some(Type::CentOS),
//"clear-linux-os" => ClearLinuxOS
//"clearos" => ClearOS
//"coreos"
//"cumulus-linux" => Cumulus
- //"debian" => Debian
+ "debian" => Some(Type::Debian),
//"devuan" => Devuan
//"elementary" => Elementary
"fedora" => Some(Type::Fedora),
@@ -115,6 +117,8 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
"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),
@@ -196,6 +200,17 @@ mod tests {
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";
@@ -240,6 +255,39 @@ mod tests {
}
#[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";
@@ -284,6 +332,17 @@ mod tests {
}
#[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";
@@ -399,6 +458,28 @@ mod tests {
}
#[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";
diff --git a/vendor/os_info/src/linux/lsb_release.rs b/vendor/os_info/src/linux/lsb_release.rs
index 58a96ae2a..a494fce68 100644
--- a/vendor/os_info/src/linux/lsb_release.rs
+++ b/vendor/os_info/src/linux/lsb_release.rs
@@ -16,8 +16,10 @@ pub fn get() -> Option<Info> {
};
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,
@@ -25,9 +27,12 @@ pub fn get() -> Option<Info> {
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,
@@ -109,6 +114,14 @@ mod tests {
}
#[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()));
@@ -117,6 +130,14 @@ mod tests {
}
#[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()));
@@ -296,6 +317,13 @@ mod tests {
"
}
+ 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\
@@ -304,6 +332,14 @@ mod tests {
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\
diff --git a/vendor/os_info/src/linux/mod.rs b/vendor/os_info/src/linux/mod.rs
index 64d488342..ac5c8cc00 100644
--- a/vendor/os_info/src/linux/mod.rs
+++ b/vendor/os_info/src/linux/mod.rs
@@ -3,7 +3,7 @@ mod lsb_release;
use log::trace;
-use crate::{bitness, Info, Type};
+use crate::{architecture, bitness, Info, Type};
pub fn current_platform() -> Info {
trace!("linux::current_platform is called");
@@ -12,6 +12,7 @@ pub fn current_platform() -> Info {
.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
@@ -25,9 +26,11 @@ mod tests {
fn os_type() {
let version = current_platform();
match version.os_type() {
- Type::Alpine
+ Type::Alpaquita
+ | Type::Alpine
| Type::Amazon
| Type::Arch
+ | Type::Artix
| Type::CentOS
| Type::Debian
| Type::EndeavourOS
@@ -35,9 +38,12 @@ mod tests {
| Type::Garuda
| Type::Gentoo
| Type::Linux
+ | Type::Mabox
| Type::Manjaro
| Type::Mariner
| Type::NixOS
+ | Type::OpenCloudOS
+ | Type::openEuler
| Type::openSUSE
| Type::OracleLinux
| Type::Pop
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 000000000..4c47ccda3
--- /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/Arch/etc/os-release b/vendor/os_info/src/linux/tests/Arch/etc/os-release
new file mode 100644
index 000000000..8662a54df
--- /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 000000000..6218b0e2c
--- /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 000000000..26279cec5
--- /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/Debian_11/etc/os-release b/vendor/os_info/src/linux/tests/Debian_11/etc/os-release
new file mode 100644
index 000000000..611cf746b
--- /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/OpenCloudOS/etc/os-release b/vendor/os_info/src/linux/tests/OpenCloudOS/etc/os-release
new file mode 100644
index 000000000..4bc4580f6
--- /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/openEuler/etc/os-release b/vendor/os_info/src/linux/tests/openEuler/etc/os-release
new file mode 100644
index 000000000..bd72dd829
--- /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
diff --git a/vendor/os_info/src/macos/mod.rs b/vendor/os_info/src/macos/mod.rs
index 0c93a9713..aef79d274 100644
--- a/vendor/os_info/src/macos/mod.rs
+++ b/vendor/os_info/src/macos/mod.rs
@@ -2,7 +2,7 @@ use std::process::Command;
use log::{trace, warn};
-use crate::{bitness, matcher::Matcher, Info, Type, Version};
+use crate::{architecture, bitness, matcher::Matcher, Info, Type, Version};
pub fn current_platform() -> Info {
trace!("macos::current_platform is called");
@@ -11,6 +11,7 @@ pub fn current_platform() -> Info {
os_type: Type::Macos,
version: version(),
bitness: bitness::get(),
+ architecture: architecture::get(),
..Default::default()
};
trace!("Returning {:?}", info);
diff --git a/vendor/os_info/src/netbsd/mod.rs b/vendor/os_info/src/netbsd/mod.rs
index d5ab97bfb..7031820b9 100644
--- a/vendor/os_info/src/netbsd/mod.rs
+++ b/vendor/os_info/src/netbsd/mod.rs
@@ -2,7 +2,7 @@ use std::process::Command;
use log::{error, trace};
-use crate::{bitness, uname::uname, Info, Type, Version};
+use crate::{architecture, bitness, uname::uname, Info, Type, Version};
pub fn current_platform() -> Info {
trace!("netbsd::current_platform is called");
@@ -15,6 +15,7 @@ pub fn current_platform() -> Info {
os_type: Type::NetBSD,
version,
bitness: bitness::get(),
+ architecture: architecture::get(),
..Default::default()
};
diff --git a/vendor/os_info/src/openbsd/mod.rs b/vendor/os_info/src/openbsd/mod.rs
index 897fc4aeb..c9eeee4d9 100644
--- a/vendor/os_info/src/openbsd/mod.rs
+++ b/vendor/os_info/src/openbsd/mod.rs
@@ -2,7 +2,7 @@ use std::process::Command;
use log::{error, trace};
-use crate::{bitness, uname::uname, Info, Type, Version};
+use crate::{architecture, bitness, uname::uname, Info, Type, Version};
pub fn current_platform() -> Info {
trace!("openbsd::current_platform is called");
@@ -15,6 +15,7 @@ pub fn current_platform() -> Info {
os_type: Type::OpenBSD,
version,
bitness: bitness::get(),
+ architecture: architecture::get(),
..Default::default()
};
diff --git a/vendor/os_info/src/os_type.rs b/vendor/os_info/src/os_type.rs
index 8cab07b8e..6d78f587c 100644
--- a/vendor/os_info/src/os_type.rs
+++ b/vendor/os_info/src/os_type.rs
@@ -6,6 +6,8 @@ use std::fmt::{self, Display, Formatter};
#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
#[non_exhaustive]
pub enum Type {
+ /// Alpaquita Linux (<https://bell-sw.com/alpaquita-linux/>).
+ Alpaquita,
/// Alpine Linux (<https://en.wikipedia.org/wiki/Alpine_Linux>).
Alpine,
/// Amazon Linux AMI (<https://en.wikipedia.org/wiki/Amazon_Machine_Image#Amazon_Linux_AMI>).
@@ -14,6 +16,8 @@ pub enum Type {
Android,
/// Arch Linux (<https://en.wikipedia.org/wiki/Arch_Linux>).
Arch,
+ /// Artix Linux (<https://en.wikipedia.org/wiki/Artix_Linux>).
+ Artix,
/// CentOS (<https://en.wikipedia.org/wiki/CentOS>).
CentOS,
/// Debian (<https://en.wikipedia.org/wiki/Debian>).
@@ -38,6 +42,8 @@ pub enum Type {
Illumos,
/// Linux based operating system (<https://en.wikipedia.org/wiki/Linux>).
Linux,
+ /// Mabox (<https://maboxlinux.org/>).
+ Mabox,
/// Mac OS X/OS X/macOS (<https://en.wikipedia.org/wiki/MacOS>).
Macos,
/// Manjaro (<https://en.wikipedia.org/wiki/Manjaro>).
@@ -54,6 +60,10 @@ pub enum Type {
NixOS,
/// OpenBSD (<https://en.wikipedia.org/wiki/OpenBSD>).
OpenBSD,
+ /// OpenCloudOS (<https://www.opencloudos.org>).
+ OpenCloudOS,
+ /// openEuler (<https://en.wikipedia.org/wiki/EulerOS>).
+ openEuler,
/// openSUSE (<https://en.wikipedia.org/wiki/OpenSUSE>).
openSUSE,
/// Oracle Linux (<https://en.wikipedia.org/wiki/Oracle_Linux>).
@@ -89,9 +99,11 @@ impl Default for Type {
impl Display for Type {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match *self {
+ Type::Alpaquita => write!(f, "Alpaquita Linux"),
Type::Alpine => write!(f, "Alpine Linux"),
Type::Amazon => write!(f, "Amazon Linux AMI"),
Type::Arch => write!(f, "Arch Linux"),
+ Type::Artix => write!(f, "Artix Linux"),
Type::DragonFly => write!(f, "DragonFly BSD"),
Type::Garuda => write!(f, "Garuda Linux"),
Type::Gentoo => write!(f, "Gentoo Linux"),
@@ -104,7 +116,7 @@ impl Display for Type {
Type::Redhat => write!(f, "Red Hat Linux"),
Type::RedHatEnterprise => write!(f, "Red Hat Enterprise Linux"),
Type::SUSE => write!(f, "SUSE Linux Enterprise Server"),
- _ => write!(f, "{:?}", self),
+ _ => write!(f, "{self:?}"),
}
}
}
@@ -121,10 +133,12 @@ mod tests {
#[test]
fn display() {
let data = [
+ (Type::Alpaquita, "Alpaquita Linux"),
(Type::Alpine, "Alpine Linux"),
(Type::Amazon, "Amazon Linux AMI"),
(Type::Android, "Android"),
(Type::Arch, "Arch Linux"),
+ (Type::Artix, "Artix Linux"),
(Type::CentOS, "CentOS"),
(Type::Debian, "Debian"),
(Type::DragonFly, "DragonFly BSD"),
diff --git a/vendor/os_info/src/version.rs b/vendor/os_info/src/version.rs
index 20a2c4a61..578464c67 100644
--- a/vendor/os_info/src/version.rs
+++ b/vendor/os_info/src/version.rs
@@ -55,15 +55,15 @@ impl Display for Version {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match *self {
Self::Unknown => f.write_str("Unknown"),
- Self::Semantic(major, minor, patch) => write!(f, "{}.{}.{}", major, minor, patch),
+ Self::Semantic(major, minor, patch) => write!(f, "{major}.{minor}.{patch}"),
Self::Rolling(ref date) => {
let date = match date {
- Some(date) => format!(" ({})", date),
+ Some(date) => format!(" ({date})"),
None => "".to_owned(),
};
- write!(f, "Rolling Release{}", date)
+ write!(f, "Rolling Release{date}")
}
- Self::Custom(ref version) => write!(f, "{}", version),
+ Self::Custom(ref version) => write!(f, "{version}"),
}
}
}
diff --git a/vendor/os_info/src/windows/winapi.rs b/vendor/os_info/src/windows/winapi.rs
index 59e3f30d9..dea5ba258 100644
--- a/vendor/os_info/src/windows/winapi.rs
+++ b/vendor/os_info/src/windows/winapi.rs
@@ -59,7 +59,7 @@ fn version() -> (Version, Option<String>) {
v.dwMinorVersion as u64,
v.dwBuildNumber as u64,
),
- product_name().or_else(|| edition(&v)),
+ product_name(&v).or_else(|| edition(&v)),
),
}
}
@@ -125,7 +125,7 @@ fn version_info() -> Option<OSVERSIONINFOEX> {
}
}
-fn product_name() -> Option<String> {
+fn product_name(info: &OSVERSIONINFOEX) -> Option<String> {
const REG_SUCCESS: LSTATUS = ERROR_SUCCESS as LSTATUS;
let sub_key = to_wide("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
@@ -138,8 +138,14 @@ fn product_name() -> Option<String> {
return None;
}
+ let is_win_11 = info.dwMajorVersion == 10 && info.dwBuildNumber >= 22000;
+
// Get size of the data.
- let name = to_wide("ProductName");
+ let name = to_wide(if is_win_11 {
+ "EditionID"
+ } else {
+ "ProductName"
+ });
let mut data_type: DWORD = 0;
let mut data_size: DWORD = 0;
if unsafe {
@@ -186,11 +192,15 @@ fn product_name() -> Option<String> {
_ => {}
}
- Some(
- OsString::from_wide(data.as_slice())
- .to_string_lossy()
- .into_owned(),
- )
+ let value = OsString::from_wide(data.as_slice())
+ .to_string_lossy()
+ .into_owned();
+
+ if is_win_11 {
+ Some(format!("Windows 11 {}", value))
+ } else {
+ Some(value)
+ }
}
fn to_wide(value: &str) -> Vec<WCHAR> {
@@ -206,7 +216,13 @@ fn edition(version_info: &OSVERSIONINFOEX) -> Option<String> {
version_info.wProductType,
) {
// Windows 10.
- (10, 0, VER_NT_WORKSTATION) => Some("Windows 10"),
+ (10, 0, VER_NT_WORKSTATION) => {
+ if version_info.dwBuildNumber >= 22000 {
+ Some("Windows 11")
+ } else {
+ Some("Windows 10")
+ }
+ }
(10, 0, _) => Some("Windows Server 2016"),
// Windows Vista, 7, 8 and 8.1.
(6, 3, VER_NT_WORKSTATION) => Some("Windows 8.1"),
@@ -283,7 +299,6 @@ mod tests {
#[test]
fn get_edition() {
let test_data = [
- (10, 0, VER_NT_WORKSTATION, "Windows 10"),
(10, 0, 0, "Windows Server 2016"),
(6, 3, VER_NT_WORKSTATION, "Windows 8.1"),
(6, 3, 0, "Windows Server 2012 R2"),
@@ -351,7 +366,8 @@ mod tests {
#[test]
fn get_product_name() {
- let edition = product_name().expect("edition() failed");
+ let version = version_info().expect("version_info() failed");
+ let edition = product_name(&version).expect("edition() failed");
assert!(!edition.is_empty());
}