diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-15 12:20:32 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-15 12:20:32 +0200 |
| commit | 7db7405c80e8f00008bc5196abfda2c500071a98 (patch) | |
| tree | ca1dc409b31931b5dc11f5c1588b3df1df0aca0a /desktop/modules | |
| parent | 0fdd992b1fd0c24e6f7ab5630575904926d91137 (diff) | |
| download | quickshell-7db7405c80e8f00008bc5196abfda2c500071a98.tar.gz quickshell-7db7405c80e8f00008bc5196abfda2c500071a98.zip | |
fix(updates): review findings in updatesctl
A git hash starting with a letter (3.1-a59215d) ordered behind its base,
because any trailing alphabetic chunk counted as a pre-release; only
alpha, beta, rc, pre and dev do now. Trailing zeros (1.14 against
1.14.0) compare equal instead of reading as an upstream bump. A bad line
in the slackpkg blacklist is skipped rather than crashing the script and
leaving the drawer with nothing. An AppImage keeps its key over a
flatpak of the same name, as the spec orders them, and flatpak list has
a timeout. A Slackware upgrade compares version and build, so an arch
change alone is not a row. The spec's prose now matches the code: the
upstream comparison includes the installed version.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules')
| -rw-r--r-- | desktop/modules/updates/test_updatesctl.py | 5 | ||||
| -rwxr-xr-x | desktop/modules/updates/updatesctl | 34 |
2 files changed, 27 insertions, 12 deletions
diff --git a/desktop/modules/updates/test_updatesctl.py b/desktop/modules/updates/test_updatesctl.py index a4d0cc0..333819b 100644 --- a/desktop/modules/updates/test_updatesctl.py +++ b/desktop/modules/updates/test_updatesctl.py @@ -43,6 +43,11 @@ assert u.vercmp("0.12.3_beta.4", "0.12.3") < 0 assert u.vercmp("9.018.00_6.18.41", "9.018.00") > 0 assert u.vercmp("3.1-659215d", "3.1") > 0 assert u.vercmp("1.0.1", "1.0rc1") > 0 +# Only named pre-releases are behind: a git hash starting with a letter is a +# suffix, and trailing zeros are not a newer version. +assert u.vercmp("3.1-a59215d", "3.1") > 0 +assert u.vercmp("1.14", "1.14.0") == 0 +assert u.vercmp("2.0rc1", "2.0") < 0 # --- fixture tree --- tmp = Path(tempfile.mkdtemp(prefix="updatesctl-test-")) 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()): |
