This repository has been archived by the owner on Nov 18, 2023. It is now read-only.
forked from halcyon/asdf-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_data.bash
executable file
·69 lines (58 loc) · 1.86 KB
/
update_data.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
set -x
set -e
set -Euo pipefail
# See https://joschi.github.io/java-metadata/ for supported values
LIST_OS="linux macosx"
LIST_ARCH="x86_64 aarch64 arm32-vfp-hflt"
LIST_RELEASE_TYPE="ga ea"
DATA_DIR="./data"
if [[ ! -d "${DATA_DIR}" ]]
then
mkdir "${DATA_DIR}"
fi
function metadata_url {
local os=$1
local arch=$2
local release=$3
echo "https://joschi.github.io/java-metadata/metadata/${release}/${os}/${arch}.json"
}
function fetch_metadata {
local os=$1
local arch=$2
local release=$3
local args=('-s' '-f' '--compressed' '-H' "Accept: application/json")
if [[ -n "${GITHUB_API_TOKEN:-}" ]]; then
args+=('-H' "Authorization: token $GITHUB_API_TOKEN")
fi
local url
url=$(metadata_url "$os" "$arch" "$release")
curl "${args[@]}" -o "${DATA_DIR}/jdk-${os}-${arch}-${release}.json" "${url}"
}
for OS in $LIST_OS
do
for ARCH in $LIST_ARCH
do
for RELEASE_TYPE in $LIST_RELEASE_TYPE
do
fetch_metadata "$OS" "$ARCH" "$RELEASE_TYPE"
done
cat "${DATA_DIR}/jdk-${OS}-${ARCH}"-*.json | jq -s 'add' > "${DATA_DIR}/jdk-${OS}-${ARCH}-all.json"
ln -fs "jdk-${OS}-${ARCH}-ga.json" "${DATA_DIR}/jdk-${OS}-${ARCH}.json"
done
done
RELEASE_QUERY='.[]
| select(.file_type | IN("tar.gz", "zip"))
| .["features"] = (.features | map(select(IN("musl", "javafx", "lite", "large_heap"))))
| [([.vendor, if (.image_type == "jre") then .image_type else empty end, if (.jvm_impl == "openj9") then .jvm_impl else empty end, if ((.features | length) == 0) then empty else (.features | join("-")) end, .version] | join("-")), .filename, .url, .sha256]
| @tsv'
for FILE in "${DATA_DIR}"/*.json
do
TSV_FILE="$(basename "${FILE}" .json).tsv"
jq -r "${RELEASE_QUERY}" "${FILE}" | sort -V > "${DATA_DIR}/${TSV_FILE}"
done
rm "${DATA_DIR}"/*.json
# copy aarch64 files to arm64
for FILE in "${DATA_DIR}"/*-aarch64-*.tsv; do
cp "${FILE}" "${FILE/aarch64/arm64}"
done