Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bin/functions
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@ function retrieve-release-data() {
local cache_file="${CACHE_DIR}/releases-${OS}-${ARCHITECTURE}.tsv"
# shellcheck disable=SC2046
if [[ ! -r "${cache_file}" ]] || (( $($STAT "${STAT_OPTS[@]}" "${cache_file}") <= $(date +%s) - 3600 )) ; then
curl -s -f --compressed -L "https://raw.githubusercontent.com/halcyon/asdf-java/master/data/jdk-${OS}-${ARCHITECTURE}.tsv" -o "${cache_file}"
local base_url="https://raw.githubusercontent.com/halcyon/asdf-java/master/data/jdk-${OS}-${ARCHITECTURE}"
local url
case "$(get_asdf_config_value "java_release_type")" in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for the opt-in.

ga) url="$base_url-ga.tsv" ;;
ea) url="$base_url-ea.tsv" ;;
all) url="$base_url.tsv" ;;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joschi Is it expected the "all" url (i.e. without classifier) is the same as the -ga one ?

$ curl -s https://raw.githubusercontent.com/halcyon/asdf-java/master/data/jdk-macosx-aarch64.tsv | wc -l
    1134
$ curl -s https://raw.githubusercontent.com/halcyon/asdf-java/master/data/jdk-macosx-aarch64-ga.tsv | wc -l
    1134

*) url="$base_url-ga.tsv" ;;
esac

curl -s -f --compressed -L "${url}" -o "${cache_file}"
fi
}

Expand Down
20 changes: 14 additions & 6 deletions update_data.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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"

Expand All @@ -16,29 +17,36 @@ fi
function metadata_url {
local os=$1
local arch=$2
local release=$3

echo "https://joschi.github.io/java-metadata/metadata/ga/${os}/${arch}.json"
echo "https://joschi.github.io/java-metadata/metadata/${release}/${os}/${arch}.json"
}

function fetch_metadata {
local os=$1
local arch=$2
local url
url=$(metadata_url "$os" "$arch")
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

curl "${args[@]}" -o "${DATA_DIR}/jdk-${os}-${arch}.json" "${url}"
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
fetch_metadata "$OS" "$ARCH"
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 -s "jdk-${OS}-${ARCH}-ga.json" "${DATA_DIR}/jdk-${OS}-${ARCH}.json"
done
done

Expand All @@ -50,5 +58,5 @@ RELEASE_QUERY='.[]
for FILE in "${DATA_DIR}"/*.json
do
TSV_FILE="$(basename "${FILE}" .json).tsv"
jq -r "${RELEASE_QUERY}" "${FILE}" | sort -V > "${DATA_DIR}/${TSV_FILE}"
jq -r "${RELEASE_QUERY}" "${FILE}" | sort -V > "${DATA_DIR}/${TSV_FILE}"
done