Skip to content

Commit

Permalink
Release the 3.8.0 version
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-tkach committed Mar 11, 2024
1 parent 6bd1efc commit e744b7d
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 74 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

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

- FIXME

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

- Information about a processor's architecture has been added. (#336)
Expand Down Expand Up @@ -291,7 +295,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
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
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")

Check warning on line 44 in os_info/src/freebsd/mod.rs

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (sbin)

Check warning on line 44 in os_info/src/freebsd/mod.rs

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (sbin)
.arg("hardening.version")
.output()
.expect("Failed to check if is hardened");
{
Ok(o) => o,
Err(e) => {
error!("Failed to invoke '/sbin/sysctl': {:?}", e);

Check warning on line 50 in os_info/src/freebsd/mod.rs

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (sbin)

Check warning on line 50 in os_info/src/freebsd/mod.rs

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (sbin)
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
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 e744b7d

Please sign in to comment.