Skip to content

Commit de9cd4e

Browse files
committed
--versions: Add OS and tool version
It's useful to know which Linux/FreeBSD kernel or windows version people are running when reporting an issue. Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 7114177 commit de9cd4e

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

framework_lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ env_logger = "0.11"
4949
clap = { version = "4.5", features = ["derive", "cargo"] }
5050
clap-num = { version = "1.2.0" }
5151
clap-verbosity-flag = { version = "2.2.1" }
52+
windows-version = "0.1.4"
5253

5354
[target.'cfg(unix)'.dependencies]
5455
libc = "0.2.155"

framework_lib/src/commandline/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ use crate::ec_binary;
4949
use crate::esrt;
5050
#[cfg(feature = "rusb")]
5151
use crate::inputmodule::check_inputmodule_version;
52+
use crate::os_specific;
5253
use crate::power;
5354
use crate::smbios;
5455
use crate::smbios::ConfigDigit0;
@@ -374,6 +375,12 @@ fn print_stylus_battery_level() {
374375
}
375376

376377
fn print_versions(ec: &CrosEc) {
378+
println!("Tool Version: {}", built_info::PKG_VERSION);
379+
380+
// Nothing useful to report on UEFI, should refer to BIOS version instead
381+
#[cfg(not(feature = "uefi"))]
382+
println!("OS Version: {}", os_specific::get_os_version());
383+
377384
println!("Mainboard Hardware");
378385
if let Some(ver) = smbios::get_product_name() {
379386
println!(" Type: {}", ver);

framework_lib/src/os_specific.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
33
#[cfg(not(feature = "uefi"))]
44
use std::{thread, time};
55

6+
#[cfg(target_family = "windows")]
7+
pub fn get_os_version() -> String {
8+
let ver = windows_version::OsVersion::current();
9+
format!("{}.{}.{}.{}", ver.major, ver.minor, ver.pack, ver.build)
10+
}
11+
12+
#[cfg(target_family = "unix")]
13+
pub fn get_os_version() -> String {
14+
if let Ok(uts) = nix::sys::utsname::uname() {
15+
// uname -a without hostname
16+
format!(
17+
"{} {} {} {}",
18+
uts.sysname().to_string_lossy(),
19+
uts.release().to_string_lossy(),
20+
uts.version().to_string_lossy(),
21+
uts.machine().to_string_lossy(),
22+
)
23+
} else {
24+
"Unknown".to_string()
25+
}
26+
}
27+
628
/// Sleep a number of microseconds
729
pub fn sleep(micros: u64) {
830
#[cfg(not(feature = "uefi"))]

0 commit comments

Comments
 (0)