From a5a06de61f60fd11a1accadc6ff47650ad852a7c Mon Sep 17 00:00:00 2001 From: Holger Friedrich Date: Mon, 1 Apr 2024 22:54:52 +0200 Subject: [PATCH] add Zulu JDK 21 installation on 64bit Requires a native 64 bit image, running a 64 bit kernel with 32-bit OS is not sufficient. Signed-off-by: Holger Friedrich --- build.bash | 2 +- functions/java-jre.bash | 42 ++++++++++++++++++++++++++++++++--------- functions/menu.bash | 2 ++ 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/build.bash b/build.bash index bb86bee33..62e79548f 100755 --- a/build.bash +++ b/build.bash @@ -7,7 +7,7 @@ set -e #################################################################### usage() { - echo -e "Usage: $(basename "$0") [oldstable]" + echo -e "Usage: $(basename "$0") [oldstable|latest]" echo -e "\\nCurrently supported platforms: rpi, rpi64" } diff --git a/functions/java-jre.bash b/functions/java-jre.bash index aa4e5b02e..64ba639a4 100644 --- a/functions/java-jre.bash +++ b/functions/java-jre.bash @@ -86,18 +86,18 @@ java_install_or_update() { java_zulu_prerequisite "${cached_java_opt:-Zulu11-32}" java_zulu_install "${cached_java_opt:-Zulu11-32}" fi - if [[ $1 == "Zulu11-64" ]]; then + if [[ $1 == "Zulu11-64" ]] || [[ $1 == "Zulu21-64" ]]; then if is_aarch64 || is_x86_64 && [[ $(getconf LONG_BIT) == 64 ]]; then if is_x86_64; then java_zulu_enterprise_apt "$@" else - if cond_redirect java_zulu_update_available "Zulu11-64"; then - java_zulu_prerequisite "Zulu11-64" + if cond_redirect java_zulu_update_available "$1"; then + java_zulu_prerequisite "$1" if [[ $branch == "openHAB3" ]] && [[ -z $UNATTENDED ]]; then - java_zulu_stable "Zulu11-64" + java_zulu_stable "$1" else - java_zulu_fetch "Zulu11-64" - java_zulu_install "Zulu11-64" + java_zulu_fetch "$1" + java_zulu_install "$1" fi fi fi @@ -211,6 +211,8 @@ java_zulu_install() { echo -n "$(timestamp) [openHABian] Installing Java Zulu 11 32-Bit OpenJDK... " elif [[ $1 == "Zulu11-64" ]]; then echo -n "$(timestamp) [openHABian] Installing Java Zulu 11 64-Bit OpenJDK... " + elif [[ $1 == "Zulu21-64" ]]; then + echo -n "$(timestamp) [openHABian] Installing Java Zulu 21 64-Bit OpenJDK... " else echo "$(timestamp) [openHABian] Installing something that probably won't work... FAILED" return 1 @@ -264,6 +266,13 @@ java_zulu_fetch() { else downloadLink="$(curl "${link}&jdk_version=11&arch=x86&hw_bitness=64&bundle_type=jre" -s -L -I -o /dev/null -w '%{url_effective}')" fi + elif [[ $1 == "Zulu21-64" ]]; then + echo -n "$(timestamp) [openHABian] Downloading Java Zulu 21 64-Bit OpenJDK... " + if is_arm; then + downloadLink="$(curl "${link}&jdk_version=21&arch=arm&hw_bitness=64" -s -L -I -o /dev/null -w '%{url_effective}')" + else + downloadLink="$(curl "${link}&jdk_version=21&arch=x86&hw_bitness=64&bundle_type=jre" -s -L -I -o /dev/null -w '%{url_effective}')" + fi fi if [[ -z $downloadLink ]]; then echo "FAILED (download link)"; return 1; fi @@ -318,6 +327,14 @@ java_zulu_update_available() { requestedArch="x64" availableVersion="$(curl -s -H "Accept: application/json" "${link}&jdk_version=11&arch=x86&hw_bitness=64&bundle_type=jre" | jq -r "$filter")" fi + elif [[ $1 == "Zulu21-64" ]]; then + if is_arm; then + requestedArch="aarch64" + availableVersion="$(curl -s -H "Accept: application/json" "${link}&jdk_version=21&arch=arm&hw_bitness=64" | jq -r "$filter")" + else + requestedArch="x64" + availableVersion="$(curl -s -H "Accept: application/json" "${link}&jdk_version=21&arch=x86&hw_bitness=64&bundle_type=jre" | jq -r "$filter")" + fi fi if [[ -z $requestedArch ]] || [[ -z $availableVersion ]]; then echo "FAILED (java update available)"; return 1; fi @@ -348,9 +365,16 @@ java_zulu_enterprise_apt() { if openhab_is_running; then cond_redirect systemctl stop openhab.service fi - if ! dpkg -s 'zulu-11' &> /dev/null; then - echo -n "$(timestamp) [openHABian] Installing Zulu 11 Enterprise 64-Bit OpenJDK... " - if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" zulu-11; then echo "OK"; else echo "FAILED"; return 1; fi + if [[ $1 == "Zulu21-64" ]]; then + if ! dpkg -s 'zulu-21' &> /dev/null; then + echo -n "$(timestamp) [openHABian] Installing Zulu 21 Enterprise 64-Bit OpenJDK... " + if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" zulu21; then echo "OK"; else echo "FAILED"; return 1; fi + fi + else + if ! dpkg -s 'zulu-11' &> /dev/null; then + echo -n "$(timestamp) [openHABian] Installing Zulu 11 Enterprise 64-Bit OpenJDK... " + if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" zulu11; then echo "OK"; else echo "FAILED"; return 1; fi + fi fi if openhab_is_installed; then cond_redirect systemctl restart openhab.service diff --git a/functions/menu.bash b/functions/menu.bash index 006a8b83b..4aa1d70c4 100644 --- a/functions/menu.bash +++ b/functions/menu.bash @@ -219,6 +219,7 @@ show_main_menu() { " | OpenJDK 11" "Install and activate OpenJDK 11 as Java provider" \ " | Zulu 11 OpenJDK 32-bit" "Install Zulu 11 32-bit OpenJDK as Java provider" \ " | Zulu 11 OpenJDK 64-bit" "Install Zulu 11 64-bit OpenJDK as Java provider" \ + " | Zulu 21 OpenJDK 64-bit" "Install Zulu 21 64-bit OpenJDK (EXPERIMENTAL)" \ "46 | Install openhab-js" "JS Scripting: Upgrade to latest version of openHAB JavaScript library (advanced)" \ " | Uninstall openhab-js" "JS Scripting: Switch back to included version of openHAB JavaScript library" \ "47 | Install openhab_rules_tools" "JS Scripting: Manually install openhab_rules_tools (auto-installed)" \ @@ -239,6 +240,7 @@ show_main_menu() { *OpenJDK\ 17) update_config_java "17" && java_install "17";; *Zulu\ 11\ OpenJDK\ 32-bit) update_config_java "Zulu11-32" && java_install_or_update "Zulu11-32";; *Zulu\ 11\ OpenJDK\ 64-bit) update_config_java "Zulu11-64" && java_install_or_update "Zulu11-64";; + *Zulu\ 21\ OpenJDK\ 64-bit) update_config_java "Zulu21-64" && java_install_or_update "Zulu21-64";; 46\ *) jsscripting_npm_install "openhab";; *Uninstall\ openhab-js) jsscripting_npm_install "openhab" "uninstall";; 47\ *) jsscripting_npm_install "openhab_rules_tools";;