Skip to content

Commit

Permalink
Release the 3.8.0 version (#368)
Browse files Browse the repository at this point in the history
* Release the 3.8.0 version
  • Loading branch information
stanislav-tkach authored Mar 12, 2024
1 parent 6bd1efc commit ae90c42
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 78 deletions.
29 changes: 28 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [3.8.0] (2024-03-12)

- The `windows-sys` crate instead of `winapi` is now used internally. (#341)

- Architecture information for Windows targets has been added. (#345)

- Artix Linux detection has been fixed. (#348)

- AIX support has been added. (#348)

- Kali Linux support has been added. (#350)

- openSUSE Tumbleweed detection has been fixed. (#353)

- Version parsing from `lsb_release` has been added. (#354)

- HardenedBSD detection has been fixed. (#358)

- Ultramarine Linux support has been added. (#359)

- AlmaLinux and Rocky Linux support has been added. (#360)

- Ultramarine Linux support has been added. (#363)

- Void Linux support has been added. (#365)

## [3.7.0] (2023-03-20)

- Information about a processor's architecture has been added. (#336)
Expand Down Expand Up @@ -291,7 +317,8 @@ All notable changes to this project will be documented in this file.

The first release containing only minor infrastructural changes and based on [os_type](https://github.com/schultyy/os_type).

[Unreleased]: https://github.com/stanislav-tkach/os_info/compare/v3.7.0...HEAD
[Unreleased]: https://github.com/stanislav-tkach/os_info/compare/v3.8.0...HEAD
[3.8.0]: https://github.com/stanislav-tkach/os_info/compare/v3.7.0...v3.8.0
[3.7.0]: https://github.com/stanislav-tkach/os_info/compare/v3.6.0...v3.7.0
[3.6.0]: https://github.com/stanislav-tkach/os_info/compare/v3.5.1...v3.6.0
[3.5.1]: https://github.com/stanislav-tkach/os_info/compare/v3.5.0...v3.5.1
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ os_info --help

Right now, the following operating system types can be returned:

- AIX
- AlmaLinux
- Alpaquita Linux
- Alpine Linux
- Amazon Linux AMI
Expand All @@ -95,8 +97,10 @@ Right now, the following operating system types can be returned:
- Garuda Linux
- Gentoo Linux
- HardenedBSD
- Illumos
- illumos
- Kali Linux
- Linux
- Mabox
- macOS (Mac OS X or OS X)
- Manjaro
- Mariner
Expand All @@ -105,17 +109,22 @@ Right now, the following operating system types can be returned:
- NetBSD
- NixOS
- OpenBSD
- OpenCloudOS
- openEuler (EulerOS)
- openSUSE
- Oracle Linux
- Pop!_OS
- Raspberry Pi OS
- Red Hat Linux
- Red Hat Enterprise Linux
- Redox
- Rocky Linux
- Solus
- SUSE Linux Enterprise Server
- Ubuntu
- Ultramarine Linux
- Unknown
- Void Linux
- Windows

If you need support for more OS types, I am looking forward to your Pull Request.
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ name = "os_info"
path = "src/main.rs"

[dependencies]
os_info = { version = "3.7.0", default-features = false, path = "../os_info" }
os_info = { version = "3.8.0", default-features = false, path = "../os_info" }
log.workspace = true
env_logger = "0.11"
clap = { version = "4", features = ["derive"] }
Expand Down
1 change: 1 addition & 0 deletions cspell-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ raspbian
redhat
rhel
rustdoc
sbin
serde
structopt
toml
Expand Down
2 changes: 1 addition & 1 deletion os_info/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "os_info"
version = "3.7.0"
version = "3.8.0"
authors = ["Jan Schulte <[email protected]>", "Stanislav Tkach <[email protected]>"]
description = "Detect the operating system type and version."
documentation = "https://docs.rs/os_info"
Expand Down
37 changes: 6 additions & 31 deletions os_info/src/aix/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::process::Command;
use std::str;
use std::{process::Command, str};

use log::{error, trace};

Expand All @@ -24,39 +23,15 @@ pub fn current_platform() -> Info {
}

fn get_version() -> Option<String> {
fn parse_uname(arg: &str) -> Option<String> {
Command::new("uname")
.arg(arg)
.output()
.map_err(|e| {
error!("Failed to invoke 'uname': {:?}", 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
}
})
}

let major = parse_uname("-v")?;
let minor = parse_uname("-r").unwrap_or(String::from("0"));
let major = uname("-v")?;
let minor = uname("-r").unwrap_or(String::from("0"));
Some(format!("{}.{}", major, minor))
}

fn get_os() -> Type {
let os = Command::new("uname")
.arg("-o")
.output()
.expect("Failed to get OS");

match str::from_utf8(&os.stdout) {
Ok("AIX\n") => Type::AIX,
Ok(_) => Type::Unknown,
Err(_) => Type::Unknown,
match uname("-o") {
Some("AIX") => Type::AIX,
None => Type::Unknown,
}
}

Expand Down
2 changes: 1 addition & 1 deletion os_info/src/architecture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod tests {

#[test]
fn uname_nonempty() {
let val = get().expect("uname failed");
let val = get().expect("architecture::get() failed");
assert!(!val.is_empty());
}
}
37 changes: 25 additions & 12 deletions os_info/src/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,39 @@ pub fn current_platform() -> Info {
}

fn get_os() -> Type {
let os = Command::new("uname")
.arg("-s")
.output()
.expect("Failed to get OS");

match str::from_utf8(&os.stdout) {
Ok("FreeBSD\n") => {
let check_hardening = Command::new("/sbin/sysctl")
let os = match uname("-s") {
Some(o) => o,
None => return Type::Unknown,
};

let os = match Command::new("uname").arg("-s").output() {
Ok(o) => o,
Err(e) => {
error!("Failed to invoke 'uname': {:?}", e);
return Type::Unknown;
}
};

match uname("-s") {
None => Type::Unknown,
Some("MidnightBSD") => Type::MidnightBSD,
Some("FreeBSD") => {
let check_hardening = match Command::new("/sbin/sysctl")
.arg("hardening.version")
.output()
.expect("Failed to check if is hardened");
{
Ok(o) => o,
Err(e) => {
error!("Failed to invoke '/sbin/sysctl': {:?}", e);
return Type::FreeBSD;
}
};
match str::from_utf8(&check_hardening.stderr) {
Ok("0\n") => Type::HardenedBSD,
Ok(_) => Type::FreeBSD,
Err(_) => Type::FreeBSD,
}
}
Ok("MidnightBSD\n") => Type::MidnightBSD,
Ok(_) => Type::Unknown,
Err(_) => Type::Unknown,
}
}

Expand Down
28 changes: 4 additions & 24 deletions os_info/src/illumos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,13 @@ pub fn current_platform() -> Info {
}

fn get_version() -> Option<String> {
Command::new("uname")
.arg("-v")
.output()
.map_err(|e| {
error!("Failed to invoke 'uname': {:?}", 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
}
})
uname("-v")
}

fn get_os() -> Type {
let os = Command::new("uname")
.arg("-o")
.output()
.expect("Failed to get OS");

match str::from_utf8(&os.stdout) {
Ok("illumos\n") => Type::Illumos,
Ok(_) => Type::Unknown,
Err(_) => Type::Unknown,
match uname("-o") {
Some("illumos") => Type::Illumos,
None => Type::Unknown,
}
}

Expand Down
1 change: 1 addition & 0 deletions os_info/src/linux/file_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fn retrieve(distributions: &[ReleaseInfo], root: &str) -> Option<Info> {
let version = (release_info.version)(&file_content);

return Some(Info {
// Unwrap is OK here because of the `os_type.is_none()` check above.
os_type: os_type.unwrap(),
version: version.unwrap_or(Version::Unknown),
bitness: Bitness::Unknown,
Expand Down
17 changes: 14 additions & 3 deletions os_info/src/os_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ impl Display for Type {
Type::Macos => write!(f, "Mac OS"),
Type::MidnightBSD => write!(f, "Midnight BSD"),
Type::Mint => write!(f, "Linux Mint"),
Type::openEuler => write!(f, "EulerOS"),
Type::OracleLinux => write!(f, "Oracle Linux"),
Type::Pop => write!(f, "Pop!_OS"),
Type::Raspbian => write!(f, "Raspberry Pi OS"),
Type::Redhat => write!(f, "Red Hat Linux"),
Expand All @@ -151,6 +153,7 @@ mod tests {
fn display() {
let data = [
(Type::AIX, "AIX"),
(Type::AlmaLinux, "AlmaLinux"),
(Type::Alpaquita, "Alpaquita Linux"),
(Type::Alpine, "Alpine Linux"),
(Type::Amazon, "Amazon Linux AMI"),
Expand All @@ -163,30 +166,38 @@ mod tests {
(Type::Emscripten, "Emscripten"),
(Type::EndeavourOS, "EndeavourOS"),
(Type::Fedora, "Fedora"),
(Type::FreeBSD, "FreeBSD"),
(Type::Garuda, "Garuda Linux"),
(Type::Gentoo, "Gentoo Linux"),
(Type::FreeBSD, "FreeBSD"),
(Type::HardenedBSD, "HardenedBSD"),
(Type::Illumos, "illumos"),
(Type::Kali, "Kali Linux"),
(Type::Linux, "Linux"),
(Type::Mabox, "Mabox"),
(Type::Macos, "Mac OS"),
(Type::Manjaro, "Manjaro"),
(Type::Mariner, "Mariner"),
(Type::MidnightBSD, "Midnight BSD"),
(Type::Mint, "Linux Mint"),
(Type::NetBSD, "NetBSD"),
(Type::NixOS, "NixOS"),
(Type::OpenCloudOS, "OpenCloudOS"),
(Type::OpenBSD, "OpenBSD"),
(Type::openEuler, "EulerOS"),
(Type::openSUSE, "openSUSE"),
(Type::OracleLinux, "OracleLinux"),
(Type::OracleLinux, "Oracle Linux"),
(Type::Pop, "Pop!_OS"),
(Type::Raspbian, "Raspberry Pi OS"),
(Type::Redhat, "Red Hat Linux"),
(Type::RedHatEnterprise, "Red Hat Enterprise Linux"),
(Type::Redox, "Redox"),
(Type::RockyLinux, "Rocky Linux"),
(Type::Solus, "Solus"),
(Type::SUSE, "SUSE Linux Enterprise Server"),
(Type::Ubuntu, "Ubuntu"),
(Type::Ultramarine, "Ultramarine Linux"),
(Type::Void, "Void Linux"),
(Type::Unknown, "Unknown"),
(Type::Void, "Void Linux"),
(Type::Windows, "Windows"),
];

Expand Down
6 changes: 3 additions & 3 deletions os_info/src/uname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use std::process::Command;

use log::error;

pub fn uname() -> Option<String> {
pub fn uname(arg: &str) -> Option<String> {
Command::new("uname")
.arg("-r")
.arg(arg)
.output()
.map_err(|e| {
error!("Failed to invoke 'uname': {:?}", e);
error!("Failed to invoke 'uname {}': {:?}", arg, e);
})
.ok()
.and_then(|out| {
Expand Down

0 comments on commit ae90c42

Please sign in to comment.