diff --git a/services/updates.py b/services/updates.py index 988e36b..dc2ab74 100644 --- a/services/updates.py +++ b/services/updates.py @@ -22,7 +22,29 @@ async def list_updates() -> str: if pm == "apt": await run_cmd(["sudo", "apt", "update"], timeout=300) rc, out = await run_cmd(["apt", "list", "--upgradable"], timeout=120) - return f"📦 Updates (apt)\n```{out}```" if rc == 0 else f"❌ apt list failed\n```{out}```" + if rc != 0: + return f"❌ apt list failed\n```{out}```" + + lines = [] + for line in out.splitlines(): + if not line or line.startswith("Listing..."): + continue + # Format: name/version ... [upgradable from: old] + name_ver = line.split(" ", 1)[0] + if "/" not in name_ver: + continue + name, new_ver = name_ver.split("/", 1) + old_ver = None + marker = "upgradable from: " + if marker in line: + old_ver = line.split(marker, 1)[1].rstrip("]").strip() + if old_ver: + lines.append(f"{name}: {old_ver} -> {new_ver}") + else: + lines.append(f"{name}: -> {new_ver}") + + body = "\n".join(lines) if lines else "No updates" + return f"📦 Updates (apt)\n```{body}```" if pm == "dnf": rc, out = await run_cmd(["sudo", "dnf", "check-update"], timeout=300)