Skip to content

Commit eb877ce

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. Example: ``` > sudo framework_tool --versions Tool Version: 0.4.3 OS Version: Linux 6.15.1 #1-NixOS SMP PREEMPT_DYNAMIC Wed Jun 4 12:46:27 UTC 2025 x86_64 ``` Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 7114177 commit eb877ce

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-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: 3 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,8 @@ fn print_stylus_battery_level() {
374375
}
375376

376377
fn print_versions(ec: &CrosEc) {
378+
println!("Tool Version: {}", built_info::PKG_VERSION);
379+
println!("OS Version: {}", os_specific::get_os_version());
377380
println!("Mainboard Hardware");
378381
if let Some(ver) = smbios::get_product_name() {
379382
println!(" Type: {}", ver);

framework_lib/src/os_specific.rs

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

6+
#[cfg(feature = "uefi")]
7+
use crate::alloc::string::ToString;
8+
9+
// Could report the implemented UEFI spec version
10+
// But that's not very useful. Just look at the BIOS version
11+
// But at least it's useful to see that the tool was run on UEFI
12+
#[cfg(feature = "uefi")]
13+
pub fn get_os_version() -> String {
14+
"UEFI".to_string()
15+
}
16+
17+
#[cfg(target_family = "windows")]
18+
pub fn get_os_version() -> String {
19+
let ver = windows_version::OsVersion::current();
20+
format!("{}.{}.{}.{}", ver.major, ver.minor, ver.pack, ver.build)
21+
}
22+
23+
#[cfg(target_family = "unix")]
24+
pub fn get_os_version() -> String {
25+
if let Ok(uts) = nix::sys::utsname::uname() {
26+
// uname -a without hostname
27+
format!(
28+
"{} {} {} {}",
29+
uts.sysname().to_string_lossy(),
30+
uts.release().to_string_lossy(),
31+
uts.version().to_string_lossy(),
32+
uts.machine().to_string_lossy(),
33+
)
34+
} else {
35+
"Unknown".to_string()
36+
}
37+
}
38+
639
/// Sleep a number of microseconds
740
pub fn sleep(micros: u64) {
841
#[cfg(not(feature = "uefi"))]

0 commit comments

Comments
 (0)