From bf8455e908411c8c8bdce8f3625b18f4a84e7f29 Mon Sep 17 00:00:00 2001 From: Ethan Dye Date: Sun, 5 Jan 2025 22:51:32 -0700 Subject: [PATCH] Fixup to make sure OH5 checks for Java 21 Signed-off-by: Ethan Dye --- .github/workflows/bats-action.yml | 13 ++---- .github/workflows/installation-action.yml | 15 ++----- build-image/first-boot.bash | 20 ++++++--- build-image/openhabian.conf | 4 +- functions/influxdb+grafana.bash | 4 +- functions/java-jre.bash | 53 ++++++++++++----------- functions/menu.bash | 8 ---- functions/nodejs-apps.bash | 6 +-- functions/nodejs-apps.bats | 2 +- functions/openhab.bash | 33 +++++++------- functions/openhabian.bash | 2 + functions/packages.bash | 8 ++-- functions/system.bash | 3 +- tests/Dockerfile.amd64-installation | 1 + tests/Dockerfile.rpi3-installation | 1 + tests/Dockerfile.rpi5-installation | 1 + tests/test.bash | 20 ++++++++- 17 files changed, 103 insertions(+), 91 deletions(-) diff --git a/.github/workflows/bats-action.yml b/.github/workflows/bats-action.yml index eeb50aa1a..1397f630a 100644 --- a/.github/workflows/bats-action.yml +++ b/.github/workflows/bats-action.yml @@ -38,11 +38,6 @@ jobs: bats-tests: runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - services: - registry: - image: registry:2 - ports: - - 5000:5000 strategy: matrix: @@ -76,14 +71,12 @@ jobs: context: . file: ./tests/Dockerfile.${{ matrix.platform }}-BATS builder: ${{ steps.buildx.outputs.name }} - tags: localhost:5000/openhabian/${{ matrix.platform }}-openhabian:latest + tags: openhabian/${{ matrix.platform }}-openhabian:latest platforms: ${{ matrix.buildx_platform }} - cache-from: type=gha - cache-to: type=gha,mode=max - push: true + load: true - name: BATS tests on ${{ matrix.platform }} platform run: | - docker run --rm --name "openhabian-${{ matrix.platform }}" --platform ${{ matrix.buildx_platform }} -d localhost:5000/openhabian/${{ matrix.platform }}-openhabian + docker run --rm --name "openhabian-${{ matrix.platform }}" --platform ${{ matrix.buildx_platform }} -d openhabian/${{ matrix.platform }}-openhabian docker exec -i "openhabian-${{ matrix.platform }}" bash -c 'bats --tap --recursive --filter "development-." .' docker exec -i "openhabian-${{ matrix.platform }}" bash -c 'bats --tap --recursive --filter "unit-." .' docker exec -i "openhabian-${{ matrix.platform }}" bash -c 'bats --tap --recursive --filter "installation-." .' diff --git a/.github/workflows/installation-action.yml b/.github/workflows/installation-action.yml index 9ff7af325..93c731d7d 100644 --- a/.github/workflows/installation-action.yml +++ b/.github/workflows/installation-action.yml @@ -32,11 +32,6 @@ jobs: installation-tests: runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - services: - registry: - image: registry:2 - ports: - - 5000:5000 strategy: matrix: @@ -76,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 QEMU if: ${{ matrix.qemu_platform != '' }} uses: docker/setup-qemu-action@v3.3.0 @@ -93,13 +88,11 @@ jobs: context: . file: ${{ matrix.dockerfile }} builder: ${{ steps.buildx.outputs.name }} - tags: localhost:5000/openhabian/${{ matrix.platform }}:latest - cache-from: type=gha - cache-to: type=gha,mode=max + tags: openhabian/${{ matrix.platform }}:latest platforms: ${{ matrix.buildx_platform }} - push: true + load: true - name: openHABian installation test with ${{ matrix.platform }} run: | - docker run --privileged --rm --platform ${{ matrix.buildx_platform }} --name "openhabian-${{ matrix.platform }}" -d localhost:5000/openhabian/${{ matrix.platform }} + docker run --privileged --rm --platform ${{ matrix.buildx_platform }} --name "openhabian-${{ matrix.platform }}" -d openhabian/${{ matrix.platform }} docker exec -i "openhabian-${{ matrix.platform }}" bash -c './build.bash local-test && /boot/first-boot.bash' shell: bash diff --git a/build-image/first-boot.bash b/build-image/first-boot.bash index 27d3754b5..74ae70ce8 100755 --- a/build-image/first-boot.bash +++ b/build-image/first-boot.bash @@ -42,7 +42,7 @@ if ! is_bookworm; then rfkill unblock wifi # Wi-Fi is blocked by Raspi OS default since bullseye(?) fi webserver=/boot/webserver.bash -ln -s /boot/firmware/webserver.bash "$webserver" +ln -sfn /boot/firmware/webserver.bash "$webserver" if [[ "${debugmode:-on}" == "on" ]]; then unset SILENT @@ -93,7 +93,7 @@ hotSpot=${hotspot:-enable} wifiSSID="$wifi_ssid" # shellcheck source=/etc/openhabian.conf disable=SC2154 wifiPassword="$wifi_password" -if is_bookworm; then +if ! running_in_docker && is_bookworm; then echo -n "$(timestamp) [openHABian] Setting up NetworkManager and Wi-Fi connection... " systemctl enable --now NetworkManager @@ -105,7 +105,7 @@ if is_bookworm; then #elif [[ -z $wifiSSID ]]; then elif grep -qs "up" /sys/class/net/eth0/operstate; then # Actually check if ethernet is working - echo -n "$(timestamp) [openHABian] Setting up Ethernet connection... OK" + echo "$(timestamp) [openHABian] Setting up Ethernet connection... OK" elif [[ -n $wifiSSID ]] && grep -qs "openHABian" /etc/wpa_supplicant/wpa_supplicant.conf && ! grep -qsE "^[[:space:]]*dtoverlay=(pi3-)?disable-wifi" /boot/config.txt; then echo -n "$(timestamp) [openHABian] Checking if WiFi is working... " if iwlist wlan0 scan |& grep -qs "Interface doesn't support scanning"; then @@ -219,7 +219,7 @@ fi # shellcheck disable=SC2154 echo -n "$(timestamp) [openHABian] Updating myself from ${repositoryurl:-https://github.com/openhab/openhabian.git}, ${clonebranch:-openHAB} branch... " -if [[ $(eval "$(openhabian_update "${clonebranch:-openHAB}" &> /dev/null)") -eq 0 ]]; then +if running_in_docker || [[ $(eval "$(openhabian_update "${clonebranch:-openHAB}" &> /dev/null)") -eq 0 ]]; then echo "OK" else echo "FAILED" @@ -254,7 +254,17 @@ if running_in_docker; then ps -auxq "$(cat "$PID")" | awk '/openhab/ {print "size/res="$5"/"$6" KB"}' else echo -e "\\n${COL_RED}Karaf PID missing, openHAB process not running (yet?).${COL_DEF}" - exit 1 + cat /var/log/openhab/openhab.log + systemctl restart openhab.service + systemctl status openhab.service + journalctl -xeu openhab.service + sleep 30 + if [[ -f "$PID" ]]; then + ps -auxq "$(cat "$PID")" | awk '/openhab/ {print "size/res="$5"/"$6" KB"}' + else + echo -e "\\n${COL_RED}Karaf PID still missing, openHAB process not running.${COL_DEF}" + exit 1 + fi fi echo -e "$COL_DEF" fi diff --git a/build-image/openhabian.conf b/build-image/openhabian.conf index 65720ab8a..d5566726e 100644 --- a/build-image/openhabian.conf +++ b/build-image/openhabian.conf @@ -52,7 +52,7 @@ clonebranch=openHAB # debug verbosity mode # off, on (verbose output in log) or maximum (show every command) -debugmode=off +debugmode=maximum # the framebuffer on RPi is enabled by default framebuffer=enable @@ -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 diff --git a/functions/influxdb+grafana.bash b/functions/influxdb+grafana.bash index 3fedd868d..22f2e5324 100644 --- a/functions/influxdb+grafana.bash +++ b/functions/influxdb+grafana.bash @@ -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 diff --git a/functions/java-jre.bash b/functions/java-jre.bash index b4cf387a1..d6814b832 100644 --- a/functions/java-jre.bash +++ b/functions/java-jre.bash @@ -2,7 +2,7 @@ ## Install Java version from dpkg repositories dynamically. ## This function is a wrapper for the OpenJDK and Adoptium Eclipse Temurin JDK install functions. -## Valid arguments: "11", "17", "Temurin17", "Temurin21" +## Valid arguments: "17", "21", "Temurin17", "Temurin21", 11 (legacy) ## ## java_install(String version) ## @@ -16,7 +16,7 @@ java_install() { rm -rf /opt/jdk fi if [[ $1 == Temurin* ]]; then - adoptium_fetch_apt "${1/Temurin/}" + adoptium_install_apt "${1/Temurin/}" else openjdk_install_apt "$1" fi @@ -31,18 +31,14 @@ java_install() { ## adoptium_fetch_apt() ## adoptium_fetch_apt() { - if ! apt-cache show "temurin-${1}-jre" &> /dev/null; then - local keyName="adoptium" - - if ! add_keys "https://packages.adoptium.net/artifactory/api/gpg/key/public" "$keyName"; then return 1; fi - cond_redirect apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 843C48A565F8F04B - - echo -n "$(timestamp) [openHABian] Adding Adoptium repository to apt... " - if ! echo "deb https://packages.adoptium.net/artifactory/deb ${osrelease:-bookworm} main" > /etc/apt/sources.list.d/adoptium.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 + local keyName="adoptium" echo -n "$(timestamp) [openHABian] Fetching Adoptium Eclipse Temurin JDK... " + if ! cond_redirect add_keys "https://packages.adoptium.net/artifactory/api/gpg/key/public" "$keyName"; then echo "FAILED (add keys)"; return 1; fi + echo "deb [signed-by=/usr/share/keyrings/${keyName}.gpg] https://packages.adoptium.net/artifactory/deb ${osrelease:-bookworm} main" > /etc/apt/sources.list.d/adoptium.list + + if ! cond_redirect apt-get update; then echo "FAILED (update apt lists)"; return 1; fi + if ! cond_redirect dpkg --configure -a; then echo "FAILED (dpkg)"; return 1; fi if cond_redirect apt-get install --download-only --yes "temurin-${1}-jre"; then echo "OK"; else echo "FAILED"; return 1; fi } @@ -56,7 +52,7 @@ adoptium_install_apt() { echo -n "$(timestamp) [openHABian] Installing Adoptium Eclipse Temurin JDK... " cond_redirect java_alternatives_reset if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" "temurin-${1}-jre"; then echo "OK"; else echo "FAILED"; return 1; fi - elif dpkg -s "temurin-${1}-jre" &> /dev/null; then + else echo -n "$(timestamp) [openHABian] Reconfiguring Adoptium Eclipse Temurin JDK... " cond_redirect java_alternatives_reset if cond_redirect dpkg-reconfigure "temurin-${1}-jre"; then echo "OK"; else echo "FAILED"; return 1; fi @@ -73,19 +69,22 @@ adoptium_install_apt() { ## openjdk_fetch_apt() ## openjdk_fetch_apt() { - if ! apt-cache show "openjdk-${1}-jre-headless" &> /dev/null; then - echo "deb http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.list.d/java.list - cond_redirect apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC - cond_redirect apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138 + local keyName="debian-bookworm" - # important to avoid release mixing: - # prevent RPi from using the Debian distro for normal Raspbian packages + echo -n "$(timestamp) [openHABian] Fetching OpenJDK ${1}... " + if [[ $1 == "21" ]]; then + if ! cond_redirect add_keys "https://ftp-master.debian.org/keys/archive-key-12.asc" "$keyName"; then echo "FAILED (add keys)"; return 1; fi # Add keys for older systems that need them + echo "deb [signed-by=/usr/share/keyrings/${keyName}.gpg] http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.list.d/java.list + # Avoid release mixing: prevent RPi from using the Debian distro for normal Raspbian packages echo -e "Package: *\\nPin: release a=unstable\\nPin-Priority: 90\\n" > /etc/apt/preferences.d/limit-unstable - fi + if ! cond_redirect apt-get update; then echo "FAILED (update apt lists)"; return 1; fi - dpkg --configure -a - echo -n "$(timestamp) [openHABian] Fetching OpenJDK ${1}... " - if cond_redirect apt-get install --download-only --yes "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED"; return 1; fi + if ! cond_redirect dpkg --configure -a; then echo "FAILED (dpkg)"; return 1; fi + if cond_redirect apt-get install --download-only --yes -t unstable "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED (download)"; return 1; fi + else + if ! cond_redirect dpkg --configure -a; then echo "FAILED (dpkg)"; return 1; fi + if cond_redirect apt-get install --download-only --yes "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED (download)"; return 1; fi + fi } ## Install OpenJDK using APT repository. @@ -97,8 +96,12 @@ openjdk_install_apt() { openjdk_fetch_apt "$1" echo -n "$(timestamp) [openHABian] Installing OpenJDK ${1}... " cond_redirect java_alternatives_reset - if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED"; return 1; fi - elif dpkg -s "openjdk-${1}-jre-headless" &> /dev/null; then + if [[ $1 == "21" ]]; then + if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" -t unstable "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED"; return 1; fi + else + if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED"; return 1; fi + fi + else echo -n "$(timestamp) [openHABian] Reconfiguring OpenJDK ${1}... " cond_redirect java_alternatives_reset if cond_redirect dpkg-reconfigure "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED"; return 1; fi diff --git a/functions/menu.bash b/functions/menu.bash index 19481c546..a0a6ef6df 100644 --- a/functions/menu.bash +++ b/functions/menu.bash @@ -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 \ @@ -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}" diff --git a/functions/nodejs-apps.bash b/functions/nodejs-apps.bash index 540d52bb8..f7d1e93f9 100644 --- a/functions/nodejs-apps.bash +++ b/functions/nodejs-apps.bash @@ -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)" diff --git a/functions/nodejs-apps.bats b/functions/nodejs-apps.bats index 05a63bcdc..544869dc4 100644 --- a/functions/nodejs-apps.bats +++ b/functions/nodejs-apps.bats @@ -28,7 +28,7 @@ teardown_file() { echo -e "# ${COL_GREEN}$(timestamp) [openHABian] Frontail service is running.${COL_DEF}" >&3 } -@test "disabled-zigbee2mqtt_install" { +@test "installation-zigbee2mqtt_install" { echo -e "# ${COL_CYAN}$(timestamp) [openHABian] Zigbee2MQTT installation starting...${COL_DEF}" >&3 run zigbee2mqtt_setup "install" 3>&- if [ "$status" -ne 0 ]; then echo "$output" >&3; fi diff --git a/functions/openhab.bash b/functions/openhab.bash index 056a4bb52..9cb49d1d1 100644 --- a/functions/openhab.bash +++ b/functions/openhab.bash @@ -95,17 +95,23 @@ 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}" - if dpkg --compare-versions "$installVersion" ge "5.0.0"; then - if [[ -n $INTERACTIVE ]]; then - if ! (whiptail --title "openHAB software change" --msgbox "openHAB 5 requires Java 21.\\n\\nPlease use menu option 45 to install Java 21." 20 80); then echo "CANCELED"; return 1; fi - else - echo "FAILED (openHAB 5 requires Java 21)" - return 1 - fi - fi else installVersion="${ohPkgName} ${ohPkgName}-addons" fi @@ -124,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)"; journalctl -xeu openhab.service; systemctl status openhab.service; return 1; fi openhab_misc create_systemd_dependencies @@ -133,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 diff --git a/functions/openhabian.bash b/functions/openhabian.bash index 5cf5477b8..db17c968b 100644 --- a/functions/openhabian.bash +++ b/functions/openhabian.bash @@ -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" diff --git a/functions/packages.bash b/functions/packages.bash index 1eb61cf22..e653688a0 100644 --- a/functions/packages.bash +++ b/functions/packages.bash @@ -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 @@ -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 @@ -922,5 +922,3 @@ install_esphomedashboard() { return fi } - - diff --git a/functions/system.bash b/functions/system.bash index 742ae91ae..d29ea6231 100644 --- a/functions/system.bash +++ b/functions/system.bash @@ -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 } @@ -69,7 +69,6 @@ needed_packages() { moreutils python3 python3-pip python3-wheel python3-setuptools sysstat \ fontconfig; \ then echo "OK"; else echo "FAILED"; return 1; fi - echo -n "$(timestamp) [openHABian] Installing additional Python packages... " if is_pi_wlan && [[ -z $PREOFFLINE ]]; then echo -n "$(timestamp) [openHABian] Installing python3 serial package... " if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" python3-smbus python3-serial; then echo "OK"; else echo "FAILED"; return 1; fi diff --git a/tests/Dockerfile.amd64-installation b/tests/Dockerfile.amd64-installation index 874aefcec..7bcf2337c 100644 --- a/tests/Dockerfile.amd64-installation +++ b/tests/Dockerfile.amd64-installation @@ -29,5 +29,6 @@ ENTRYPOINT ["./tests/entry.sh"] # Setup openHABian environment COPY . /opt/openhabian/ +COPY ./build-image/webserver.bash /boot/firmware/webserver.bash WORKDIR /opt/openhabian/ RUN install -m 755 ./tests/runlevel /sbin/runlevel diff --git a/tests/Dockerfile.rpi3-installation b/tests/Dockerfile.rpi3-installation index e3af99787..1b24b85d9 100644 --- a/tests/Dockerfile.rpi3-installation +++ b/tests/Dockerfile.rpi3-installation @@ -30,5 +30,6 @@ ENTRYPOINT ["./tests/entry.sh"] # Setup openHABian environment COPY . /opt/openhabian/ +COPY ./build-image/webserver.bash /boot/firmware/webserver.bash WORKDIR /opt/openhabian/ RUN install -m 755 ./tests/runlevel /sbin/runlevel diff --git a/tests/Dockerfile.rpi5-installation b/tests/Dockerfile.rpi5-installation index abe64ee97..950d8008f 100644 --- a/tests/Dockerfile.rpi5-installation +++ b/tests/Dockerfile.rpi5-installation @@ -29,5 +29,6 @@ ENTRYPOINT ["./tests/entry.sh"] # Setup openHABian environment COPY . /opt/openhabian/ +COPY ./build-image/webserver.bash /boot/firmware/webserver.bash WORKDIR /opt/openhabian/ RUN install -m 755 ./tests/runlevel /sbin/runlevel diff --git a/tests/test.bash b/tests/test.bash index f01b90ddd..6a96f0577 100755 --- a/tests/test.bash +++ b/tests/test.bash @@ -1,5 +1,4 @@ #!/usr/bin/env bash -set -e ## This function formats log messages ## @@ -19,6 +18,25 @@ if [[ $1 == "shellcheck" ]]; then shellcheck -x -s bash functions/*.bash shellcheck -x -s bash build-image/*.bash shellcheck -x -s bash build.bash tests/ci-setup.bash +elif [[ $1 == "docker-install" ]]; then + if [[ -n $2 ]]; then + saved_java_opt="$(ggrep -oP 'java_opt=\K.*' build-image/openhabian.conf)" + gsed -i 's|java_opt=.*$|java_opt='"${2}"'|' build-image/openhabian.conf + fi + if [[ -n $3 ]]; then + saved_debugmode="$(ggrep -oP 'debugmode=\K.*' build-image/openhabian.conf)" + gsed -i 's|debugmode=.*$|debugmode='"${3}"'|' build-image/openhabian.conf + fi + docker buildx build --tag openhabian/install-openhabian -f tests/Dockerfile.rpi5-installation --platform linux/arm64 . + docker run --privileged --rm --platform linux/arm64 --name openhabian -d openhabian/install-openhabian:latest + docker exec -i "openhabian" bash -c './build.bash local-test && /boot/first-boot.bash' + docker stop openhabian + if [[ -n $2 ]]; then + gsed -i 's|java_opt=.*$|java_opt='"${saved_java_opt}"'|' build-image/openhabian.conf + fi + if [[ -n $3 ]]; then + gsed -i 's|debugmode=.*$|debugmode='"${saved_debugmode}"'|' build-image/openhabian.conf + fi else echo_process "Please provide a valid test profile, \"shellcheck\". Exiting" exit 0