Vollständig portables Linux-ELF bauen
Some checks failed
Tests / test (push) Has been cancelled

This commit is contained in:
2026-10-15 11:23:21 +02:00
parent e799682e10
commit bf34593bbb
10 changed files with 581 additions and 166 deletions

View File

@@ -1,6 +1,16 @@
use serde::Deserialize;
use std::{path::Path, process::Command};
const BRIDGE: &str = include_str!("../../scripts/inventory-sync.py");
fn python() -> Command {
if let Some(launcher) = std::env::var_os("CSR_RUNTIME_LAUNCHER") {
let mut command = Command::new(launcher);
command.arg("--internal-python");
command
} else {
Command::new("python3")
}
}
#[derive(Clone, Debug, Deserialize)]
pub struct QueueEntry {
pub asset_id: String,
@@ -12,7 +22,7 @@ pub struct QueueEntry {
pub report_path: String,
}
fn call(data: &Path, args: &[&str]) -> Result<String, String> {
let out = Command::new("python3")
let out = python()
.args(["-c", BRIDGE, "--data"])
.arg(data)
.args(args)
@@ -48,7 +58,7 @@ pub struct HardwareIdentity {
pub fn identify(identity: &crate::workflow::Identity) -> Result<HardwareIdentity, String> {
let report = serde_json::json!({"system_uuid": identity.uuid, "serial_number": identity.serial,
"manufacturer": identity.manufacturer});
let output = Command::new("python3")
let output = python()
.args(["-c", BRIDGE, "--identity-json", &report.to_string()])
.output()
.map_err(|e| e.to_string())?;

View File

@@ -86,24 +86,29 @@ struct App {
station_ready: bool,
next_station_attempt: Instant,
}
fn scanner_path() -> PathBuf {
fn scanner_command() -> Command {
if let Some(launcher) = std::env::var_os("CSR_RUNTIME_LAUNCHER") {
let mut command = Command::new(launcher);
command.arg("--internal-scanner");
return command;
}
if let Some(p) = std::env::var_os("CSR_SCANNER") {
return PathBuf::from(p);
return Command::new(p);
}
// Prefer the scanner bundled beside this executable, then a system installation.
if let Ok(exe) = std::env::current_exe() {
if let Some(parent) = exe.parent() {
let sibling = parent.join("pc-intake");
if sibling.exists() {
return sibling;
return Command::new(sibling);
}
}
}
let local = Path::new(env!("CARGO_MANIFEST_DIR")).join("../scanner/target/release/pc-intake");
if local.exists() {
local
Command::new(local)
} else {
PathBuf::from("/usr/local/bin/pc-intake")
Command::new("/usr/local/bin/pc-intake")
}
}
fn setup(data: &Path) -> Result<(), String> {
@@ -337,20 +342,17 @@ impl App {
}
let data = self.data.clone();
let asset = self.inspection.as_ref().unwrap().asset.clone();
let scanner = scanner_path();
let mut scanner = scanner_command();
let (tx, rx) = mpsc::channel();
self.receiver = Some(rx);
self.status = "Hardware scan running / Hardware-Scan läuft …".into();
thread::spawn(move || {
let result = (|| {
let mut command = Command::new("timeout");
command
.args(["--kill-after=5s", "600s"])
.arg(scanner)
scanner
.args(["--asset-id", &asset, "--output"])
.arg(data.join("reports"));
command.arg(if full { "--compile" } else { "--quick" });
let out = command.output().map_err(|e| format!("Scanner: {e}"))?;
scanner.arg(if full { "--compile" } else { "--quick" });
let out = scanner.output().map_err(|e| format!("Scanner: {e}"))?;
if !out.status.success() {
return Err(String::from_utf8_lossy(&out.stderr).into_owned());
}