Skip to content

Commit

Permalink
Merge pull request #149 from DarkEld3r/release-2-0-1
Browse files Browse the repository at this point in the history
Release 2.0.1 version
  • Loading branch information
stanislav-tkach authored Feb 22, 2020
2 parents f918d8a + d9772e0 commit abddce9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "os_info"
version = "2.0.0"
version = "2.0.1"
authors = ["Jan Schulte <hello@unexpected-co.de>", "Stanislav Tkach <stanislav.tkach@gmail.com>"]
description = "Detect the operating system type and version."
documentation = "https://docs.rs/os_info"
Expand Down
13 changes: 10 additions & 3 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [2.0.1] (2020-02-22)

- Bitness detection has been implemented for MacOS. (#147)

- `regex` dependency has been removed. (#144)

- `libntdll.a` has been removed from the sources. (#146)

## [2.0.0] (2020-02-11)

- `Bitness` and `Type` enums have been marked as `non_exhaustive`. (#140)
Expand Down Expand Up @@ -126,9 +132,10 @@ 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/darkeld3r/os_info/compare/v2.0...HEAD
[1.3.2]: https://github.com/darkeld3r/os_info/compare/v1.3.3...v2.0
[1.3.2]: https://github.com/darkeld3r/os_info/compare/v1.3.2...v1.3.3
[Unreleased]: https://github.com/darkeld3r/os_info/compare/v2.0.1...HEAD
[2.0.1]: https://github.com/darkeld3r/os_info/compare/v2.0...v2.0.1
[2.0.0]: https://github.com/darkeld3r/os_info/compare/v1.3.3...v2.0
[1.3.3]: https://github.com/darkeld3r/os_info/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/darkeld3r/os_info/compare/v1.3.1...v1.3.2
[1.3.1]: https://github.com/darkeld3r/os_info/compare/v1.3...v1.3.1
[1.3.0]: https://github.com/darkeld3r/os_info/compare/v1.2...v1.3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ To use this crate, add `os_info` as a dependency to your project's Cargo.toml:

```toml
[dependencies]
os_info = "2.0.0"
os_info = "2.0.1"
```

This project has `serde` as an optional dependency, so if you don't need it, then
Expand Down
40 changes: 10 additions & 30 deletions src/macos/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::process::Command;
use std::process::{Command, Output};

use log::trace;
use log::{trace, warn};

use crate::{matcher::Matcher, Bitness, Info, Type, Version};

Expand Down Expand Up @@ -51,7 +51,7 @@ fn product_version() -> Option<String> {
parse(&output)
}
Err(e) => {
trace!("sw_vers command failed with {:?}", e);
warn!("sw_vers command failed with {:?}", e);
None
}
}
Expand All @@ -65,24 +65,10 @@ fn parse(sw_vers_output: &str) -> Option<String> {
}

fn bitness() -> Bitness {
match Command::new("getconf").arg("LONG_BIT").output() {
Ok(val) => parse_bitness(val.stdout),
Err(e) => {
trace!("getconf command failed with {:?}", e);
Bitness::Unknown
}
}
}

fn parse_bitness(getconf_output: Vec<u8>) -> Bitness {
match String::from_utf8(getconf_output) {
Ok(ref output) if output.trim() == "32" => Bitness::X32,
Ok(ref output) if output.trim() == "64" => Bitness::X64,
Ok(_) => Bitness::Unknown,
Err(e) => {
trace!("convert getconf output to String failed with {:?}", e);
Bitness::Unknown
}
match &Command::new("getconf").arg("LONG_BIT").output() {
Ok(Output { stdout, .. }) if stdout == b"32\n" => Bitness::X32,
Ok(Output { stdout, .. }) if stdout == b"64\n" => Bitness::X64,
_ => Bitness::Unknown,
}
}

Expand Down Expand Up @@ -170,14 +156,8 @@ mod tests {
}

#[test]
fn bitness() {
assert_eq!(parse_bitness("32".as_bytes().to_vec()), Bitness::X32);
assert_eq!(parse_bitness("32\n".as_bytes().to_vec()), Bitness::X32);
assert_eq!(parse_bitness("64".as_bytes().to_vec()), Bitness::X64);
assert_eq!(parse_bitness("64\n".as_bytes().to_vec()), Bitness::X64);
assert_eq!(
parse_bitness("bad_value".as_bytes().to_vec()),
Bitness::Unknown
);
fn get_bitness() {
let b = bitness();
assert_ne!(b, Bitness::Unknown);
}
}

0 comments on commit abddce9

Please sign in to comment.