From 17cc473c0197ea693f1c59acba1d72d32a115e87 Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Fri, 1 May 2026 16:06:13 -0500 Subject: [PATCH] feat: support liberica nik --- README.md | 1 + bin/functions.bash | 2 +- bin/liberica-nik.bash | 122 ++++++++++++++++++++++++++++++++++++++++++ bin/update.bash | 1 + 4 files changed, 125 insertions(+), 1 deletion(-) create mode 100755 bin/liberica-nik.bash diff --git a/README.md b/README.md index 814d6690bc2..bdd5bf95538 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Supported OpenJDK distributions: * [IBM Semeru](https://developer.ibm.com/languages/java/semeru-runtimes/) * [Java SE Reference Implementations](https://jdk.java.net/) * [Liberica](https://bell-sw.com/) +* [Liberica Native Image Kit](https://bell-sw.com/liberica-native-image-kit/) * [Mandrel](https://github.com/graalvm/mandrel) * [Microsoft OpenJDK](https://www.microsoft.com/openjdk) * [OpenJDK](https://jdk.java.net/) diff --git a/bin/functions.bash b/bin/functions.bash index 304a3c767a8..2b9439008e2 100644 --- a/bin/functions.bash +++ b/bin/functions.bash @@ -116,7 +116,7 @@ function metadata_json { function normalize_os { case "${1}" in - 'linux'|'Linux'|'alpine-linux') echo 'linux' + 'linux'|'Linux'|'alpine-linux'|'linux-musl') echo 'linux' ;; 'mac'|'macos'|'macosx'|'osx'|'darwin'|'macOS') echo 'macosx' ;; diff --git a/bin/liberica-nik.bash b/bin/liberica-nik.bash new file mode 100755 index 00000000000..7d2febb4ed1 --- /dev/null +++ b/bin/liberica-nik.bash @@ -0,0 +1,122 @@ +#!/usr/bin/env bash +set -e +set -Euo pipefail + +TEMP_DIR=$(mktemp -d) +trap 'rm -rf ${TEMP_DIR}' EXIT + +if [[ "$#" -lt 2 ]] +then + echo "Usage: ${0} metadata-directory checksum-directory" + exit 1 +fi + +# shellcheck source=bin/functions.bash +source "$(dirname "${0}")/functions.bash" + +VENDOR='liberica-nik' +METADATA_DIR="${1}/${VENDOR}" +CHECKSUM_DIR="${2}/${VENDOR}" + +ensure_directory "${METADATA_DIR}" +ensure_directory "${CHECKSUM_DIR}" + +API_URL="https://api.bell-sw.com/v1/nik/releases" + +function get_release_type { + if [[ "${1}" = 'true' ]] + then + echo 'ga' + else + echo 'ea' + fi +} + +function normalize_liberica_arch { + local arch="${1}" + local bitness="${2}" + if [[ "${arch}" == "x86" ]] && [[ "${bitness}" == "64" ]] + then + echo "x86_64" + elif [[ "${arch}" == "arm" ]] && [[ "${bitness}" == "64" ]] + then + echo "aarch64" + else + echo "${arch}" + fi +} + +function normalize_features { + local bundle_type="${1}" + local os="${2}" + declare -a features + if [[ "${bundle_type}" == "full" ]] + then + features+=("libericafx" "minimal-vm" "javafx") + fi + if [[ "${os}" == "linux-musl" ]] + then + features+=("musl") + fi + echo "${features[@]}" +} + +# Fetch releases +RELEASES_FILE="${TEMP_DIR}/releases.json" +curl -s "${API_URL}" > "${RELEASES_FILE}" + +# Iterate over releases +# We filter for nik component +jq -c '.[] | select(.component == "nik")' "${RELEASES_FILE}" | while read -r release; do + FILENAME=$(echo "${release}" | jq -r '.filename') + URL=$(echo "${release}" | jq -r '.downloadUrl') + VERSION=$(echo "${release}" | jq -r '.version') + GA=$(echo "${release}" | jq -r '.GA') + OS=$(echo "${release}" | jq -r '.os') + ARCH=$(echo "${release}" | jq -r '.architecture') + BITNESS=$(echo "${release}" | jq -r '.bitness') + EXT=$(echo "${release}" | jq -r '.packageType') + BUNDLE_TYPE=$(echo "${release}" | jq -r '.bundleType') + + # Extract Java version from components + JAVA_VERSION=$(echo "${release}" | jq -r '.components[] | select(.component == "liberica") | .version') + + METADATA_FILE="${METADATA_DIR}/${FILENAME}.json" + ARCHIVE="${TEMP_DIR}/${FILENAME}" + + if [[ -f "${METADATA_FILE}" ]] + then + echo "Skipping ${FILENAME}" + continue + fi + + echo "Processing ${FILENAME}" + download_file "${URL}" "${ARCHIVE}" || continue + + # Generate metadata JSON + json="$(metadata_json \ + "${VENDOR}" \ + "${FILENAME}" \ + "$(get_release_type "${GA}")" \ + "${VERSION}" \ + "${JAVA_VERSION}" \ + 'graalvm' \ + "$(normalize_os "${OS}")" \ + "$(normalize_arch "$(normalize_liberica_arch "${ARCH}" "${BITNESS}")")" \ + "${EXT}" \ + 'jdk' \ + "$(normalize_features "${BUNDLE_TYPE}" "${OS}")" \ + "${URL}" \ + "$(hash_file 'md5' "${ARCHIVE}" "${CHECKSUM_DIR}")" \ + "$(hash_file 'sha1' "${ARCHIVE}" "${CHECKSUM_DIR}")" \ + "$(hash_file 'sha256' "${ARCHIVE}" "${CHECKSUM_DIR}")" \ + "$(hash_file 'sha512' "${ARCHIVE}" "${CHECKSUM_DIR}")" \ + "$(file_size "${ARCHIVE}")" \ + "${FILENAME}" + )" + + echo "${json}" > "${METADATA_FILE}" + rm -f "${ARCHIVE}" +done + +jq -s -S . "${METADATA_DIR}"/*.json > "${METADATA_DIR}/all.json" diff --git a/bin/update.bash b/bin/update.bash index e44d22438e3..0fafebc1181 100755 --- a/bin/update.bash +++ b/bin/update.bash @@ -48,6 +48,7 @@ vendors=( "$(cmd 'zulu')" "$(cmd 'sapmachine')" "$(cmd 'liberica')" + "$(cmd 'liberica-nik')" "$(cmd 'dragonwell8')" "$(cmd 'dragonwell11')" "$(cmd 'dragonwell17')"