-
Notifications
You must be signed in to change notification settings - Fork 5
/
openjdk.install
executable file
·89 lines (79 loc) · 2.57 KB
/
openjdk.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
set -e
set -u
VERSION=17.0.13
LINUXJDK=https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jdk_x64_linux_hotspot_17.0.13_11.tar.gz
LINUXAARCH64JDK=https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jdk_aarch64_linux_hotspot_17.0.13_11.tar.gz
MACOSJDK=https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jdk_x64_mac_hotspot_17.0.13_11.tar.gz
MACOSAARCH64JDK=https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jdk_aarch64_mac_hotspot_17.0.13_11.tar.gz
WIN32JDK=https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jdk_x86-32_windows_hotspot_17.0.13_11.zip
WIN64JDK=https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jdk_x64_windows_hotspot_17.0.13_11.zip
uid()
{
id | cut -f2 -d = | cut -f1 -d \(;
}
# install <OpenJDK URL> <dest. dir.> <release path> <platform ID> <version>
install()
{
JDKFILE="`basename $1`"
mkdir -p ~/.openjdk/$4
pushd ~/.openjdk/$4 >/dev/null 2>&1
NEEDINSTALL=0
if [ ! -r ~/.openjdk/$4/$JDKFILE -o ! -d "$2" ]; then
NEEDINSTALL=1
fi
if [ -f $3 ]; then
INSTALLED_VERSION=`grep JAVA_VERSION= $3 | cut -f2 -d\"`
if [ "$INSTALLED_VERSION" != "$5" ]; then
NEEDINSTALL=1
fi
else
NEEDINSTALL=1
fi
wget -nv -c "$1"
find . -type f ! -name "$JDKFILE" -delete
if [ "$NEEDINSTALL" = "1" ]; then
echo Installing OpenJDK ...
$SUDO rm -rf "$2"
$SUDO mkdir "$2"
$SUDO chmod 755 "$2"
EXT=${JDKFILE##*.}
if [ "$EXT" = "zip" ]; then
pushd "$2" >/dev/null 2>&1
unzip -qx ~/.openjdk/$4/$JDKFILE
mv jdk-*/* .
rmdir jdk-*
popd >/dev/null 2>&1
else
$SUDO tar xfoz "$JDKFILE" -C "$2" --strip-components $STRIP
fi
echo OpenJDK installed.
else
echo OpenJDK $5 already installed.
fi
}
SUDO=
if [ ! `uid` -eq 0 ]; then
SUDO=sudo
fi
case "`uname -s`" in
Linux)
STRIP=1
install $LINUXJDK /opt/openjdk17 /opt/openjdk17/release linux64 $VERSION
install $LINUXAARCH64JDK /opt/openjdk17.arm64 /opt/openjdk17.arm64/release linux.arm64 $VERSION
;;
Darwin)
STRIP=1
install $MACOSJDK /opt/openjdk17 /opt/openjdk17/Contents/Home/release macosx8664 $VERSION
install $MACOSAARCH64JDK /opt/openjdk17.arm64 /opt/openjdk17.arm64/Contents/Home/release macosarm64 $VERSION
;;
MSYS*|MINGW*)
SUDO=
install $WIN32JDK /opt/openjdk17 /opt/openjdk17/release win32 $VERSION
install $WIN64JDK /opt/openjdk17.x64 /opt/openjdk17.x64/release win64 $VERSION
;;
*)
echo "Unsupported platform"
exit 1
;;
esac
popd >/dev/null 2>&1