Skip to content

Commit

Permalink
Add official support for Java 21 (#1940)
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye authored Feb 3, 2025
1 parent 9858a95 commit 6f5beda
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 461 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bats-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
name: ${{ matrix.platform }} BATS
runs-on: ${{ matrix.runner }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name

strategy:
matrix:
include:
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/installation-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@ jobs:
runner: ubuntu-24.04
buildx_platform: linux/amd64
java_opt: 17
- platform: rpi3-bellsoft21
dockerfile: ./tests/Dockerfile.rpi3-installation
- platform: rpi5-openjdk21
dockerfile: ./tests/Dockerfile.rpi5-installation
runner: ubuntu-24.04-arm
buildx_platform: linux/arm/v7
java_opt: BellSoft21
buildx_platform: linux/arm64
java_opt: 21
continue-on-error: true # Experimental currently
- platform: rpi5-temurin21
dockerfile: ./tests/Dockerfile.rpi5-installation
runner: ubuntu-24.04-arm
buildx_platform: linux/arm64
java_opt: Temurin21
continue-on-error: true # Experimental currently

steps:
Expand All @@ -65,7 +71,7 @@ jobs:
- name: Setup environment
run: |
sudo -E ./tests/ci-setup.bash github
sed -i 's|^java_opt=.*$|java_opt=${{ matrix.java_opt }}|' build-image/openhabian.conf
sed -i 's|^java_opt=.*$|java_opt='"${{ matrix.java_opt }}"'|' build-image/openhabian.conf
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion build-image/openhabian.conf
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ apttimeout=60
# osrelease=

# Java version to install
# Valid arguments: 11, 17, Zulu11-32, Zulu11-64, Zulu21-64
# Valid arguments: 17, 21, Temurin17, Temurin21, 11 (legacy)
java_opt=17

# install zram per default, set to "disable" to skip installation
Expand Down
4 changes: 2 additions & 2 deletions functions/influxdb+grafana.bash
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ influxdb_install() {
else
myOS="$(lsb_release -si)"
fi
myRelease="$(lsb_release -sc)"
if [[ "$myRelease" == "n/a" ]]; then
myRelease="$(lsb_release -sc | head -1)"
if [[ "$myRelease" == "n/a" ]] || running_in_docker; then
myRelease=${osrelease:-bookworm}
fi

Expand Down
475 changes: 62 additions & 413 deletions functions/java-jre.bash

Large diffs are not rendered by default.

24 changes: 20 additions & 4 deletions functions/java-jre.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,26 @@ load helpers.bash
echo -e "# ${COL_GREEN}$(timestamp) [openHABian] OpenJDK 17 Java installation successful.${COL_DEF}" >&3
}

@test "installation-java_install_zulujdk21" {
echo -e "# ${COL_CYAN}$(timestamp) [openHABian] Azul Zulu JDK 21 Java is being (test-)installed...${COL_DEF}" >&3
run java_install_or_update "Zulu21-64" 3>&-
@test "installation-java_install_openjdk21" {
echo -e "# ${COL_CYAN}$(timestamp) [openHABian] OpenJDK 21 Java is being (test-)installed...${COL_DEF}" >&3
run java_install "21" 3>&-
if [ "$status" -ne 0 ]; then echo "$output" >&3; fi
[ "$status" -eq 0 ]
echo -e "# ${COL_GREEN}$(timestamp) [openHABian] Azul Zulu JDK 21 Java installation successful.${COL_DEF}" >&3
echo -e "# ${COL_GREEN}$(timestamp) [openHABian] OpenJDK 21 Java installation successful.${COL_DEF}" >&3
}

@test "installation-java_install_temurin17" {
echo -e "# ${COL_CYAN}$(timestamp) [openHABian] Temurin 17 Java is being (test-)installed...${COL_DEF}" >&3
run java_install "Temurin17" 3>&-
if [ "$status" -ne 0 ]; then echo "$output" >&3; fi
[ "$status" -eq 0 ]
echo -e "# ${COL_GREEN}$(timestamp) [openHABian] Temurin 17 Java installation successful.${COL_DEF}" >&3
}

@test "installation-java_install_temurin21" {
echo -e "# ${COL_CYAN}$(timestamp) [openHABian] Temurin 21 Java is being (test-)installed...${COL_DEF}" >&3
run java_install "Temurin21" 3>&-
if [ "$status" -ne 0 ]; then echo "$output" >&3; fi
[ "$status" -eq 0 ]
echo -e "# ${COL_GREEN}$(timestamp) [openHABian] Temurin 21 Java installation successful.${COL_DEF}" >&3
}
26 changes: 8 additions & 18 deletions functions/menu.bash
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Menu 50 provides options to backup and restore either your openHAB configuration
show_main_menu() {
local choice
local version
local javaVersion


choice=$(whiptail --title "openHABian Configuration Tool — $(get_git_revision)" --menu "Setup Options" 24 118 16 --cancel-button Exit --ok-button Execute \
Expand Down Expand Up @@ -74,13 +73,6 @@ show_main_menu() {
return 255
fi

javaVersion="$(java -version |& grep -m 1 -o "[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}[\.+][0-9]\{0,3\}" | head -1|cut -d '.' -f1)"
if [[ $(apt-cache madison openhab | head -n 1 | awk '{ print $3 }' | cut -d'.' -f1) = 4 ]]; then
if [[ $javaVersion -lt 17 ]] ; then
update_config_java "17"
java_install "17"
fi
fi
repo=$(apt-cache madison openhab | head -n 1 | awk '{ print $6 }' |cut -d'/' -f1)
# shellcheck disable=SC2154
openhab_setup "${repo:-release}" "${openhabpkgversion}"
Expand Down Expand Up @@ -219,12 +211,11 @@ show_main_menu() {
"42 | Remote Console" "Bind the openHAB SSH console to all external interfaces" \
"43 | Clean cache" "Clean the cache for openHAB" \
"44 | Nginx Proxy" "Setup reverse and forward web proxy" \
"45 | OpenJDK 17" "Install and activate OpenJDK 17 as Java provider (now default)" \
" | 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 as Java provider" \
" | BellSoft Liberica JDK 21" "Install BellSoft Liberica JDK 21, supports 32bit RPi (EXPERIMENTAL)" \
"45 | OpenJDK 17" "Install and activate OpenJDK 17 as Java provider (default)" \
" | OpenJDK 21" "Install and activate OpenJDK 21 as Java provider (upcoming default)" \
" | Temurin 17" "Install and activate Temurin 17 as Java provider (default alternative)" \
" | Temurin 21" "Install and activate Temurin 21 as Java provider (upcoming alternative default)" \
" | OpenJDK 11" "Install and activate OpenJDK 11 as Java provider (legacy)" \
"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 @@ -243,11 +234,10 @@ show_main_menu() {
43\ *) openhab_clean_cache;;
44\ *) nginx_setup;;
*OpenJDK\ 17) update_config_java "17" && java_install "17";;
*OpenJDK\ 21) update_config_java "21" && java_install "21";;
*Temurin\ 17) update_config_java "Temurin17" && java_install "Temurin17";;
*Temurin\ 21) update_config_java "Temurin21" && java_install "Temurin21";;
*OpenJDK\ 11) update_config_java "11" && java_install "11";;
*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";;
46\ *) jsscripting_npm_install "openhab";;
*Uninstall\ openhab-js) jsscripting_npm_install "openhab" "uninstall";;
47\ *) jsscripting_npm_install "openhab_rules_tools";;
Expand Down
6 changes: 3 additions & 3 deletions functions/nodejs-apps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ nodejs_setup() {
local temp


myDistro="$(lsb_release -sc)"
if [[ "$myDistro" == "n/a" ]]; then
myDistro=${osrelease:-bullseye}
myDistro="$(lsb_release -sc | head -1)"
if [[ "$myDistro" == "n/a" ]] || running_in_docker; then
myDistro=${osrelease:-bookworm}
fi
temp="$(mktemp "${TMPDIR:-/tmp}"/openhabian.XXXXX)"

Expand Down
27 changes: 18 additions & 9 deletions functions/openhab.bash
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ openhab_setup() {
repo="deb [signed-by=/usr/share/keyrings/${keyName}.gpg] https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable main"
echo -n "$(timestamp) [openHABian] Beginning install of latest $ohPkgName release (stable repo)... "
elif [[ $1 == "milestone" || $1 == "testing" ]]; then
introText="You are about to install or change to the latest milestone $ohPkgName build. Note this is openHAB 4!\\n\\nMilestones contain the latest features and is supposed to run stable, but if you experience bugs or incompatibilities, please help with enhancing openHAB by posting them on the community forum or by raising a GitHub issue in the proper place.\\n\\nPlease be aware that downgrading from a newer build is not supported!\\n\\nPlease consult with the documentation or community forum and be sure to take a full openHAB configuration backup first!"
introText="You are about to install or change to the latest milestone $ohPkgName build. Note this is openHAB 5!\\n\\nMilestones contain the latest features and is supposed to run stable, but if you experience bugs or incompatibilities, please help with enhancing openHAB by posting them on the community forum or by raising a GitHub issue in the proper place.\\n\\nPlease be aware that downgrading from a newer build is not supported!\\n\\nPlease consult with the documentation or community forum and be sure to take a full openHAB configuration backup first!"
successText="The testing release of $ohPkgName is now installed on your system.\\n\\nPlease test the correct behavior of your setup. You might need to adapt your configuration, if available. If you made changes to the files in '/var/lib/${ohPkgName}' they were replaced, but you can restore them from backup files next to the originals.\\n\\nCheck the \"openHAB Release Notes\" and the official announcements to learn about additons, fixes and changes."
repo="deb [signed-by=/usr/share/keyrings/${keyName}.gpg] https://openhab.jfrog.io/artifactory/openhab-linuxpkg testing main"
echo -n "$(timestamp) [openHABian] Beginning install of latest $ohPkgName milestone build (testing repo)... "
Expand Down Expand Up @@ -95,7 +95,21 @@ openhab_setup() {
echo -n "$(timestamp) [openHABian] Installing openHAB... "
if ! apt-get clean --yes -o DPkg::Lock::Timeout="$APTTIMEOUT"; then echo "FAILED (apt cache clean)"; return 1; fi
cond_redirect apt-get update -o DPkg::Lock::Timeout="$APTTIMEOUT"
openhabVersion="${2:-$(apt-cache madison ${ohPkgName} | head -n 1 | cut -d'|' -f2 | xargs)}"
openhabVersion="${2:-$(apt-cache madison ${ohPkgName} | head -n 1 | awk '{ print $3 }')}"
openhabMajorVersion="$(echo "$openhabVersion" | cut -d'.' -f1)"
javaVersion="$(java -version |& head -1 | awk -F'"' '{ print $2 }' | cut -d '.' -f1)"
if [[ $openhabMajorVersion = 4 ]]; then
if [[ $javaVersion -lt 17 ]] ; then
update_config_java "17"
java_install "17"
fi
elif [[ $openhabMajorVersion = 5 ]]; then
if [[ $javaVersion -lt 21 ]] ; then
update_config_java "21"
java_install "21"
fi
fi

if [[ -n $openhabVersion ]]; then
installVersion="${ohPkgName}=${openhabVersion} ${ohPkgName}-addons=${openhabVersion}"
else
Expand All @@ -116,7 +130,8 @@ openhab_setup() {

echo -n "$(timestamp) [openHABian] Setting up openHAB service... "
if ! cond_redirect zram_dependency install ${ohPkgName}; then return 1; fi
if cond_redirect systemctl enable ${ohPkgName}.service; then echo "OK"; else echo "FAILED (enable service)"; return 1; fi
if ! cond_redirect systemctl -q daemon-reload; then echo "FAILED (reload)"; return 1; fi
if cond_redirect systemctl enable --now ${ohPkgName}.service; then echo "OK"; else echo "FAILED (enable service)"; return 1; fi

openhab_misc
create_systemd_dependencies
Expand All @@ -125,12 +140,6 @@ openhab_setup() {
fi
dashboard_add_tile "openhabiandocs"

# see https://github.com/openhab/openhab-core/issues/1937
echo -n "$(timestamp) [openHABian] Restarting openHAB service the hard way to play it safe... "
if cond_redirect systemctl restart ${ohPkgName}.service; then echo "OK"; else echo "FAILED (restart service)"; return 1; fi
sleep 60
pkill -9 java

if [[ -n $INTERACTIVE ]]; then
unset DEBIAN_FRONTEND
whiptail --title "Operation successful!" --msgbox "$successText" 15 80
Expand Down
2 changes: 2 additions & 0 deletions functions/openhabian.bash
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ system_check_default_password() {
## config_ipv6()
##
config_ipv6() {
if running_in_docker; then echo "$(timestamp) [openHABian] Making sure router advertisements are available... SKIPPED"; return 0; fi

local aptConf="/etc/apt/apt.conf.d/S90force-ipv4"
local sysctlConf="/etc/sysctl.d/99-sysctl.conf"

Expand Down
8 changes: 3 additions & 5 deletions functions/packages.bash
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,8 @@ deconz_setup() {
if ! add_keys "http://phoscon.de/apt/deconz.pub.key" "$keyName"; then return 1; fi

myOS="$(lsb_release -si)"
myRelease="$(lsb_release -sc)"
if [[ "$myRelease" == "n/a" ]]; then
myRelease="$(lsb_release -sc | head -1)"
if [[ "$myRelease" == "n/a" ]] || running_in_docker; then
myRelease=${osrelease:-bookworm}
fi

Expand Down Expand Up @@ -856,7 +856,7 @@ install_esphomedashboard() {
return
fi

if [[ $1 == "install" ]]; then
if [[ $1 == "install" ]]; then
if [[ -n $INTERACTIVE ]]; then
whiptail --title "ESPhome dashboard installation" --msgbox "$installText" 8 80
fi
Expand Down Expand Up @@ -922,5 +922,3 @@ install_esphomedashboard() {
return
fi
}


2 changes: 1 addition & 1 deletion functions/system.bash
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ system_upgrade() {
# bad packages may require interactive input despite of this setting so do not mask output (no cond_redirect)
if ! apt-get upgrade --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"; then echo "FAILED"; return 1; fi
if ! cond_redirect java -version &> /dev/null; then
update_config_java "11" && java_install "11"
update_config_java "17" && java_install "17"
fi
unset DEBIAN_FRONTEND
}
Expand Down

0 comments on commit 6f5beda

Please sign in to comment.