1 #!/usr/bin/env nix-shell
2 #!nix-shell --pure -i python3 -p "python3.withPackages (ps: with ps; [ requests ])"
9 feature_versions
= (8, 11, 17, 21, 23)
10 oses
= ("mac", "linux", "alpine-linux")
11 types
= ("jre", "jdk")
16 "aarch64": ("aarch64",),
17 "arm": ("armv6l", "armv7l"),
18 "ppc64le": ("powerpc64le",),
19 "riscv64": ("riscv64",),
22 def generate_sources(assets
, feature_version
, out
):
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"])
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"],
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
)
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)