diff --git a/README.md b/README.md index 51737e429..cd7c2cb33 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Choose yours based on your hardware and primary use case. Please be aware that y Use the 64 bit image versions but please be aware that 64 bit always has one major drawback: increased memory usage. That is not a good idea on heavily memory constrained platforms like Raspberries. If you want to go with 64 bit, ensure your RPi has a minimum of 2 GB, 4 will put you on the safe side. You can use the 32 bit version for older or non official addons that will not work on 64 bit yet. Note there's a known issue on 32 bit, JS rules are reported to be annoyingly slow on first startup and in some Blockly use cases. -If you consider using the (newer but still experimental) Java version 21, choose 64 bit. Java 21 is not available for 32 bit systems. +If you consider using the (newer but still experimental) Java version 21, if possible choose 64 bit. On x86 hardware, it's all 64 bit but that in turn once more increases memory usage. A NUC to run on should have no less than 8 GB. diff --git a/functions/java-jre.bash b/functions/java-jre.bash index 9f4d7fe30..a925047ec 100644 --- a/functions/java-jre.bash +++ b/functions/java-jre.bash @@ -64,6 +64,43 @@ openjdk_install_apt() { fi } +## Fetch BellSoft Liberica JDK using APT repository. +## +## liberica_fetch_apt() +## +liberica_fetch_apt() { + local pkgname="bellsoft-java21-lite" + if ! apt-cache show $pkgname &> /dev/null; then + local keyName="bellsoft_liberica" + + if ! add_keys "https://download.bell-sw.com/pki/GPG-KEY-bellsoft" "$keyName"; then return 1; fi + + echo -n "$(timestamp) [openHABian] Adding BellSoft repository to apt... " + + # architectures available: amd64, i386, arm64, armhf; those could be added to the repo string via [arch=...] + if ! echo "deb [signed-by=/usr/share/keyrings/${keyName}.gpg] https://apt.bell-sw.com/ stable main" > /etc/apt/sources.list.d/bellsoft.list; then echo "FAILED"; return 1; fi + if cond_redirect apt-get update; then echo "OK"; else echo "FAILED (update apt lists)"; return 1; fi + fi +} + +## Install BellSoft Liberica JDK using APT repository. +## +## liberica_install_apt() +## +liberica_install_apt() { + local pkgname="bellsoft-java21-lite" + if ! dpkg -s $pkgname &> /dev/null; then # Check if already is installed + liberica_fetch_apt + echo -n "$(timestamp) [openHABian] Installing BellSoft Liberica JDK... " + if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" $pkgname; then echo "OK"; else echo "FAILED"; return 1; fi + elif dpkg -s $pkgname &> /dev/null; then + echo -n "$(timestamp) [openHABian] Reconfiguring BellSoft Liberica JDK... " + if cond_redirect dpkg-reconfigure $pkgname; then echo "OK"; else echo "FAILED"; return 1; fi + # shellcheck disable=SC2012 + update-alternatives --set java "$(ls -d /usr/lib/jvm/bellsoft-java21-lite-* | head -n1)"/bin/java + fi +} + # LEGACY SECTION ## Install appropriate Java version based on current choice. @@ -117,6 +154,8 @@ java_install_or_update() { fi fi fi + elif [[ $1 == "BellSoft21" ]]; then + liberica_install_apt else # Default to 32-bit installation if cond_redirect java_zulu_update_available "Zulu11-32"; then java_zulu_prerequisite "Zulu11-32" diff --git a/functions/menu.bash b/functions/menu.bash index bde9cf781..c616a2a9d 100644 --- a/functions/menu.bash +++ b/functions/menu.bash @@ -216,7 +216,8 @@ 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)" \ + " | Zulu 21 OpenJDK 64-bit" "Install Zulu 21 64-bit OpenJDK as Java provider" \ + " | BellSoft Liberica JDK 21" "Install BellSoft Liberica JDK 21, supports 32bit RPi (EXPERIMENTAL)" \ "47 | 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" \ "48 | Install openhab_rules_tools" "JS Scripting: Manually install openhab_rules_tools (auto-installed)" \ @@ -239,6 +240,7 @@ show_main_menu() { *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";; + *BellSoft\ Liberica\ JDK\ 21) update_config_java "BellSoft21" && java_install_or_update "BellSoft21";; 47\ *) jsscripting_npm_install "openhab";; *Uninstall\ openhab-js) jsscripting_npm_install "openhab" "uninstall";; 48\ *) jsscripting_npm_install "openhab_rules_tools";;