diff --git a/maintainers/scripts/kde/generate-sources.py b/maintainers/scripts/kde/generate-sources.py index f251a737efd1..2966e7ef9675 100755 --- a/maintainers/scripts/kde/generate-sources.py +++ b/maintainers/scripts/kde/generate-sources.py @@ -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"]