2018-12-17 22:08:56 +00:00
|
|
|
#!/usr/bin/env nix-shell
|
2018-12-18 19:24:58 +00:00
|
|
|
#!nix-shell --pure -i python3 -p "python3.withPackages (ps: with ps; [ requests ])"
|
2018-12-17 22:08:56 +00:00
|
|
|
|
|
|
|
import json
|
|
|
|
import re
|
|
|
|
import requests
|
|
|
|
import sys
|
|
|
|
|
2021-03-20 00:11:52 +00:00
|
|
|
releases = ("openjdk8", "openjdk11", "openjdk13", "openjdk14", "openjdk15", "openjdk16")
|
2019-07-21 19:40:18 +00:00
|
|
|
oses = ("mac", "linux")
|
|
|
|
types = ("jre", "jdk")
|
|
|
|
impls = ("hotspot", "openj9")
|
2018-12-17 22:08:56 +00:00
|
|
|
|
|
|
|
arch_to_nixos = {
|
2019-07-20 16:26:44 +00:00
|
|
|
"x64": ("x86_64",),
|
|
|
|
"aarch64": ("aarch64",),
|
|
|
|
"arm": ("armv6l", "armv7l"),
|
2022-04-10 08:50:31 +00:00
|
|
|
"ppc64le": ("powerpc64le",),
|
2018-12-17 22:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def get_sha256(url):
|
|
|
|
resp = requests.get(url)
|
|
|
|
if resp.status_code != 200:
|
|
|
|
print("error: could not fetch checksum from url {}: code {}".format(url, resp.code), file=sys.stderr)
|
|
|
|
sys.exit(1)
|
|
|
|
return resp.text.strip().split(" ")[0]
|
|
|
|
|
|
|
|
def generate_sources(release, assets):
|
|
|
|
out = {}
|
|
|
|
for asset in assets:
|
|
|
|
if asset["os"] not in oses: continue
|
|
|
|
if asset["binary_type"] not in types: continue
|
|
|
|
if asset["openjdk_impl"] not in impls: continue
|
|
|
|
if asset["heap_size"] != "normal": continue
|
|
|
|
if asset["architecture"] not in arch_to_nixos: continue
|
|
|
|
|
2019-07-21 19:40:18 +00:00
|
|
|
# examples: 11.0.1+13, 8.0.222+10
|
|
|
|
version, build = asset["version_data"]["semver"].split("+")
|
2018-12-17 22:08:56 +00:00
|
|
|
|
|
|
|
type_map = out.setdefault(asset["os"], {})
|
|
|
|
impl_map = type_map.setdefault(asset["binary_type"], {})
|
|
|
|
arch_map = impl_map.setdefault(asset["openjdk_impl"], {
|
|
|
|
"packageType": asset["binary_type"],
|
|
|
|
"vmType": asset["openjdk_impl"],
|
|
|
|
})
|
|
|
|
|
2019-07-20 16:26:44 +00:00
|
|
|
for nixos_arch in arch_to_nixos[asset["architecture"]]:
|
|
|
|
arch_map[nixos_arch] = {
|
|
|
|
"url": asset["binary_link"],
|
|
|
|
"sha256": get_sha256(asset["checksum_link"]),
|
|
|
|
"version": version,
|
|
|
|
"build": build,
|
|
|
|
}
|
2018-12-17 22:08:56 +00:00
|
|
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
out = {}
|
|
|
|
for release in releases:
|
|
|
|
resp = requests.get("https://api.adoptopenjdk.net/v2/latestAssets/releases/" + release)
|
|
|
|
if resp.status_code != 200:
|
|
|
|
print("error: could not fetch data for release {} (code {})".format(release, resp.code), file=sys.stderr)
|
|
|
|
sys.exit(1)
|
|
|
|
out[release] = generate_sources(release, resp.json())
|
|
|
|
|
|
|
|
with open("sources.json", "w") as f:
|
|
|
|
json.dump(out, f, indent=2, sort_keys=True)
|
2021-02-14 14:24:25 +00:00
|
|
|
f.write('\n')
|