Skip to content

Commit

Permalink
Use Zulu API v1 when upgrading Java (openhab#848)
Browse files Browse the repository at this point in the history
* Use Zulu API v1 when upgrading Java

Additionally, to clarify what Java version this will install, when
available, the API will prefer downloading a JRE. However, when a JRE is
not available it will use a JDK instead. However, when JDK's are
installed only the essential binaries are linked to update-alternatives
so extra JDK related software is unlinked (i.e. javac).

At the moment, Azul appears to only provide JDK builds for ARM platforms
and so, as such, ARM platforms are most often the ones to not get a JRE
installed and the resulting installation tends to be a bit larger (~100
MB).

One minor inconvenience is that with the current Azul API it does not
allow explicitly choosing builds without the JavaFX additional binaries.
So at times, the Java version installed will have extra JavaFX binaries.
This is usually seen when the architecture being installed is x86 based.

Fixes openhab#714
Fixes openhab#723
See Also openhab#629

Signed-off-by: Ethan Dye <[email protected]>

* Refuse to install 64-bit JDK on 32-bit OS

armv8 builds in theory should work on the RPi3+/RPi4, however the
current Raspbian kernel uses a armv7l base which works because armv8 is
backwards compatible. However, this has the effect of making the builds
targeting aarch64 provided by Azul unable to work on the RPi3+/RPi4. On
the other hand, this is not a huge issue as the use of 64-bit Java on
low-memory boards brings few benefits and mostly issues.

Additionally, this adds checking for other platforms to ensure that the
OS is actually 64-bit before trying to install a 64-bit JDK. If the OS
is not actually 64-bit the installer defaults to installing a 32-bit
JDK.

Signed-off-by: Ethan Dye <[email protected]>
Signed-off-by: Markus Storm <[email protected]>
  • Loading branch information
ecdye authored and mstormi committed Jun 10, 2020
1 parent 97461b6 commit e1e41a7
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 110 deletions.
50 changes: 28 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ jobs:
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-x86 .
- echo -e "\n\e[36mopenHABian test installation 64bit Azul Enterprise Java on virtual $HW ...\n"
- docker run --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
docker exec -i "openhabian-${HW}" bash -c './build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: arm32hf
arch: arm64
script:
Expand All @@ -73,8 +72,7 @@ jobs:
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-ARMv6hf-native .
- echo -e "\n\e[36mopenHABian test installation 32bit Azul Embedded Java on virtual $HW ...\n"
- docker run --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
docker exec -i "openhabian-${HW}" bash -c './build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: arm32hf
arch: arm64
script:
Expand All @@ -84,31 +82,41 @@ jobs:
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-arm32hf-native .
- echo -e "\n\e[36mopenHABian test installation 32bit Azul Embedded Java on virtual $HW ...\n"
- docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian
- docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: aarch64
- docker exec -i "openhabian-${HW}" bash -c './build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: arm32hf
arch: arm64
script:
# 64bit Azul Java on 64bit ARMv8 (RPi3, CM3) on 32bit OS on Travis Arm64 HW -- supposed to fail !
# 32bit Azul Java on 64bit ARMv8 (CM3, RPi3) on 32bit OS on Travis Arm64 HW
- export HW=cm3
- sed -i 's/java_arch=64-bit$/java_arch=32-bit/' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-arm32hf-CM3 .
- echo -e "\n\e[36mopenHABian test installation 32bit Azul Embedded Java on virtual $HW ...\n"
- docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
- docker exec -i "openhabian-${HW}" bash -c './build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: arm32hf
arch: arm64
script:
# 64bit Azul Java on 32bit ARMv8 (RPi3, CM3) on 32bit OS on Travis Arm64 HW
# This is known to not work - openHABian is supposed to downgrade to 32bit on install.
- export HW=rpi3
- sed -i 's/java_arch=32-bit$/java_arch=64-bit/' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-aarch64-native .
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-arm32hf-native .
- echo -e "\n\e[36mopenHABian test installation 64bit Azul Embedded Java on virtual $HW ..."
- echo -e "\e[31m ** This is known to not work. openHABian is supposed to force install down to 32bit **\n"
- docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
- docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: arm32hf
- docker exec -i "openhabian-${HW}" bash -c './build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: aarch64
arch: arm64
script:
# 32bit Azul Java on 64bit ARMv8 (CM3, RPi3) on 32bit OS on Travis Arm64 HW
- export HW=cm3
- sed -i 's/java_arch=64-bit$/java_arch=32-bit/' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-arm32hf-CM3 .
- echo -e "\n\e[36mopenHABian test installation 32bit Azul Embedded Java on virtual $HW ...\n"
# 64bit Azul Java on 64bit ARMv8 (RPi3,4) on 32bit OS on Travis Arm64 HW
# This is known to not work - openHABian is supposed to downgrade to 32bit on install.
- export HW=rpi3
- sed -i 's/java_arch=32-bit$/java_arch=64-bit/' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-aarch64-native .
- echo -e "\n\e[36mopenHABian test installation 64bit Azul Embedded Java on virtual $HW ..."
- echo -e "\e[31m ** This is known to not work. openHABian is supposed to force install down to 32bit **\n"
- docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
- docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- docker exec -i "openhabian-${HW}" bash -c './build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: aarch64
arch: arm64
script:
Expand All @@ -118,6 +126,4 @@ jobs:
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-aarch64-64bit .
- echo -e "\n\e[36mopenHABian test installation 64bit Azul Embedded Java \e[31m on 64bit OS\e[36m on virtual $HW ...\n"
- docker run --memory="2G" --memory-reservation="2G" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'

docker exec -i "openhabian-${HW}" bash -c './build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
5 changes: 2 additions & 3 deletions Dockerfile.openhabian-arm32hf-native
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# assumes at least ARMv71 but not ARMv8 (aarch64) yet
FROM balenalib/raspberry-pi2-debian-node:latest-buster

ENV container docker
ENV INITSYSTEM on
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
Expand Down Expand Up @@ -37,7 +37,7 @@ RUN cp docker-systemctl-replacement/files/docker/systemctl.py /bin/systemctl
ENTRYPOINT ["/usr/bin/entry.sh"]

RUN adduser openhabian --gecos "Openhabian,,," --disabled-password
RUN echo "openhabian:openhabian" | chpasswd
RUN echo "openhabian:openhabian" | chpasswd
RUN /bin/echo -n "Running on " && /usr/bin/arch

COPY . /opt/openhabian/
Expand All @@ -50,4 +50,3 @@ VOLUME ["/sys/fs/cgroup"]
STOPSIGNAL 37

CMD ["bash", "start.sh"]

13 changes: 12 additions & 1 deletion functions/config.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ clean_config_userpw() {
## Update java architecture in config file
## Valid options: "32-bit" & "64-bit"
update_config_java() {
cond_redirect grep -q '^java_arch' "$CONFIGFILE" && sed -i "s/^java_arch.*/java_arch=$1/" "$CONFIGFILE" || echo "java_arch=$1" >> "$CONFIGFILE"
if [ "$1" == "64-bit" ]; then
if (! is_x86_64 && ! [ "$(getconf LONG_BIT)" == "64" ]) || (! is_aarch64 && ! [ "$(getconf LONG_BIT)" == "64" ]); then
if [ -n "$INTERACTIVE" ]; then
whiptail --title "Incompatible hardware detected" --msgbox "Zulu OpenJDK 64-bit: this option does not currently work on your platform.\\n\\nDefaulting to 32-bit installation." 10 60
else
echo "Zulu OpenJDK 64-bit: this option does not currently work on your platform. Defaulting to 32-bit installation."
fi
cond_redirect grep -q '^java_arch' "$CONFIGFILE" && sed -i "s/^java_arch.*/java_arch=32-bit/" "$CONFIGFILE" || echo "java_arch=32-bit" >> "$CONFIGFILE"
fi
else
cond_redirect grep -q '^java_arch' "$CONFIGFILE" && sed -i "s/^java_arch.*/java_arch=$1/" "$CONFIGFILE" || echo "java_arch=$1" >> "$CONFIGFILE"
fi
# shellcheck disable=SC1090
source "$CONFIGFILE"
}
Loading

0 comments on commit e1e41a7

Please sign in to comment.