python313Packages.pyais: 2.8.3 -> 2.8.4 (#378375)
[NixPkgs.git] / pkgs / development / compilers / temurin-bin / generate-sources.py
bloba5c5d6f9ffb87f8f807c934f220f817f218616ed
1 #!/usr/bin/env nix-shell
2 #!nix-shell --pure -i python3 -p "python3.withPackages (ps: with ps; [ requests ])"
4 import json
5 import re
6 import requests
7 import sys
9 feature_versions = (8, 11, 17, 21, 23)
10 oses = ("mac", "linux", "alpine-linux")
11 types = ("jre", "jdk")
12 impls = ("hotspot",)
14 arch_to_nixos = {
15 "x64": ("x86_64",),
16 "aarch64": ("aarch64",),
17 "arm": ("armv6l", "armv7l"),
18 "ppc64le": ("powerpc64le",),
19 "riscv64": ("riscv64",),
22 def generate_sources(assets, feature_version, out):
23 for asset in assets:
24 binary = asset["binary"]
25 if binary["os"] not in oses: continue
26 if binary["image_type"] not in types: continue
27 if binary["jvm_impl"] not in impls: continue
28 if binary["heap_size"] != "normal": continue
29 if binary["architecture"] not in arch_to_nixos: continue
31 version = ".".join(str(v) for v in [
32 asset["version"]["major"],
33 asset["version"]["minor"],
34 asset["version"]["security"]
36 build = str(asset["version"]["build"])
38 arch_map = (
39 out
40 .setdefault(binary["jvm_impl"], {})
41 .setdefault(binary["os"], {})
42 .setdefault(binary["image_type"], {})
43 .setdefault(feature_version, {
44 "packageType": binary["image_type"],
45 "vmType": binary["jvm_impl"],
49 for nixos_arch in arch_to_nixos[binary["architecture"]]:
50 arch_map[nixos_arch] = {
51 "url": binary["package"]["link"],
52 "sha256": binary["package"]["checksum"],
53 "version": version,
54 "build": build,
57 return out
60 out = {}
61 for feature_version in feature_versions:
62 # Default user-agenet is blocked by Azure WAF.
63 headers = {'user-agent': 'nixpkgs-temurin-generate-sources/1.0.0'}
64 resp = requests.get(f"https://api.adoptium.net/v3/assets/latest/{feature_version}/hotspot", headers=headers)
66 if resp.status_code != 200:
67 print("error: could not fetch data for release {} (code {}) {}".format(feature_version, resp.status_code, resp.content), file=sys.stderr)
68 sys.exit(1)
69 generate_sources(resp.json(), f"openjdk{feature_version}", out)
71 with open("sources.json", "w") as f:
72 json.dump(out, f, indent=2, sort_keys=True)
73 f.write('\n')