Skip to content

Commit c48b31b

Browse files
authored
Merge pull request #19 from ev3dev-lang-java/java10_others
Add support for OpenJDK 10 on Raspberry Pi based platforms
2 parents f9deac5 + 0c4ac93 commit c48b31b

2 files changed

Lines changed: 29 additions & 13 deletions

File tree

modules/java.sh

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/bash
22

33

4-
function java_install_bundle(){
4+
function java_install_bundle() {
55
if [ -d "$JAVA_PATH_NEW" ]; then
66
echo "Sorry, we detected a previous installation in path: /opt/jri-10-build-050"
77
echo
88
exit 1
99
fi
10-
10+
1111
if [ ! -f "$JAVA_ZIP" ]; then
1212
echo "Downloading new Java..."
1313
wget "$JAVA_URL" -O "$JAVA_ZIP"
@@ -20,21 +20,37 @@ function java_install_bundle(){
2020
tar -xf "$JAVA_ZIP" -C "$JAVA_OPT"
2121
mv "$JAVA_PATH_ZIP" "$JAVA_PATH_NEW"
2222
update-alternatives --install /usr/bin/java java "$JAVA_EXE" 1
23-
23+
2424
JAVA_REAL_EXE="$JAVA_EXE"
2525
}
2626

27-
#TODO Upgrade this function with the support of OpenJDK 10
2827
function java_install_ppa() {
29-
echo "$WEBUPD8_REPO" | sudo tee -a /etc/apt/sources.list
30-
apt-key adv --recv-key --keyserver keyserver.ubuntu.com "$WEBUPD8_KEY"
28+
###
29+
# Add Debian Buster repo to Stretch
30+
31+
# prevent distro upgrade
32+
cat >/etc/apt/preferences.d/jdk <<EOF
33+
Package: *
34+
Pin: release a=stable
35+
Pin-Priority: 200
36+
37+
Package: *
38+
Pin: release a=testing
39+
Pin-Priority: 100
40+
EOF
41+
# workaround for cyclic dependency
42+
ln -sf "$JDEB_TMP_LINK" "/usr/bin/java"
43+
44+
# add repo, update
45+
echo "$JDEB_REPO" | sudo tee "/etc/apt/sources.list.d/jdk.list"
3146
apt-get update
32-
apt-get install --yes --no-install-recommends "$WEBUPD8_PKG"
3347

34-
JAVA_REAL_EXE="$(which java)"
48+
# install package
49+
# (the symlink above gets discarded, but
50+
# it is needed during the installation)
51+
apt-get install --yes --no-install-recommends "$JDEB_PKG"
3552

36-
#Review in the future how to accept licence automatically
37-
#https://askubuntu.com/questions/190582/installing-java-automatically-with-silent-option
53+
JAVA_REAL_EXE="$(which java)"
3854
}
3955

4056
#1. Detect Java

modules/vars.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ JAVA_EXE="$JAVA_PATH_NEW/bin/java"
1010

1111

1212
# brickpi java repository
13-
WEBUPD8_KEY="C2518248EEA14886"
14-
WEBUPD8_REPO="deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main"
15-
WEBUPD8_PKG="oracle-java8-installer"
13+
JDEB_REPO="deb http://ftp.debian.org/debian buster main contrib non-free"
14+
JDEB_PKG="openjdk-10-jre-headless"
15+
JDEB_TMP_LINK="/usr/lib/jvm/java-10-openjdk-armhf/bin/java"
1616

1717
# graphics
1818
CHARACTER="#"

0 commit comments

Comments
 (0)