archrelease: copy trunk to extra-x86_64
[arch-packages.git] / java-openjdk / trunk / PKGBUILD
blob95c0ca0daea847360da39b451baed408f5a62843
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=java-openjdk
8 pkgname=('jre-openjdk-headless' 'jre-openjdk' 'jdk-openjdk' 'openjdk-src' 'openjdk-doc')
9 _majorver=20
10 _minorver=0
11 _securityver=1
12 _updatever=9
13 pkgver=${_majorver}.${_minorver}.${_securityver}.u${_updatever}
14 #pkgver=${_majorver}.u${_updatever}
15 pkgrel=3
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=('1b7f42ecedf97a837b1f3499d2b6293b26ffed97627b1bd883452c21cf9f798b'
31             '761d4f1274c7dfb4ff61f6d6cb01504f2f886240229e371647ce227fcf81278e'
32             '2b17178ac414e1d0768c8f482779efa88bfeab17b8b0517df4e66b3c2874131c'
33             '82329d23887df14bce3f8d8f356fe8f4b643831d40ade5fed31a070516f86fd7')
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
45               lib/libjawt.so
46               lib/libjsound.so
47               lib/libsplashscreen.so)
49 _nonjre=(lib/ct.sym
50           lib/libattach.so
51           lib/libsaproc.so
52           lib/src.zip)
55 build() {
56   cd ${_jdkdir}
58   NUM_PROC_OPT=''
59   MAKEFLAG_J=$(echo ${MAKEFLAGS} | sed -En 's/.*-j([0-9]+).*/\1/p')
60   if [ -n "${MAKEFLAG_J}" ]; then
61     # http://hg.openjdk.java.net/jdk10/jdk10/file/85e6cb013b98/make/InitSupport.gmk#l105
62     echo "Removing '-j${MAKEFLAG_J}' from MAKEFLAGS to prevent build fail. Passing it directly to ./configure."
63     export MAKEFLAGS=${MAKEFLAGS/-j${MAKEFLAG_J}/}
64     NUM_PROC_OPT="--with-num-cores=${MAKEFLAG_J}"
65   fi
67   # Avoid optimization of HotSpot to be lowered from O3 to O2
68   local _CFLAGS="${CFLAGS//-O2/-O3} ${CPPFLAGS} -fcommon"
69   local _CXXFLAGS="${CXXFLAGS//-O2/-O3} ${CPPFLAGS} -fcommon"
70   local _LDFLAGS=${LDFLAGS}
71   if [[ ${CARCH} = i686 ]]; then
72     echo "Removing '-fno-plt' from CFLAGS and CXXFLAGS to prevent build fail with this architecture"
73     _CFLAGS=${CFLAGS/-fno-plt/}
74     _CXXFLAGS=${CXXFLAGS/-fno-plt/}
75   fi
77   # TODO: Should be rechecked for the next releases
78   # compiling with -fexceptions leads to:
79   # /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()':
80   # /build/java-openjdk/src/jdk17u-jdk-17.0.3-2/src/hotspot/share/gc/z/zList.hpp:54: undefined reference to `ZListNode<ZMemory>::~ZListNode()'
81   # collect2: error: ld returned 1 exit status
82   _CFLAGS=${CFLAGS/-fexceptions/}
83   _CXXFLAGS=${CXXFLAGS/-fexceptions/}
85   # CFLAGS, CXXFLAGS and LDFLAGS are ignored as shown by a warning
86   # in the output of ./configure unless used like such:
87   #  --with-extra-cflags="${CFLAGS}"
88   #  --with-extra-cxxflags="${CXXFLAGS}"
89   #  --with-extra-ldflags="${LDFLAGS}"
90   # See also paragraph "Configure Control Variables from "jdk${_majorver}-${_git_tag}/common/doc/building.md
91   unset CFLAGS
92   unset CXXFLAGS
93   unset LDFLAGS
95   bash configure \
96     --with-version-build="${_updatever}" \
97     --with-version-pre="" \
98     --with-version-opt="" \
99     --with-stdc++lib=dynamic \
100     --with-extra-cflags="${_CFLAGS}" \
101     --with-extra-cxxflags="${_CXXFLAGS}" \
102     --with-extra-ldflags="${_LDFLAGS}" \
103     --with-libjpeg=system \
104     --with-giflib=system \
105     --with-libpng=system \
106     --with-lcms=system \
107     --with-zlib=system \
108     --with-harfbuzz=system \
109     --with-jvm-features=zgc,shenandoahgc \
110     --with-native-debug-symbols=internal \
111     --enable-unlimited-crypto \
112     --disable-warnings-as-errors \
113     ${NUM_PROC_OPT}
114     #--disable-javac-server
116   make images legacy-jre-image docs
118   # https://bugs.openjdk.java.net/browse/JDK-8173610
119   find "../${_imgdir}" -iname '*.so' -exec chmod +x {} \;
122 check() {
123   cd ${_jdkdir}
124   # TODO package jtreg
125   # make -k check
128 package_jre-openjdk-headless() {
129   pkgdesc="OpenJDK Java ${_majorver} headless runtime environment"
130   depends=('java-runtime-common>=3' 'ca-certificates-utils' 'nss' 'libjpeg-turbo' 'libjpeg.so'
131            'lcms2' 'liblcms2.so' 'libnet' 'freetype2' 'libfreetype.so' 'harfbuzz' 'libharfbuzz.so'
132            'glibc' 'gcc-libs')
133   optdepends=('java-rhino: for some JavaScript support')
134   provides=("java-runtime-headless=${_majorver}" "java-runtime-headless-openjdk=${_majorver}" "jre${_majorver}-openjdk-headless=${pkgver}-${pkgrel}")
135   backup=(etc/${pkgbase}/logging.properties
136           etc/${pkgbase}/management/jmxremote.access
137           etc/${pkgbase}/management/jmxremote.password.template
138           etc/${pkgbase}/management/management.properties
139           etc/${pkgbase}/net.properties
140           etc/${pkgbase}/security/java.policy
141           etc/${pkgbase}/security/java.security
142           etc/${pkgbase}/security/policy/README.txt
143           etc/${pkgbase}/security/policy/limited/default_US_export.policy
144           etc/${pkgbase}/security/policy/limited/default_local.policy
145           etc/${pkgbase}/security/policy/limited/exempt_local.policy
146           etc/${pkgbase}/security/policy/unlimited/default_US_export.policy
147           etc/${pkgbase}/security/policy/unlimited/default_local.policy
148           etc/${pkgbase}/sound.properties)
149   install=install_jre-openjdk-headless.sh
151   cd ${_imgdir}/jre
153   install -dm 755 "${pkgdir}${_jvmdir}"/bin
155   for i in $(ls bin/); do
156     cp ../jdk/bin/$i "${pkgdir}${_jvmdir}/bin/"
157   done
159   cp -a ../jdk/lib "${pkgdir}${_jvmdir}"
161   for f in "${_nonjre[@]}"; do
162     rm "${pkgdir}${_jvmdir}/${f}"
163   done
165   for f in "${_nonheadless[@]}"; do
166     rm "${pkgdir}${_jvmdir}/${f}"
167   done
169   cp ../jdk/release "${pkgdir}${_jvmdir}"
170   cp ../jdk/lib/modules "${pkgdir}${_jvmdir}/lib"
172   # Conf
173   install -dm 755 "${pkgdir}/etc"
174   cp -r conf "${pkgdir}/etc/${pkgbase}"
175   ln -s /etc/${pkgbase} "${pkgdir}/${_jvmdir}/conf"
177   # Legal
178   install -dm 755 "${pkgdir}/usr/share/licenses"
179   cp -r legal "${pkgdir}/usr/share/licenses/${pkgbase}"
180   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
181   ln -s /usr/share/licenses/${pkgbase} "${pkgdir}/${_jvmdir}/legal"
183   # Man pages
184   for f in bin/*; do
185     f=$(basename "${f}")
186     _man=../jdk/man/man1/"${f}.1"
187     test -f "${_man}" && install -Dm 644 "${_man}" "${pkgdir}/usr/share/man/man1/${f}-openjdk${_majorver}.1"
188   done
189   ln -s /usr/share/man "${pkgdir}/${_jvmdir}/man"
191   # Link JKS keystore from ca-certificates-utils
192   rm -f "${pkgdir}${_jvmdir}/lib/security/cacerts"
193   ln -sf /etc/ssl/certs/java/cacerts "${pkgdir}${_jvmdir}/lib/security/cacerts"
196 package_jre-openjdk() {
197   pkgdesc="OpenJDK Java ${_majorver} full runtime environment"
198   depends=("jre${_majorver}-openjdk-headless=${pkgver}-${pkgrel}" 'giflib' 'libgif.so'
199            'glibc' 'gcc-libs' 'libpng')
200   optdepends=('alsa-lib: for basic sound support'
201               'gtk2: for the Gtk+ 2 look and feel - desktop usage'
202               'gtk3: for the Gtk+ 3 look and feel - desktop usage')
203   provides=("java-runtime=${_majorver}" "java-runtime-openjdk=${_majorver}" "jre${_majorver}-openjdk=${pkgver}-${pkgrel}")
204   install=install_jre-openjdk.sh
206   cd ${_imgdir}/jre
208   install -dm 755 "${pkgdir}${_jvmdir}"
210   for f in "${_nonheadless[@]}"; do
211     install -Dm 644 ${f} "${pkgdir}${_jvmdir}/${f}"
212   done
214   # Licenses
215   install -dm 755 "${pkgdir}/usr/share/licenses"
216   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
219 package_jdk-openjdk() {
220   pkgdesc="OpenJDK Java ${_majorver} development kit"
221   depends=("jre${_majorver}-openjdk=${pkgver}-${pkgrel}" 'java-environment-common=3'
222            'hicolor-icon-theme' 'libelf' 'glibc' 'gcc-libs')
223   provides=("java-environment=${_majorver}" "java-environment-openjdk=${_majorver}" "jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
224   install=install_jdk-openjdk.sh
226   cd ${_imgdir}/jdk
228   install -dm 755 "${pkgdir}${_jvmdir}"
230   cp -a bin demo include jmods lib \
231     "${pkgdir}${_jvmdir}"
233   rm "${pkgdir}${_jvmdir}/lib/src.zip"
235   # Remove files held by JRE
236   pushd ../jre
237   for d in bin lib; do
238     find ${d} ! -type d -exec rm "${pkgdir}${_jvmdir}/{}" \;
239   done
240   popd
241   find "${pkgdir}${_jvmdir}/lib" -type d -empty -delete
243   # Conf files all belong to JRE
245   # Legal
246   install -dm 755 "${pkgdir}/usr/share/licenses"
247   cp -r legal "${pkgdir}/usr/share/licenses/${pkgbase}"
248   pushd ../jre/legal
249   find . ! -type d -exec rm "${pkgdir}/usr/share/licenses/${pkgbase}/{}" \;
250   popd
251   find "${pkgdir}/usr/share/licenses" -type d -empty -delete
252   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
254   # Man pages
255   for f in bin/*; do
256     f=$(basename "${f}")
257     _man=man/man1/"${f}.1"
258     test -f "../jre/bin/${f}" && continue
259     test -f "${_man}" && install -Dm 644 "${_man}" "${pkgdir}/usr/share/man/man1/${f}-openjdk${_majorver}.1"
260   done
262   # Icons
263   for s in 16 24 32 48; do
264     install -Dm 644 \
265       "${srcdir}/${_jdkdir}/src/java.desktop/unix/classes/sun/awt/X11/java-icon${s}.png" \
266       "${pkgdir}/usr/share/icons/hicolor/${s}x${s}/apps/${pkgbase}.png"
267   done
269   # Desktop files
270   for f in jconsole java jshell; do
271     install -Dm 644 \
272       "${srcdir}/freedesktop-${f}.desktop" \
273       "${pkgdir}/usr/share/applications/${f}-${pkgbase}.desktop"
274   done
277 package_openjdk-src() {
278   pkgdesc="OpenJDK Java ${_majorver} sources"
279   # Depends on JDK to get license files
280   depends=("jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
281   provides=("openjdk${_majorver}-src=${pkgver}-${pkgrel}")
283   install -Dm 644 -t "${pkgdir}${_jvmdir}/lib" ${_imgdir}/jdk/lib/src.zip
285   install -dm 755 "${pkgdir}/usr/share/licenses"
286   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
289 package_openjdk-doc() {
290   pkgdesc="OpenJDK Java ${_majorver} documentation"
291   # Depends on JDK to get license files
292   depends=("jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
293   provides=("openjdk${_majorver}-doc=${pkgver}-${pkgrel}")
295   install -dm 755 "${pkgdir}/usr/share/doc"
296   cp -r ${_imgdir}/docs "${pkgdir}/usr/share/doc/${pkgbase}"
298   install -dm 755 "${pkgdir}/usr/share/licenses"
299   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
302 # vim: ts=2 sw=2 et: