diff --git a/apps/control-center/i18n/de.json b/apps/control-center/i18n/de.json index 01c2dae8..c94a0afb 100644 --- a/apps/control-center/i18n/de.json +++ b/apps/control-center/i18n/de.json @@ -516,5 +516,7 @@ "From now on EVERYTHING that draws goes through our Mesa, desktop included: Vulkan and OpenGL. 32-bit stays on the stock driver. Proceed?": "Ab jetzt läuft ALLES, was zeichnet, über unsere Mesa, Desktop eingeschlossen: Vulkan und OpenGL. 32-Bit bleibt beim Serientreiber. Fortfahren?", "With the system driver on, the launchers take it from there.": "Wenn der Systemtreiber an ist, holen ihn sich die Starter von dort.", "System graphics driver": "Grafiktreiber des Systems", - "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "Kein Modell auf der Platte: lade eines über Studio herunter oder kopiere eine .gguf nach ~/modelli" + "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "Kein Modell auf der Platte: lade eines über Studio herunter oder kopiere eine .gguf nach ~/modelli", + "checking the checksum": "prüfe die Prüfsumme", + "wrong sha512 checksum: the download is corrupt": "falsche sha512-Prüfsumme: der Download ist beschädigt" } diff --git a/apps/control-center/i18n/es.json b/apps/control-center/i18n/es.json index e9dc471c..b5f5e352 100644 --- a/apps/control-center/i18n/es.json +++ b/apps/control-center/i18n/es.json @@ -516,5 +516,7 @@ "From now on EVERYTHING that draws goes through our Mesa, desktop included: Vulkan and OpenGL. 32-bit stays on the stock driver. Proceed?": "A partir de ahora TODO lo que dibuja pasa por nuestra Mesa, escritorio incluido: Vulkan y OpenGL. Los 32 bits se quedan con el controlador de serie. ¿Continuar?", "With the system driver on, the launchers take it from there.": "Con el controlador del sistema activado, los lanzadores lo toman de ahí.", "System graphics driver": "Controlador gráfico del sistema", - "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "Ningún modelo en el disco: descarga uno desde Studio o copia un .gguf en ~/modelli" + "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "Ningún modelo en el disco: descarga uno desde Studio o copia un .gguf en ~/modelli", + "checking the checksum": "compruebo la suma de verificación", + "wrong sha512 checksum: the download is corrupt": "suma sha512 incorrecta: la descarga está dañada" } diff --git a/apps/control-center/i18n/fr.json b/apps/control-center/i18n/fr.json index 502e8a14..ce222145 100644 --- a/apps/control-center/i18n/fr.json +++ b/apps/control-center/i18n/fr.json @@ -516,5 +516,7 @@ "From now on EVERYTHING that draws goes through our Mesa, desktop included: Vulkan and OpenGL. 32-bit stays on the stock driver. Proceed?": "Dès maintenant TOUT ce qui dessine passe par notre Mesa, bureau compris : Vulkan et OpenGL. Le 32 bits reste sur le pilote d'origine. Continuer ?", "With the system driver on, the launchers take it from there.": "Quand le pilote système est activé, les lanceurs le prennent de là.", "System graphics driver": "Pilote graphique du système", - "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "Aucun modèle sur le disque : téléchargez-en un depuis Studio ou copiez un .gguf dans ~/modelli" + "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "Aucun modèle sur le disque : téléchargez-en un depuis Studio ou copiez un .gguf dans ~/modelli", + "checking the checksum": "vérification de la somme de contrôle", + "wrong sha512 checksum: the download is corrupt": "somme sha512 incorrecte : le téléchargement est corrompu" } diff --git a/apps/control-center/i18n/pl.json b/apps/control-center/i18n/pl.json index 672f7c5c..b16ac692 100644 --- a/apps/control-center/i18n/pl.json +++ b/apps/control-center/i18n/pl.json @@ -517,5 +517,7 @@ "From now on EVERYTHING that draws goes through our Mesa, desktop included: Vulkan and OpenGL. 32-bit stays on the stock driver. Proceed?": "Od teraz WSZYSTKO, co rysuje, przechodzi przez naszą Mesę, łącznie z pulpitem: Vulkan i OpenGL. 32-bit zostaje na fabrycznym sterowniku. Kontynuować?", "With the system driver on, the launchers take it from there.": "Gdy sterownik systemowy jest włączony, programy uruchamiające biorą go stamtąd.", "System graphics driver": "Systemowy sterownik graficzny", - "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "Brak modelu na dysku: pobierz go przez Studio albo skopiuj plik .gguf do ~/modelli" + "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "Brak modelu na dysku: pobierz go przez Studio albo skopiuj plik .gguf do ~/modelli", + "checking the checksum": "sprawdzam sumę kontrolną", + "wrong sha512 checksum: the download is corrupt": "błędna suma sha512: pobrany plik jest uszkodzony" } diff --git a/apps/control-center/i18n/pt.json b/apps/control-center/i18n/pt.json index c046debd..2f8ff040 100644 --- a/apps/control-center/i18n/pt.json +++ b/apps/control-center/i18n/pt.json @@ -516,5 +516,7 @@ "From now on EVERYTHING that draws goes through our Mesa, desktop included: Vulkan and OpenGL. 32-bit stays on the stock driver. Proceed?": "A partir de agora TUDO o que desenha passa pela nossa Mesa, ambiente de trabalho incluído: Vulkan e OpenGL. Os 32 bits ficam com o driver de série. Continuar?", "With the system driver on, the launchers take it from there.": "Com o driver do sistema ligado, os lançadores usam-no a partir daí.", "System graphics driver": "Driver gráfico do sistema", - "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "Nenhum modelo no disco: descarregue um pelo Studio ou copie um .gguf para ~/modelli" + "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "Nenhum modelo no disco: descarregue um pelo Studio ou copie um .gguf para ~/modelli", + "checking the checksum": "a verificar a soma de verificação", + "wrong sha512 checksum: the download is corrupt": "soma sha512 errada: a transferência está corrompida" } diff --git a/apps/control-center/i18n/ru.json b/apps/control-center/i18n/ru.json index ad75c40c..5004dd06 100644 --- a/apps/control-center/i18n/ru.json +++ b/apps/control-center/i18n/ru.json @@ -516,5 +516,7 @@ "From now on EVERYTHING that draws goes through our Mesa, desktop included: Vulkan and OpenGL. 32-bit stays on the stock driver. Proceed?": "С этого момента ВСЁ, что рисует, идёт через нашу Mesa, включая рабочий стол: Vulkan и OpenGL. 32-битное остаётся на штатном драйвере. Продолжить?", "With the system driver on, the launchers take it from there.": "Когда системный драйвер включён, лаунчеры берут его оттуда.", "System graphics driver": "Системный графический драйвер", - "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "На диске нет модели: скачайте её через Studio или скопируйте .gguf в ~/modelli" + "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "На диске нет модели: скачайте её через Studio или скопируйте .gguf в ~/modelli", + "checking the checksum": "проверяю контрольную сумму", + "wrong sha512 checksum: the download is corrupt": "неверная контрольная сумма sha512: загрузка повреждена" } diff --git a/apps/control-center/i18n/uk.json b/apps/control-center/i18n/uk.json index 46c765fc..a8a53c3f 100644 --- a/apps/control-center/i18n/uk.json +++ b/apps/control-center/i18n/uk.json @@ -517,5 +517,7 @@ "From now on EVERYTHING that draws goes through our Mesa, desktop included: Vulkan and OpenGL. 32-bit stays on the stock driver. Proceed?": "Відтепер УСЕ, що малює, іде через нашу Mesa, разом зі стільницею: Vulkan і OpenGL. 32-бітне лишається на штатному драйвері. Продовжити?", "With the system driver on, the launchers take it from there.": "Коли системний драйвер увімкнено, запускачі беруть його звідти.", "System graphics driver": "Системний графічний драйвер", - "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "На диску немає моделі: завантажте її через Studio або скопіюйте .gguf до ~/modelli" + "No model on the disk: download one from Studio or copy a .gguf into ~/modelli": "На диску немає моделі: завантажте її через Studio або скопіюйте .gguf до ~/modelli", + "checking the checksum": "перевіряю контрольну суму", + "wrong sha512 checksum: the download is corrupt": "неправильна контрольна сума sha512: завантаження пошкоджене" } diff --git a/apps/control-center/sfcc/pagine/giochi.py b/apps/control-center/sfcc/pagine/giochi.py index bf41917f..9ede341c 100644 --- a/apps/control-center/sfcc/pagine/giochi.py +++ b/apps/control-center/sfcc/pagine/giochi.py @@ -8,6 +8,7 @@ started on this board. """ import configparser +import hashlib import importlib.machinery import importlib.util import json @@ -131,6 +132,21 @@ def nome_interno(cartella, n): return n +def cartella_di(n, cartelle): + """The installed folder of GE-Proton release n among `cartelle`, or None. + + ⚠️ The folder is not always the release name. Up to GE-Proton11-11 the + tarball unpacks into GE-Proton11-11; from GE-Proton11-12 it unpacks into + GE-Proton11-12-x86_64. Comparing names only, the page listed the release + as "not installed" next to a second row for the folder, and "Install" + downloaded the same 500 MB again. + """ + for d in (n, n + "-x86_64"): + if d in cartelle: + return d + return None + + def proton_installati(): out = {} for nome, cartella in (("steam", STEAM_TOOLS), ("heroic", HEROIC_TOOLS)): @@ -175,9 +191,26 @@ class Scarica(QThread): avanzamento = pyqtSignal(int, str) finito = pyqtSignal(bool, str) - def __init__(self, url, nome, cartelle, parent=None): + def __init__(self, url, nome, cartelle, sha=None, parent=None): super().__init__(parent) - self.url, self.nome, self.cartelle = url, nome, cartelle + self.url, self.nome, self.cartelle, self.sha = url, nome, cartelle, sha + + def _verifica(self, percorso): + """Check the tarball against the .sha512sum GloriousEggroll publishes + next to it. A release without one is installed as before; a mismatch + is never unpacked.""" + if not self.sha: + return + req = urllib.request.Request(self.sha, headers={"User-Agent": "SkillFishOS-Control-Center"}) + with urllib.request.urlopen(req, timeout=30) as r: + atteso = r.read().decode("ascii", "replace").split()[0].lower() + h = hashlib.sha512() + with open(percorso, "rb") as f: + for blocco in iter(lambda: f.read(1 << 20), b""): + h.update(blocco) + if h.hexdigest() != atteso: + raise ValueError(L("checksum sha512 sbagliato: lo scaricamento è corrotto", + "wrong sha512 checksum: the download is corrupt")) def run(self): tmp = None @@ -195,6 +228,8 @@ def run(self): letti += len(b) self.avanzamento.emit(int(letti * 100 / tot) if tot else 0, "%d MB" % (letti >> 20)) tmp.close() + self.avanzamento.emit(100, L("controllo il checksum", "checking the checksum")) + self._verifica(tmp.name) for cartella in self.cartelle: os.makedirs(cartella, exist_ok=True) self.avanzamento.emit(100, L("estraggo in %s", "unpacking into %s") % cartella) @@ -473,9 +508,12 @@ def _scarica_elenco(self): out = [] for rel in dati: nome = rel.get("tag_name", "") - asset = next((a for a in rel.get("assets", []) if a["name"].endswith(".tar.gz") and "aarch64" not in a["name"]), None) + assets = rel.get("assets", []) + asset = next((a for a in assets if a["name"].endswith(".tar.gz") and "aarch64" not in a["name"]), None) + somma = next((a for a in assets if a["name"].endswith(".sha512sum") and "aarch64" not in a["name"]), None) if asset and nome: out.append({"nome": nome, "url": asset["browser_download_url"], "mb": asset["size"] >> 20, + "sha": somma["browser_download_url"] if somma else None, "data": (rel.get("published_at") or "")[:10]}) return {"ok": True, "versioni": out} except Exception as e: @@ -497,14 +535,16 @@ def _proton_elenca(self): for v in self.versioni: nomi.append(v["nome"]) for n in inst["steam"] + inst["heroic"]: - if n not in nomi: + # a folder that belongs to a listed release is shown on its row + if n not in nomi and not any(cartella_di(r, [n]) for r in nomi): nomi.append(n) for n in nomi: dove = [] - if n in inst["steam"]: - dove.append("Steam" + (" ★" if ds in (n, nome_interno(STEAM_TOOLS, n)) else "")) - if n in inst["heroic"]: - dove.append("Heroic" + (" ★" if n == dh else "")) + cs, ch = cartella_di(n, inst["steam"]), cartella_di(n, inst["heroic"]) + if cs: + dove.append("Steam" + (" ★" if ds in (cs, nome_interno(STEAM_TOOLS, cs)) else "")) + if ch: + dove.append("Heroic" + (" ★" if ch == dh else "")) v = next((x for x in self.versioni if x["nome"] == n), None) testo = n if v: @@ -549,7 +589,7 @@ def _installa(self): self.barra.setValue(0) self.barra.show() self.e_proton.setText(L("Scarico %s (%d MB)…", "Downloading %s (%d MB)…") % (n, v["mb"])) - self._scarica = Scarica(v["url"], n, cartelle, self) + self._scarica = Scarica(v["url"], n, cartelle, v.get("sha"), self) self._scarica.avanzamento.connect(self._avanza) self._scarica.finito.connect(self._scaricato) self._scarica.start() @@ -570,14 +610,16 @@ def _rimuovi(self): if not n: return inst = proton_installati() - dove = [(STEAM_TOOLS, "Steam") for _ in [0] if n in inst["steam"]] + [(HEROIC_TOOLS, "Heroic") for _ in [0] if n in inst["heroic"]] + dove = [(STEAM_TOOLS, "Steam", cartella_di(n, inst["steam"])), + (HEROIC_TOOLS, "Heroic", cartella_di(n, inst["heroic"]))] + dove = [x for x in dove if x[2]] if not dove: self.toast(L("Non e' installata.", "It is not installed.")) return - if QMessageBox.question(self, L("Rimuovere?", "Remove?"), L("Tolgo %s da %s?", "Remove %s from %s?") % (n, ", ".join(d for _, d in dove))) != QMessageBox.StandardButton.Yes: + if QMessageBox.question(self, L("Rimuovere?", "Remove?"), L("Tolgo %s da %s?", "Remove %s from %s?") % (n, ", ".join(d for _, d, _ in dove))) != QMessageBox.StandardButton.Yes: return - for cartella, _ in dove: - shutil.rmtree(os.path.join(cartella, n), ignore_errors=True) + for cartella, _, sotto in dove: + shutil.rmtree(os.path.join(cartella, sotto), ignore_errors=True) self._proton_elenca() def _default(self, dove): @@ -585,9 +627,11 @@ def _default(self, dove): if not n: return inst = proton_installati() - if n not in inst[dove]: + c = cartella_di(n, inst[dove]) + if not c: self.toast(L("Prima installala in %s.", "Install it in %s first.") % dove.capitalize()) return + n = c # the folder is what Heroic and Steam know if dove == "heroic": try: with open(HEROIC_CONFIG) as f: diff --git a/tests/test_cc_proton_folder.py b/tests/test_cc_proton_folder.py new file mode 100644 index 00000000..5313ede3 --- /dev/null +++ b/tests/test_cc_proton_folder.py @@ -0,0 +1,40 @@ +"""Control Center, Games page: which folder a GE-Proton release is installed in. + +From GE-Proton11-12 the tarball unpacks into GE-Proton11-12-x86_64, not +GE-Proton11-12. The page compared names only, showed the release as not +installed and downloaded it again. giochi.py needs PyQt and the Control +Center package to import, so only cartella_di() is taken out of it. +""" +import ast +import pathlib + +GIOCHI = (pathlib.Path(__file__).resolve().parents[1] + / "apps" / "control-center" / "sfcc" / "pagine" / "giochi.py") + + +def _cartella_di(): + tree = ast.parse(GIOCHI.read_text(encoding="utf-8")) + fn = next(n for n in tree.body if isinstance(n, ast.FunctionDef) and n.name == "cartella_di") + ns = {} + exec(compile(ast.Module(body=[fn], type_ignores=[]), str(GIOCHI), "exec"), ns) + return ns["cartella_di"] + + +def test_old_releases_unpack_into_their_own_name(): + f = _cartella_di() + assert f("GE-Proton11-6", ["GE-Proton10-34", "GE-Proton11-6"]) == "GE-Proton11-6" + + +def test_new_releases_unpack_into_name_x86_64(): + f = _cartella_di() + assert f("GE-Proton11-12", ["GE-Proton11-12-x86_64", "GE-Proton11-6"]) == "GE-Proton11-12-x86_64" + + +def test_not_installed_is_none(): + f = _cartella_di() + assert f("GE-Proton11-12", ["GE-Proton11-6"]) is None + + +def test_a_prefix_of_another_release_does_not_match(): + f = _cartella_di() + assert f("GE-Proton11-1", ["GE-Proton11-12-x86_64", "GE-Proton11-12"]) is None