forked from AdoptOpenJDK/openjdk11-upstream-binaries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-rhel-deps-build-openjdk11.sh
279 lines (258 loc) · 8.3 KB
/
install-rhel-deps-build-openjdk11.sh
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/bin/bash
set -e
# Determine platform name. Currently supported:
#
# x86_64 => x64_linux
# aarch64 => aarch64_linux
#
platform_name() {
arch=$(uname -m)
case $arch in
x86_64)
echo "x64_linux"
;;
aarch64)
echo "aarch64_linux"
;;
*)
echo "Unsupported platform '$arch'" 1>&2
exit 1
;;
esac
}
#
# Mapping for static-libs packaging
#
# x86_64 => amd64
# aarch64 => aarch64
#
staticlibs_arch() {
arch=$(uname -m)
case $arch in
x86_64)
echo "amd64"
;;
aarch64)
echo "aarch64"
;;
*)
echo "Unsupported platform '$arch'" 1>&2
exit 1
;;
esac
}
BRS_FILE=openjdk_build_deps.txt
BUILD_SCRIPT=build-openjdk11.sh
cat > $BRS_FILE <<EOF
autoconf
automake
alsa-lib-devel
binutils
cups-devel
fontconfig
freetype-devel
devtoolset-8
giflib-devel
devtoolset-8-gcc-c++
gtk2-devel
libjpeg-devel
libpng-devel
libxslt
libX11-devel
libXi-devel
libXinerama-devel
libXt-devel
libXtst-devel
pkgconfig
xorg-x11-proto-devel
zip
unzip
java-1.8.0-openjdk-devel
openssl
git
wget
patch
gzip
tar
EOF
# Download and install boot JDK
#
# Originally boot-strapped with build-openjdk9.sh and build-openjdk10.sh
# For simplicity download a suitable boot JDK from AdoptOpenJDK.
pushd /opt
wget -O jdk-11.0.14_9.tar.gz "https://github.com/AdoptOpenJDK/openjdk11-upstream-binaries/releases/download/jdk-11.0.14%2B9/OpenJDK11U-jdk_$(platform_name)_11.0.14_9.tar.gz"
tar -xf jdk-11.0.14_9.tar.gz
/opt/openjdk-11.0.14_9/bin/java -version
popd
BOOT_JDK="/opt/openjdk-11.0.14_9/"
yum -y install $(echo $(cat $BRS_FILE))
# On some build hosts available disk size of /home
# is insufficient for building OpenJDK in release and
# slowdebug configurations. Be sure to bind-mount
# an appropriate slice of / for the build to succeed.
THRESHOLD_DISK_SIZE="20"
AVAIL_HOME="$(echo $(df -P --block-size=G /home | tail -n1 | awk '{print $4}' | sed 's/G//g'))"
AVAIL_OPT="$(echo $(df -P --block-size=G /opt | tail -n1 | awk '{print $4}' | sed 's/G//g'))"
if [ ${AVAIL_HOME} -lt ${THRESHOLD_DISK_SIZE} ]; then
# Some diagnostic output
df -P -h
if [ ${AVAIL_OPT} -lt ${THRESHOLD_DISK_SIZE} ]; then
# Nothing we can do, the build host seems not suitable
echo "Neither /home nor /opt have sufficient disk space available. This is an error." 1>&2
exit 1
fi
# Preconditions met. Bind mount a slice of /opt
if [ ! -e /opt/openjdk ]; then
mkdir /opt/openjdk
fi
if [ ! -e /home/openjdk ]; then
mkdir /home/openjdk
fi
echo -n "Bind-mounting /opt/openjdk (Avail: ${AVAIL_OPT}G) to "
echo "/home/openjdk (Avail: ${AVAIL_HOME}G) for disk space reasons."
mount -o bind /opt/openjdk /home/openjdk
else
echo "Disk space of /home seems sufficient: Avail: ${AVAIL_OPT}G"
fi
useradd openjdk
# Note: platform_name, BOOT_JDK intentionally not escaped
cat > $BUILD_SCRIPT <<EOF
#!/bin/bash
set -e
UPDATE="11.0.16"
BUILD=8
NAME="openjdk-\${UPDATE}_\${BUILD}"
JRE_NAME="\${NAME}-jre"
TEST_IMAGE_NAME="\${NAME}-test-image"
TARBALL_BASE_NAME="OpenJDK11U"
EA_SUFFIX=""
PLATFORM="$(platform_name)"
STATICLIBS_ARCH="$(staticlibs_arch)"
TARBALL_VERSION="\${UPDATE}_\${BUILD}\${EA_SUFFIX}"
PLATFORM_VERSION="\${PLATFORM}_\${TARBALL_VERSION}"
TARBALL_NAME="\${TARBALL_BASE_NAME}-jdk_\${PLATFORM_VERSION}"
TARBALL_NAME_JRE="\${TARBALL_BASE_NAME}-jre_\${PLATFORM_VERSION}"
TARBALL_NAME_SHENANDOAH="\${TARBALL_BASE_NAME}-jdk-shenandoah_\${PLATFORM_VERSION}"
TARBALL_NAME_SHENANDOAH_JRE="\${TARBALL_BASE_NAME}-jre-shenandoah_\${PLATFORM_VERSION}"
TARBALL_NAME_TEST_IMAGE="\${TARBALL_BASE_NAME}-testimage_\${PLATFORM_VERSION}"
TARBALL_NAME_SHENANDOAH_TEST_IMAGE="\${TARBALL_BASE_NAME}-testimage-shenandoah_\${PLATFORM_VERSION}"
TARBALL_NAME_STATIC_LIBS="\${TARBALL_BASE_NAME}-static-libs_\${PLATFORM_VERSION}"
SOURCE_NAME="\${TARBALL_BASE_NAME}-sources_\${TARBALL_VERSION}"
# Release string for the vendor. Use the GA date.
VENDOR="18.9"
CLONE_URL=https://github.com/openjdk/jdk11u
TAG="jdk-\${UPDATE}+\${BUILD}"
clone() {
url=\$1
tag=\$2
targetdir=\$3
if [ -d \$targetdir ]; then
echo "Target directory \$targetdir already exists. Skipping clone"
return
fi
git clone \$url \$targetdir
pushd \$targetdir
git checkout -b \$tag \$tag
popd
}
build() {
# On some systems the per user process limit is set too low
# by default (e.g. 1024). This may make the build fail on
# systems with many cores (e.g. 64). Raise the limit to 1/2
# of the maximum amount of threads allowed by the kernel.
if [ -e /proc/sys/kernel/threads-max ]; then
ulimit -u \$(( \$(cat /proc/sys/kernel/threads-max) / 2))
fi
rm -rf build
# Add patch to be able to build on EL 6
wget https://bugs.openjdk.java.net/secure/attachment/81704/JDK-8219879.jdk11.export.patch
patch -p1 < JDK-8219879.jdk11.export.patch
# Create a source tarball archive corresponding to the
# binary build
tar -c -z -f ../\${SOURCE_NAME}.tar.gz --transform "s|^|\${NAME}-sources/|" --exclude-vcs --exclude='**.patch*' --exclude='overall-build.log' .
VERSION_PRE=""
if [ "\${EA_SUFFIX}_" != "_" ]; then
VERSION_PRE="ea"
fi
for debug in release shenandoah slowdebug; do
if [ "\$debug" == "shenandoah" ]; then
flag="--with-jvm-features=shenandoahgc"
dbg_level="release"
else
flag=""
dbg_level="\$debug"
fi
scl enable devtoolset-8 -- bash configure \
--with-boot-jdk="$BOOT_JDK" \
"\$flag" \
--with-debug-level="\$dbg_level" \
--with-conf-name="\$debug" \
--enable-unlimited-crypto \
--with-version-build=\$BUILD \
--with-version-pre="\$VERSION_PRE" \
--with-version-opt="" \
--with-vendor-version-string="\$VENDOR" \
--with-native-debug-symbols=external \
--disable-warnings-as-errors
targets="bootcycle-images legacy-images test-image static-libs-image"
if [ "\${debug}_" == "slowdebug_" ]; then
targets="images"
fi
scl enable devtoolset-8 -- make LOG=debug CONF=\$debug \$targets
archive_name="\$TARBALL_NAME"
jre_archive_name="\$TARBALL_NAME_JRE"
testimage_archive_name="\$TARBALL_NAME_TEST_IMAGE"
if [ "\${debug}_" == "shenandoah_" ]; then
archive_name="\$TARBALL_NAME_SHENANDOAH"
jre_archive_name="\$TARBALL_NAME_SHENANDOAH_JRE"
testimage_archive_name="\$TARBALL_NAME_SHENANDOAH_TEST_IMAGE"
fi
# Package it up
pushd build/\$debug/images
if [ "\${debug}_" == "slowdebug_" ]; then
NAME="\$NAME-\$debug"
archive_name="\$archive_name-\$debug"
fi
mv jdk \$NAME
tar -c -f \${archive_name}.tar --exclude='**.debuginfo' \$NAME
gzip \${archive_name}.tar
tar -c -f \${archive_name}-debuginfo.tar \$(find \${NAME}/ -name \*.debuginfo)
gzip \${archive_name}-debuginfo.tar
mv \$NAME jdk
# JRE package produced via legacy-images (release only)
if [ "\${debug}_" == "release_" ] || [ "\${debug}_" == "shenandoah_" ]; then
mv jre \$JRE_NAME
tar -c -f \${jre_archive_name}.tar --exclude='**.debuginfo' \$JRE_NAME
gzip \${jre_archive_name}.tar
tar -c -f \${jre_archive_name}-debuginfo.tar \$(find \${JRE_NAME}/ -name \*.debuginfo)
gzip \${jre_archive_name}-debuginfo.tar
mv \$JRE_NAME jre
# Test image (release-only: needed for after-the-fact testing with native libs)
mv "test" \$TEST_IMAGE_NAME
tar -c -f \${testimage_archive_name}.tar \$TEST_IMAGE_NAME
gzip \${testimage_archive_name}.tar
mv \$TEST_IMAGE_NAME "test"
# Static libraries (release-only: needed for building graal vm with native image)
# Tar as overlay
tar --transform "s|^static-libs/lib/*|\${NAME}/lib/static/linux-\${STATICLIBS_ARCH}/glibc/|" -c -f \${TARBALL_NAME_STATIC_LIBS}.tar "static-libs/lib"
gzip \${TARBALL_NAME_STATIC_LIBS}.tar
fi
popd
done
mv ../\${SOURCE_NAME}.tar.gz build/
find \$(pwd)/build -name \*.tar.gz
}
TARGET_FOLDER="jdk11u"
clone \$CLONE_URL \$TAG \$TARGET_FOLDER
pushd \$TARGET_FOLDER
build 2>&1 | tee overall-build.log
popd
ALL_ARTEFACTS="\$NAME\$EA_SUFFIX-$(platform_name)-all-artefacts.tar"
tar -c -f \$ALL_ARTEFACTS --transform "s|^\$TARGET_FOLDER/|\$NAME\$EA_SUFFIX-all-artefacts/$(platform_name)/|g" \$(echo \$(find \$TARGET_FOLDER/build -name \*.tar.gz) \$TARGET_FOLDER/overall-build.log)
gzip \$ALL_ARTEFACTS
ls -lh \$(pwd)/*.tar.gz
EOF
cp $BUILD_SCRIPT /home/openjdk
chown -R openjdk /home/openjdk
# Drop privs and perform build
su -c "bash $BUILD_SCRIPT" - openjdk