Skip to content

Commit

Permalink
add Zulu JDK 21 installation on 64bit (#1861)
Browse files Browse the repository at this point in the history
Requires a native 64 bit image, running a 64 bit kernel with 32-bit OS is not sufficient.

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
  • Loading branch information
holgerfriedrich committed Apr 5, 2024
1 parent 5e76108 commit b6a3217
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e
####################################################################

usage() {
echo -e "Usage: $(basename "$0") <platform> [oldstable]"
echo -e "Usage: $(basename "$0") <platform> [oldstable|latest]"
echo -e "\\nCurrently supported platforms: rpi, rpi64"
}

Expand Down
42 changes: 33 additions & 9 deletions functions/java-jre.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions functions/menu.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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)" \
Expand All @@ -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";;
Expand Down

0 comments on commit b6a3217

Please sign in to comment.