fix: extract clean package names in updates_available warning meta

opkg list-upgradable and apk version output contains version strings and
comparison operators; meta.packages now stores only the bare package name
so the schedule-updates API validation passes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Manivong
2026-06-02 13:28:07 +02:00
co-authored by Claude Sonnet 4.6
parent 64964c1b33
commit 0493520e5f
+17 -1
View File
@@ -1711,6 +1711,21 @@ class OpenWrtDriver(AccessPointDriver):
pm = self._pm_type() pm = self._pm_type()
# 2. Package updates available (local cache only – no opkg update) # 2. Package updates available (local cache only – no opkg update)
def _pkg_name(line: str, pm_type: str) -> str:
"""Extract just the package name from an upgradable line.
apk: 'luci-app-firewall-26.143~abc < 26.151~def' → 'luci-app-firewall'
opkg: 'luci-app-firewall - 1.0 - 1.1' → 'luci-app-firewall'
"""
import re as _re
if pm_type == "apk":
# Strip trailing ' < ...' then remove the version suffix (-\d...)
name_ver = line.split(" ")[0]
m = _re.match(r'^(.*?)-\d', name_ver)
return m.group(1) if m else name_ver
else:
return line.split(" - ")[0].strip()
try: try:
if pm == "apk": if pm == "apk":
raw_upg = self._send_command("apk version 2>/dev/null | grep '<'") raw_upg = self._send_command("apk version 2>/dev/null | grep '<'")
@@ -1721,13 +1736,14 @@ class OpenWrtDriver(AccessPointDriver):
upgradable = [] upgradable = []
if upgradable: if upgradable:
pkg_names = [_pkg_name(ln, pm) for ln in upgradable]
warnings.append({ warnings.append({
"code": "updates_available", "code": "updates_available",
"severity": "info", "severity": "info",
"action": None, "action": None,
"meta": { "meta": {
"count": len(upgradable), "count": len(upgradable),
"packages": upgradable[:10], "packages": pkg_names[:10],
}, },
}) })