lol

scripts/kde: handle missing hashes gracefully

K900 a2f4f883 454765d7

+12 -2
+12 -2
maintainers/scripts/kde/generate-sources.py
··· 2 2 #!nix-shell -i python3 -p "python3.withPackages(ps: [ ps.beautifulsoup4 ps.click ps.httpx ps.jinja2 ps.packaging ps.pyyaml ])" nix-update 3 3 import base64 4 4 import binascii 5 + import hashlib 5 6 import json 6 7 import pathlib 7 8 import subprocess ··· 112 113 113 114 url = urljoin(sources_url, link.attrs["href"]) 114 115 115 - hash = client.get(url + ".sha256").text.split(" ", maxsplit=1)[0] 116 - assert hash 116 + hash = client.get(url + ".sha256").text.strip() 117 + 118 + if hash == "Hash type not supported": 119 + print(f"{url} missing hash on CDN, downloading...") 120 + hasher = hashlib.sha256() 121 + with client.stream("GET", url, follow_redirects=True) as r: 122 + for data in r.iter_bytes(): 123 + hasher.update(data) 124 + hash = hasher.hexdigest() 125 + else: 126 + hash = hash.split(" ", maxsplit=1)[0] 117 127 118 128 if existing := results.get(project_name): 119 129 old_version = existing["version"]