diff options
Diffstat (limited to 'desktop/modules/updates/updatesctl')
| -rwxr-xr-x | desktop/modules/updates/updatesctl | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/desktop/modules/updates/updatesctl b/desktop/modules/updates/updatesctl index ee843c2..31f60a0 100755 --- a/desktop/modules/updates/updatesctl +++ b/desktop/modules/updates/updatesctl @@ -44,10 +44,13 @@ def sysp(p): def vercmp(a, b): """Version order: numeric chunks as numbers, numbers after letters. - When one version runs out, the longer one is newer unless its next chunk - is alphabetic, which makes 0.12.3_beta.4 older than 0.12.3 and a kernel - suffix or git hash (9.018.00_6.18.41) newer than its base, never behind. + When one version runs out, the longer one is newer unless what follows + is only zeros (1.14 == 1.14.0) or starts with a named pre-release, which + makes 0.12.3_beta.4 older than 0.12.3 and a kernel suffix or git hash + (9.018.00_6.18.41, 3.1-a59215d) newer than its base, never behind. """ + PRERELEASE = {"alpha", "beta", "rc", "pre", "dev"} + def chunks(v): v = v.lower() return re.findall(r"\d+|[a-z]+", v[1:] if v.startswith("v") else v) @@ -61,10 +64,11 @@ def vercmp(a, b): if p.isdigit() != q.isdigit(): return 1 if p.isdigit() else -1 return (p > q) - (p < q) - if len(x) == len(y): - return 0 longer, sign = (x, 1) if len(x) > len(y) else (y, -1) - return sign if longer[min(len(x), len(y))].isdigit() else -sign + rest = longer[min(len(x), len(y)):] + if all(c == "0" for c in rest): # 1.14 == 1.14.0, and equal lengths + return 0 + return -sign if rest[0] in PRERELEASE else sign NVCONF = HOME / ".config/nvchecker/nvchecker.toml" @@ -198,12 +202,15 @@ def apps(): except (ValueError, AttributeError): pass if shutil.which("flatpak"): - r = subprocess.run(["flatpak", "list", "--app", "--columns=application,version"], - capture_output=True, text=True) - for line in r.stdout.splitlines(): + try: + lines = subprocess.run(["flatpak", "list", "--app", "--columns=application,version"], + capture_output=True, text=True, timeout=10).stdout + except subprocess.TimeoutExpired: + lines = "" + for line in lines.splitlines(): app, _, v = line.partition("\t") if app: - out[app.rsplit(".", 1)[-1].lower()] = (v, "flatpak") + out.setdefault(app.rsplit(".", 1)[-1].lower(), (v, "flatpak")) return out @@ -270,7 +277,10 @@ def blacklist(): for line in read(sysp("/etc/slackpkg/blacklist")).splitlines(): p = line.strip().strip('"') if p and not p.startswith("#"): - out.append(re.compile(p)) + try: + out.append(re.compile(p)) + except re.error: + pass # one bad line must not cost the whole document return out @@ -334,7 +344,7 @@ def slackware(installed, errors): if f.count("-") >= 3 and not blocked(bl, f)} for name, full in sorted(mine.items()): - if name in mirror and mirror[name] != full: + if name in mirror and verbuild(mirror[name]) != verbuild(full): out["upgrade"].append({"name": name, "from": verbuild(full), "to": verbuild(mirror[name])}) for name, (act, date) in sorted(changelog(cl).items()): |
