Fix dashboard -V to show cm-dashboard package hash not system hash
Make dashboard -V show the same hash as the agent by extracting the hash from the dashboard binary's nix store path instead of the system configuration path. Now both will show identical hashes since they're from the same cm-dashboard package.
This commit is contained in:
parent
3d187c9220
commit
17b5921d8d
@ -11,19 +11,14 @@ mod ui;
|
||||
|
||||
use app::Dashboard;
|
||||
|
||||
/// Get version showing current system config hash for easy rebuild verification
|
||||
/// Get version showing cm-dashboard package hash for easy rebuild verification
|
||||
fn get_version() -> &'static str {
|
||||
use std::process::Command;
|
||||
// Get the path of the current executable
|
||||
let exe_path = std::env::current_exe().expect("Failed to get executable path");
|
||||
let exe_str = exe_path.to_string_lossy();
|
||||
|
||||
// Get config hash from current system
|
||||
let output = Command::new("readlink").arg("/run/current-system").output().expect("Failed to run readlink");
|
||||
assert!(output.status.success(), "readlink command failed");
|
||||
|
||||
let store_path = String::from_utf8_lossy(&output.stdout);
|
||||
let store_path = store_path.trim();
|
||||
|
||||
// Extract hash from nix store path
|
||||
let hash_part = store_path.strip_prefix("/nix/store/").expect("Not a nix store path");
|
||||
// Extract Nix store hash from path like /nix/store/HASH-cm-dashboard-0.1.0/bin/cm-dashboard
|
||||
let hash_part = exe_str.strip_prefix("/nix/store/").expect("Not a nix store path");
|
||||
let hash = hash_part.split('-').next().expect("Invalid nix store path format");
|
||||
assert!(hash.len() >= 8, "Hash too short");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user