summaryrefslogtreecommitdiff
path: root/raveos-updater/check.py
diff options
context:
space:
mode:
Diffstat (limited to 'raveos-updater/check.py')
-rw-r--r--raveos-updater/check.py83
1 files changed, 0 insertions, 83 deletions
diff --git a/raveos-updater/check.py b/raveos-updater/check.py
deleted file mode 100644
index 79a0ba3..0000000
--- a/raveos-updater/check.py
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env python3
-"""RaveOS frissítés-ellenőrző.
-
-A raveos-core-repo szinkron adatbázisából kiolvassa a RaveOS saját
-csomagjainak legfrissebb verzióját, összeveti a telepített verziókkal,
-és a /var/lib/raveos-updater/status.json fájlba írja az eredményt.
-
-Használat:
- check.py # pacman -Sy után ellenőriz (root; a systemd timer hívja)
- check.py --no-sync # nem szinkronizál, a meglévő DB-t használja (pacman hook)
-"""
-
-import json
-import os
-import subprocess
-import sys
-from datetime import datetime
-
-REPO = "raveos-core-repo"
-STATUS_DIR = "/var/lib/raveos-updater"
-STATUS_FILE = os.path.join(STATUS_DIR, "status.json")
-
-
-def run(args):
- return subprocess.run(args, capture_output=True, text=True)
-
-
-def main():
- sync = "--no-sync" not in sys.argv[1:]
- error = None
-
- if sync:
- r = run(["pacman", "-Sy", "--noconfirm"])
- if r.returncode != 0:
- error = "sync failed"
-
- installed = {}
- repo = {}
-
- try:
- for line in run(["pacman", "-Q"]).stdout.splitlines():
- name, _, version = line.partition(" ")
- if version:
- installed[name] = version
-
- for line in run(["pacman", "-Sl", REPO]).stdout.splitlines():
- parts = line.split()
- if len(parts) >= 3:
- repo[parts[1]] = parts[2]
- except FileNotFoundError:
- error = "pacman not found"
-
- updates = []
- for name, newver in sorted(repo.items()):
- oldver = installed.get(name)
- if oldver is None:
- continue
- r = run(["vercmp", newver, oldver])
- try:
- newer = int(r.stdout.strip()) > 0
- except (ValueError, AttributeError):
- continue
- if newer:
- updates.append({"name": name, "old": oldver, "new": newver})
-
- status = {
- "count": len(updates),
- "checked": datetime.now().astimezone().isoformat(timespec="seconds"),
- "updates": updates,
- }
- if error:
- status["error"] = error
-
- os.makedirs(STATUS_DIR, exist_ok=True)
- tmp = STATUS_FILE + ".tmp"
- with open(tmp, "w", encoding="utf-8") as f:
- json.dump(status, f, ensure_ascii=False, indent=2)
- os.replace(tmp, STATUS_FILE)
- os.chmod(STATUS_FILE, 0o644)
-
-
-if __name__ == "__main__":
- main()