Files
system_update/server/services/aptParse.ts
T
2026-06-04 21:03:52 +02:00

27 lines
769 B
TypeScript

// server/services/aptParse.ts
import type { AptPackage } from "@shared/types.js";
// Exemple de ligne:
// Inst pve-manager [8.4-1] (8.4-3 Proxmox VE:8.x [amd64])
// Inst newpkg (1.0.0 Debian:11.6/stable [all])
const INST_RE = /^Inst (\S+) (?:\[([^\]]+)\] )?\((\S+) (.+?) \[[^\]]+\]\)\s*$/;
export function parseAptSimulate(raw: string): AptPackage[] {
const out: AptPackage[] = [];
for (const line of raw.split("\n")) {
const m = INST_RE.exec(line.trimEnd());
if (!m) continue;
out.push({
name: m[1]!,
currentVersion: m[2] ?? null,
targetVersion: m[3]!,
origin: (m[4] ?? "").trim() || null,
});
}
return out;
}
export function parseRebootRequired(raw: string): boolean {
return /REBOOT_REQUIRED=1/.test(raw);
}