archrelease: copy trunk to extra-x86_64
[arch-packages.git] / java17-openjdk / trunk / PKGBUILD
blobe45aa5b5b7956e85a01071c25861f603d95b8d1a
1 # Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
2 # Maintainer: Frederik Schwan <freswa at archlinux dot org>
3 # Contributor: Guillaume ALAUX <guillaume@archlinux.org>
5 # TODO add test, see about packaging jtreg and using it here
7 pkgbase=java17-openjdk
8 pkgname=('jre17-openjdk-headless' 'jre17-openjdk' 'jdk17-openjdk' 'openjdk17-src' 'openjdk17-doc')
9 _majorver=17
10 _minorver=0
11 _securityver=3
12 _updatever=7
13 pkgver=${_majorver}.${_minorver}.${_securityver}.u${_updatever}
14 #pkgver=${_majorver}.u${_updatever}
15 pkgrel=2
16 _git_tag=jdk-${_majorver}.${_minorver}.${_securityver}+${_updatever}
17 #_git_tag=jdk-${_majorver}+${_updatever}
18 arch=('x86_64')
19 url='https://openjdk.java.net/'
20 license=('custom')
21 makedepends=('java-environment=17' 'cpio' 'unzip' 'zip' 'libelf' 'libcups' 'libx11'
22              'libxrender' 'libxtst' 'libxt' 'libxext' 'libxrandr' 'alsa-lib' 'pandoc'
23              'graphviz' 'freetype2' 'libjpeg-turbo' 'giflib' 'libpng' 'lcms2'
24              'libnet' 'bash' 'harfbuzz' 'gcc-libs' 'glibc')
25 options=(!lto)
26 source=(https://github.com/openjdk/jdk${_majorver}u/archive/${_git_tag}.tar.gz
27         freedesktop-java.desktop
28         freedesktop-jconsole.desktop
29         freedesktop-jshell.desktop)
30 sha256sums=('22575340d080a396442658356583d9c7dc0c44cefa52842fbfcf23eef23c39a0'
31             '85c4742764590783160af74587a47269e6797fbdf17ec485c7644bd239adf61d'
32             'abac1ab09a33a3654378bc69be5a7cf075263ab3ae9efec1eb25cf388e711bb7'
33             'e7cce0ecf868f656d8dc2eb25ab82ab665526a0a28aba20f02632dd29962dac3')
35 case "${CARCH}" in
36   x86_64) _JARCH='x86_64';;
37   i686)   _JARCH='x86';;
38 esac
40 _jvmdir=/usr/lib/jvm/java-${_majorver}-openjdk
41 _jdkdir=jdk${_majorver}u-${_git_tag//+/-}
42 _imgdir=${_jdkdir}/build/linux-${_JARCH}-server-release/images
44 _nonheadless=(lib/libawt_xawt.{so,debuginfo}
45               lib/libjawt.{so,debuginfo}
46               lib/libjsound.{so,debuginfo}
47               lib/libsplashscreen.{so,debuginfo})
49 build() {
50   cd ${_jdkdir}
52   NUM_PROC_OPT=''
53   MAKEFLAG_J=$(echo ${MAKEFLAGS} | sed -En 's/.*-j([0-9]+).*/\1/p')
54   if [ -n "${MAKEFLAG_J}" ]; then
55     # http://hg.openjdk.java.net/jdk10/jdk10/file/85e6cb013b98/make/InitSupport.gmk#l105
56     echo "Removing '-j${MAKEFLAG_J}' from MAKEFLAGS to prevent build fail. Passing it directly to ./configure."
57     export MAKEFLAGS=${MAKEFLAGS/-j${MAKEFLAG_J}/}
58     NUM_PROC_OPT="--with-num-cores=${MAKEFLAG_J}"
59   fi
61   # Avoid optimization of HotSpot to be lowered from O3 to O2
62   local _CFLAGS="${CFLAGS//-O2/-O3} ${CPPFLAGS} -fcommon"
63   local _CXXFLAGS="${CXXFLAGS//-O2/-O3} ${CPPFLAGS} -fcommon"
64   local _LDFLAGS=${LDFLAGS}
65   if [[ ${CARCH} = i686 ]]; then
66     echo "Removing '-fno-plt' from CFLAGS and CXXFLAGS to prevent build fail with this architecture"
67     _CFLAGS=${CFLAGS/-fno-plt/}
68     _CXXFLAGS=${CXXFLAGS/-fno-plt/}
69   fi
71   # TODO: Should be rechecked for the next releases
72   # compiling with -fexceptions leads to:
73   # /usr/bin/ld: /build/java-openjdk/src/jdk17u-jdk-17.0.3-2/build/linux-x86_64-server-release/hotspot/variant-server/libjvm/objs/zPhysicalMemory.o: in function `ZList<ZMemory>::~ZList()':
74   # /build/java-openjdk/src/jdk17u-jdk-17.0.3-2/src/hotspot/share/gc/z/zList.hpp:54: undefined reference to `ZListNode<ZMemory>::~ZListNode()'
75   # collect2: error: ld returned 1 exit status
76   _CFLAGS=${CFLAGS/-fexceptions/}
77   _CXXFLAGS=${CXXFLAGS/-fexceptions/}
79   # CFLAGS, CXXFLAGS and LDFLAGS are ignored as shown by a warning
80   # in the output of ./configure unless used like such:
81   #  --with-extra-cflags="${CFLAGS}"
82   #  --with-extra-cxxflags="${CXXFLAGS}"
83   #  --with-extra-ldflags="${LDFLAGS}"
84   # See also paragraph "Configure Control Variables from "jdk${_majorver}-${_git_tag}/common/doc/building.md
85   unset CFLAGS
86   unset CXXFLAGS
87   unset LDFLAGS
89   bash configure \
90     --with-version-build="${_updatever}" \
91     --with-version-pre="" \
92     --with-version-opt="" \
93     --with-stdc++lib=dynamic \
94     --with-extra-cflags="${_CFLAGS}" \
95     --with-extra-cxxflags="${_CXXFLAGS}" \
96     --with-extra-ldflags="${_LDFLAGS}" \
97     --with-libjpeg=system \
98     --with-giflib=system \
99     --with-libpng=system \
100     --with-lcms=system \
101     --with-zlib=system \
102     --with-harfbuzz=system \
103     --with-jvm-features=zgc \
104     --enable-unlimited-crypto \
105     --disable-warnings-as-errors \
106     ${NUM_PROC_OPT}
107     #--disable-javac-server
109   make images legacy-jre-image docs
111   # https://bugs.openjdk.java.net/browse/JDK-8173610
112   find "../${_imgdir}" -iname '*.so' -exec chmod +x {} \;
115 check() {
116   cd ${_jdkdir}
117   # TODO package jtreg
118   # make -k check
121 package_jre17-openjdk-headless() {
122   pkgdesc="OpenJDK Java ${_majorver} headless runtime environment"
123   depends=('java-runtime-common>=3' 'ca-certificates-utils' 'nss' 'libjpeg-turbo' 'libjpeg.so'
124            'lcms2' 'liblcms2.so' 'libnet' 'freetype2' 'libfreetype.so' 'harfbuzz' 'libharfbuzz.so'
125            'glibc' 'gcc-libs')
126   optdepends=('java-rhino: for some JavaScript support')
127   provides=("java-runtime-headless=${_majorver}" "java-runtime-headless-openjdk=${_majorver}" "jre${_majorver}-openjdk-headless=${pkgver}-${pkgrel}")
128   backup=(etc/${pkgbase}/logging.properties
129           etc/${pkgbase}/management/jmxremote.access
130           etc/${pkgbase}/management/jmxremote.password.template
131           etc/${pkgbase}/management/management.properties
132           etc/${pkgbase}/net.properties
133           etc/${pkgbase}/security/java.policy
134           etc/${pkgbase}/security/java.security
135           etc/${pkgbase}/security/policy/README.txt
136           etc/${pkgbase}/security/policy/limited/default_US_export.policy
137           etc/${pkgbase}/security/policy/limited/default_local.policy
138           etc/${pkgbase}/security/policy/limited/exempt_local.policy
139           etc/${pkgbase}/security/policy/unlimited/default_US_export.policy
140           etc/${pkgbase}/security/policy/unlimited/default_local.policy
141           etc/${pkgbase}/sound.properties)
142   install=install_jre-openjdk-headless.sh
144   cd ${_imgdir}/jre
146   install -dm 755 "${pkgdir}${_jvmdir}"
148   cp -a bin lib \
149     "${pkgdir}${_jvmdir}"
151   for f in "${_nonheadless[@]}"; do
152     rm "${pkgdir}${_jvmdir}/${f}"
153   done
155   cp ../jdk/release "${pkgdir}${_jvmdir}"
156   cp ../jdk/lib/modules "${pkgdir}${_jvmdir}/lib"
158   # Conf
159   install -dm 755 "${pkgdir}/etc"
160   cp -r conf "${pkgdir}/etc/${pkgbase}"
161   ln -s /etc/${pkgbase} "${pkgdir}/${_jvmdir}/conf"
163   # Legal
164   install -dm 755 "${pkgdir}/usr/share/licenses"
165   cp -r legal "${pkgdir}/usr/share/licenses/${pkgbase}"
166   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
167   ln -s /usr/share/licenses/${pkgbase} "${pkgdir}/${_jvmdir}/legal"
169   # Man pages
170   for f in bin/*; do
171     f=$(basename "${f}")
172     _man=../jdk/man/man1/"${f}.1"
173     test -f "${_man}" && install -Dm 644 "${_man}" "${pkgdir}/usr/share/man/man1/${f}-openjdk${_majorver}.1"
174   done
175   ln -s /usr/share/man "${pkgdir}/${_jvmdir}/man"
177   # Link JKS keystore from ca-certificates-utils
178   rm -f "${pkgdir}${_jvmdir}/lib/security/cacerts"
179   ln -sf /etc/ssl/certs/java/cacerts "${pkgdir}${_jvmdir}/lib/security/cacerts"
182 package_jre17-openjdk() {
183   pkgdesc="OpenJDK Java ${_majorver} full runtime environment"
184   depends=("jre${_majorver}-openjdk-headless=${pkgver}-${pkgrel}" 'giflib' 'libgif.so'
185            'glibc' 'gcc-libs' 'libpng')
186   optdepends=('alsa-lib: for basic sound support'
187               'gtk2: for the Gtk+ 2 look and feel - desktop usage'
188               'gtk3: for the Gtk+ 3 look and feel - desktop usage')
189   provides=("java-runtime=${_majorver}" "java-runtime-openjdk=${_majorver}" "jre${_majorver}-openjdk=${pkgver}-${pkgrel}")
190   install=install_jre-openjdk.sh
192   cd ${_imgdir}/jre
194   install -dm 755 "${pkgdir}${_jvmdir}"
196   for f in "${_nonheadless[@]}"; do
197     install -Dm 644 ${f} "${pkgdir}${_jvmdir}/${f}"
198   done
200   # Licenses
201   install -dm 755 "${pkgdir}/usr/share/licenses"
202   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
205 package_jdk17-openjdk() {
206   pkgdesc="OpenJDK Java ${_majorver} development kit"
207   depends=("jre${_majorver}-openjdk=${pkgver}-${pkgrel}" 'java-environment-common=3'
208            'hicolor-icon-theme' 'libelf' 'glibc' 'gcc-libs')
209   provides=("java-environment=${_majorver}" "java-environment-openjdk=${_majorver}" "jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
210   install=install_jdk-openjdk.sh
212   cd ${_imgdir}/jdk
214   install -dm 755 "${pkgdir}${_jvmdir}"
216   cp -a bin demo include jmods lib \
217     "${pkgdir}${_jvmdir}"
219   rm "${pkgdir}${_jvmdir}/lib/src.zip"
221   # Remove files held by JRE
222   pushd ../jre
223   for d in bin lib; do
224     find ${d} ! -type d -exec rm "${pkgdir}${_jvmdir}/{}" \;
225   done
226   popd
227   find "${pkgdir}${_jvmdir}/lib" -type d -empty -delete
229   # Conf files all belong to JRE
231   # Legal
232   install -dm 755 "${pkgdir}/usr/share/licenses"
233   cp -r legal "${pkgdir}/usr/share/licenses/${pkgbase}"
234   pushd ../jre/legal
235   find . ! -type d -exec rm "${pkgdir}/usr/share/licenses/${pkgbase}/{}" \;
236   popd
237   find "${pkgdir}/usr/share/licenses" -type d -empty -delete
238   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
240   # Man pages
241   for f in bin/*; do
242     f=$(basename "${f}")
243     _man=man/man1/"${f}.1"
244     test -f "../jre/bin/${f}" && continue
245     test -f "${_man}" && install -Dm 644 "${_man}" "${pkgdir}/usr/share/man/man1/${f}-openjdk${_majorver}.1"
246   done
248   # Icons
249   for s in 16 24 32 48; do
250     install -Dm 644 \
251       "${srcdir}/${_jdkdir}/src/java.desktop/unix/classes/sun/awt/X11/java-icon${s}.png" \
252       "${pkgdir}/usr/share/icons/hicolor/${s}x${s}/apps/${pkgbase}.png"
253   done
255   # Desktop files
256   for f in jconsole java jshell; do
257     install -Dm 644 \
258       "${srcdir}/freedesktop-${f}.desktop" \
259       "${pkgdir}/usr/share/applications/${f}-${pkgbase}.desktop"
260   done
263 package_openjdk17-src() {
264   pkgdesc="OpenJDK Java ${_majorver} sources"
265   # Depends on JDK to get license files
266   depends=("jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
267   provides=("openjdk${_majorver}-src=${pkgver}-${pkgrel}")
269   install -Dm 644 -t "${pkgdir}${_jvmdir}/lib" ${_imgdir}/jdk/lib/src.zip
271   install -dm 755 "${pkgdir}/usr/share/licenses"
272   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
275 package_openjdk17-doc() {
276   pkgdesc="OpenJDK Java ${_majorver} documentation"
277   # Depends on JDK to get license files
278   depends=("jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
279   provides=("openjdk${_majorver}-doc=${pkgver}-${pkgrel}")
281   install -dm 755 "${pkgdir}/usr/share/doc"
282   cp -r ${_imgdir}/docs "${pkgdir}/usr/share/doc/${pkgbase}"
284   install -dm 755 "${pkgdir}/usr/share/licenses"
285   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
288 # vim: ts=2 sw=2 et: