diff --git a/out-of-tree/nixGL/fetch.py b/out-of-tree/nixGL/fetch.py index 2435435..688a64e 100755 --- a/out-of-tree/nixGL/fetch.py +++ b/out-of-tree/nixGL/fetch.py @@ -1,9 +1,14 @@ +#!/usr/bin/env python3 +# execution: fetch.py >nvidia_versions.json + import http.client import json import sys NV_FREE_X86_URL = "download.nvidia.com" POTENTIAL_SHA256_EXTS = [".sha256sum", ".sha256"] +RIGHT_PAD = " " * 20 + conn = http.client.HTTPSConnection(NV_FREE_X86_URL) conn.request("GET", "/XFree86/Linux-x86_64/") response = conn.getresponse() @@ -32,9 +37,8 @@ def scrape_driver_versions(dir_html: bytes): versions = _rec(dir_html, 0, []) num_versions = len(versions) - right_pad = " " * 50 for i, version in enumerate(versions): - print(f"[{i+1}/{num_versions}] Processing version {version}{right_pad}", end="\r", file=sys.stderr) + print(f"[{i+1}/{num_versions}] Processing version {version}{RIGHT_PAD}", end="\r", file=sys.stderr) yield version print() @@ -48,15 +52,24 @@ sha256_urls_of = lambda ver: [ ] def sha256_of(version: str) -> str | None: + if int(version.split(".")[0]) < 256: + # Has 3 different packages that we should probably not bother + return None for url in sha256_urls_of(version): conn = http.client.HTTPSConnection(NV_FREE_X86_URL) conn.request("GET", url) response = conn.getresponse() if response.status < 400: return response.read().decode().split()[0] + print(f"No sha256 for {version}{RIGHT_PAD}", file=sys.stderr) return None -fetch_data = [(v, download_urls_of(v)[0], sha256_of(v)) for v in versions] +def fetch(version: str): + dl_url = download_urls_of(version)[0] + sha256 = sha256_of(version) + return (version, dl_url, sha256) + +fetch_data = [fetch(v) for v in versions] fetch_data.append(("latest", *fetch_data[-1][1:])) # now print the JSON object @@ -65,4 +78,4 @@ print(json.dumps({ "url": f"https://{NV_FREE_X86_URL}{dl_url}", "sha256": sha256 } for (version, dl_url, sha256) in fetch_data if sha256 is not None}, indent=4)) -# execution: fetch.py >nvidia_versions.json + diff --git a/out-of-tree/nixGL/nvidia_versions.json b/out-of-tree/nixGL/nvidia_versions.json index 9d94b03..97de4f2 100644 --- a/out-of-tree/nixGL/nvidia_versions.json +++ b/out-of-tree/nixGL/nvidia_versions.json @@ -1,3 +1,4 @@ + { "256.25": { "url": "https://download.nvidia.com/XFree86/Linux-x86_64/256.25/NVIDIA-Linux-x86_64-256.25.run",