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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
#!/bin/bash
# Slackware build script for OpenJDK17 LTS
# Copyright 2021, 2022 Lenard Spencer, Orlando, Florida, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=OpenJDK17
VERSION=${VERSION:-17.0.6}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm; echo "$ARCH is not supported, aborting."; exit 1 ;;
*) ARCH=$( uname -m ) ;;
esac
fi
# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
# the name of the created package would be, and then exit. This information
# could be useful to other scripts.
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
fi
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf jdk17u-jdk-$VERSION-ga
tar xvf $CWD/jdk17u-jdk-$VERSION-ga.tar.gz
# Building openjdk from source requires bootstrapping from either a
# current or previous version of the (open)jdk binary installation.
# Extract the OpenJDK16 binary to bootstrap
if [ "$ARCH" = "x86_64" ]; then
export BSDIR="OpenJDK-16.0.2-ga-linux-x86_64-bin"
rm -rf $BSDIR
tar xvf $CWD/OpenJDK-16.0.2-ga-linux-x86_64-bin.tar.xz
else
export BSDIR="OpenJDK-16.0.2-ga-linux-i586-bin"
rm -rf $BSDIR
tar xvf $CWD/OpenJDK-16.0.2-ga-linux-i586-bin.tar.xz
fi
export BOOT_JAVA=$TMP/$BSDIR
# Unpack the jtreg package to run the tests:
if [ "${TESTS:-no}" = "yes" ]; then
rm -rf $TMP/jtreg{,-reports}
tar xvf $CWD/jtreg-6.1+1.tar.gz
JTREG="--with-jtreg=$TMP/jtreg"
else
JTREG=""
fi
cd jdk17u-jdk-${VERSION}-ga
echo "Setting permissions (this may take a while so be patient)"
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
unset JAVA_HOME # recommended by upstream
if [ "${USE_CCACHE:-no}" = "yes" ]; then
USECCACHE="--enable-ccache"
else
USECCACHE=""
fi
# By default, the OpenJDK17 build uses all available cpu cores.
# We can override that here with the CORES= switch.
if [ "${CORES:-""}" ]; then
JVAL="$(echo $CORES | grep -o "[0-9]")" || true
[ -n "$JVAL" ] && SJOBS="--with-jobs=$JVAL"
TJOBS=$JVAL
else
SJOBS=""
TJOBS="$(expr $(nproc) + 1)"
fi
sh configure \
--with-boot-jdk=${BOOT_JAVA} \
--with-extra-cflags="$SLKCFLAGS" \
--with-extra-cxxflags="$SLKCFLAGS" \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--sysconfdir=/etc \
--localstatedir=/var \
--mandir=/usr/man \
--docdir=/usr/doc/$PRGNAM-$VERSION \
--with-giflib=system \
--with-harfbuzz=system \
--with-lcms=system \
--with-libjpeg=system \
--with-libpng=system \
--with-zlib=system \
--disable-precompiled-headers \
--enable-unlimited-crypto \
--disable-warnings-as-errors \
--with-native-debug-symbols=none \
$SJOBS \
$USECCACHE \
$JTREG \
--build=$ARCH-slackware-linux
unset MAKEFLAGS # causes the build to fail if set
make bootcycle-images
# Test the build using jtreg (thanks again BLFS):
if [ "$TESTS" = "yes" ]; then
export JT_JAVA=$(echo $TMP/jdk17u-jdk-${VERSION}-ga/build/*/jdk)
mkdir -p $TMP/jtreg-reports
$TMP/jtreg/bin/jtreg -jdk:$JT_JAVA -automatic -ignore:quiet -v1 \
-r:$TMP/jtreg-reports -avm -conc:$TJOBS test/jdk:tier1 test/langtools:tier1 \
|| true
unset JT_JAVA
fi
# make install does not respect DESTDIR, so we must move the image:
mkdir -p $PKG/usr/lib$LIBDIRSUFFIX/java
cp -a build/*/images/jdk/* $PKG/usr/lib$LIBDIRSUFFIX/java
for s in 16 24 32 48; do
install -vDm644 src/java.desktop/unix/classes/sun/awt/X11/java-icon${s}.png \
$PKG/usr/share/icons/hicolor/${s}x${s}/apps/java.png
done
# the 24x24 icon is missized, so we fix it here:
cp $CWD/java.png $PKG/usr/share/icons/hicolor/24x24/apps
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
# Create some necessary symlinks:
( cd $PKG/usr/lib$LIBDIRSUFFIX
ln -sf java $PRGNAM-$VERSION
ln -sf java/lib/libjawt.so
ln -sf java/lib/server/libjvm.so
ln -sf java/lib/libjava.so
ln -sf java/lib/libawt.so
ln -sf java/lib/libawt_xawt.so
ln -sf java/lib/libverify.so
)
# Move man pages and compress:
mv $PKG/usr/lib$LIBDIRSUFFIX/java/man $PKG/usr
find $PKG/usr/man -type f -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
LICENSE ADDITIONAL_LICENSE_INFO ASSEMBLY_EXCEPTION README.md \
$PKG/usr/doc/$PRGNAM-$VERSION
( cd $PKG/usr/doc/$PRGNAM-$VERSION
ln -s ../../lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/legal
ln -s ../../lib${LIBDIRSUFFIX}/$PRGNAM-$VERSION/release
)
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
# Create desktop entries (Thanks BLFS):
mkdir -p $PKG/usr/share/applications
cat > $PKG/usr/share/applications/openjdk-java.desktop << EOF
[Desktop Entry]
Name=OpenJDK ${VERSION} Runtime
Comment=OpenJDK Java ${VERSION} Runtime
Exec=/usr/lib${LIBDIRSUFFIX}/java/bin/java -jar
Terminal=false
Type=Application
Icon=java
MimeType=application/x-java-archive;application/java-archive;application/x-jar;
NoDisplay=true
EOF
cat > $PKG/usr/share/applications/openjdk-jconsole.desktop << EOF
[Desktop Entry]
Name=OpenJDK Java ${VERSION} Console
Comment=OpenJDK ${VERSION} Console
Keywords=java;console;monitoring
Exec=/usr/lib${LIBDIRSUFFIX}/java/bin/jconsole
Terminal=false
Type=Application
Icon=java
Categories=System;
EOF
# Create /etc/profile.d scripts:
mkdir -p $PKG/etc/profile.d
cat > $PKG/etc/profile.d/jdk17.sh << EOF
export JAVA_HOME=/usr/lib${LIBDIRSUFFIX}/java
export PATH=\${PATH}:\${JAVA_HOME}/bin
EOF
cat > $PKG/etc/profile.d/jdk17.csh << EOF
setenv JAVA_HOME /usr/lib${LIBDIRSUFFIX}/java
setenv PATH \${PATH}:\${JAVA_HOME}/bin
EOF
chmod 755 $PKG/etc/profile.d/*
mkdir -p $PKG/install
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
|