nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 44 lines 1.5 kB view raw
1#!/usr/bin/env nix-shell 2#!nix-shell --pure -i python3 -p "python3.withPackages (ps: with ps; [ requests ])" 3import json 4import os 5import requests 6import sys 7 8def parse_packages(text): 9 res = [] 10 for package in resp.text.split("\n\n"): 11 if not package: continue 12 pkg = {} 13 for field in package.split("\n"): 14 if field.startswith(" "): # multiline string 15 pkg[k] += "\n" + field[1:] 16 else: 17 [k, v] = field.split(": ", 1) 18 pkg[k] = v 19 res.append(pkg) 20 return res 21 22def generate_sources(packages): 23 sources_spec = {} 24 for pkg in pkgs: 25 sources_spec[pkg['Package']] = { 26 "url": "https://labs.picotech.com/rc/picoscope7/debian/" + pkg["Filename"], 27 "sha256": pkg["SHA256"], 28 "version": pkg["Version"] 29 } 30 return sources_spec 31 32out = {} 33for nix_system, release in {"x86_64-linux": "amd64"}.items(): 34 resp = requests.get("https://labs.picotech.com/rc/picoscope7/debian//dists/picoscope/main/binary-"+release+"/Packages") 35 if resp.status_code != 200: 36 print("error: could not fetch data for release {} (code {})".format(release, resp.code), file=sys.stderr) 37 sys.exit(1) 38 pkgs = parse_packages(resp.text) 39 out[nix_system] = generate_sources(pkgs) 40 41with open(os.path.dirname(__file__) + "/sources.json", "w") as f: 42 json.dump(out, f, indent=2, sort_keys=True) 43 f.write('\n') 44