scripts/kde: handle missing hashes gracefully

This commit is contained in:
K900 2025-07-15 14:12:38 +03:00
parent 454765d7f5
commit a2f4f88315

View File

@ -2,6 +2,7 @@
#!nix-shell -i python3 -p "python3.withPackages(ps: [ ps.beautifulsoup4 ps.click ps.httpx ps.jinja2 ps.packaging ps.pyyaml ])" nix-update
import base64
import binascii
import hashlib
import json
import pathlib
import subprocess
@ -112,8 +113,17 @@ def main(pkgset: str, version: str, nixpkgs: pathlib.Path, sources_url: str | No
url = urljoin(sources_url, link.attrs["href"])
hash = client.get(url + ".sha256").text.split(" ", maxsplit=1)[0]
assert hash
hash = client.get(url + ".sha256").text.strip()
if hash == "Hash type not supported":
print(f"{url} missing hash on CDN, downloading...")
hasher = hashlib.sha256()
with client.stream("GET", url, follow_redirects=True) as r:
for data in r.iter_bytes():
hasher.update(data)
hash = hasher.hexdigest()
else:
hash = hash.split(" ", maxsplit=1)[0]
if existing := results.get(project_name):
old_version = existing["version"]