Skip to content

Instantly share code, notes, and snippets.

@stokito
Forked from simonswine/install-openjdk8-musl.sh
Last active August 21, 2023 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stokito/7dd425da5a12abce8b39dda1bd1106d7 to your computer and use it in GitHub Desktop.
Save stokito/7dd425da5a12abce8b39dda1bd1106d7 to your computer and use it in GitHub Desktop.
Install Java openjdk8 compiled for musl from Alpine onto OpenWRT (armv7). Tested on Turris Omnia (TurrisOS 6.4.1)
#!/bin/sh
# aarch64, armhf, armv7, ppc64le, s390x, x86, x86_64
ARCH="armv7" # Turris Omnia
REVISION="8.275.01-r0"
DESTDIR="" # empty for root, you can set to /opt
# Alpine v3.13 switched to musl v1.2.0 while TurrisOS 6.4.1 uses older musl v1.1.24
# Use ldd command to see a musl version.
# If it's newer then change the URL to https://dl-cdn.alpinelinux.org/alpine/edge/
# You will also need to change the REVISION for the latest
URL="https://dl-cdn.alpinelinux.org/alpine/v3.12/community/$ARCH"
PACKAGES="openjdk8 openjdk8-jre openjdk8-jre-lib openjdk8-jre-base"
for package in $PACKAGES; do
# download and extract on the fly
# apk files are just tar.gz with additional .PKGINFO and .SIGN.RSA files
wget -q -O - "${URL}/${package}-${REVISION}.apk" | tar -xz -C "$DESTDIR" --exclude=.PKGINFO --exclude=.SIGN*
done
export PATH="$PATH:$DESTDIR/usr/lib/jvm/java-8-openjdk/bin"
echo "export PATH=\"$PATH:$DESTDIR/usr/lib/jvm/java-8-openjdk/bin\"" >> /etc/profile
@stokito
Copy link
Author

stokito commented Aug 16, 2023

You may also need to install packages:

  • libstdcpp is required
  • libjpeg-turbo may be not needed, but I have it anyway
  • libnss I don't have it but the java works. It only become needed when using TLS.
  • liblcms I don't have it but the java works.

The liblcms is absent in OpenWrt repo and needs to be installed similarly from Alpine.

wget -q -O - "https://dl-cdn.alpinelinux.org/alpine/v3.12/community/armv7/liblcms-1.19-r8.apk" | tar -xz -C / --exclude=.PKGINFO --exclude=.SIGN*

The Alpine openjdk also depends on java-cacerts package which is an updater of java certs from ca-bundle. We may need something similar or port it into OpenWrt. Currently the TLS CA certs in the default keystore are outdated and basically you can't make a HTTPS call to any external service. I didn't checked if you can serve TLS but it shouldn't be a problem as far I understood.

There may be other libraries needed https://git.alpinelinux.org/aports/tree/community/openjdk8/APKBUILD?h=3.12-stable#n17

Links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment