archrelease: copy trunk to extra-x86_64
[arch-packages.git] / java17-openjdk / repos / extra-x86_64 / PKGBUILD
blob8f974b90d85df194d37b94797f37a92bb820fc5a
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=7
12 _updatever=7
13 pkgver=${_majorver}.${_minorver}.${_securityver}.u${_updatever}
14 #pkgver=${_majorver}.u${_updatever}
15 pkgrel=1
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=('43b80a5aec5fce908e80858e9b34efdf1b49255a12ce303650325af65141d3e8'
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
45               lib/libjawt.so
46               lib/libjsound.so
47               lib/libsplashscreen.so)
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     --with-native-debug-symbols=internal \
105     --enable-unlimited-crypto \
106     --disable-warnings-as-errors \
107     ${NUM_PROC_OPT}
108     #--disable-javac-server
110   make images legacy-jre-image docs
112   # https://bugs.openjdk.java.net/browse/JDK-8173610
113   find "../${_imgdir}" -iname '*.so' -exec chmod +x {} \;
116 check() {
117   cd ${_jdkdir}
118   # TODO package jtreg
119   # make -k check
122 package_jre17-openjdk-headless() {
123   pkgdesc="OpenJDK Java ${_majorver} headless runtime environment"
124   depends=('java-runtime-common>=3' 'ca-certificates-utils' 'nss' 'libjpeg-turbo' 'libjpeg.so'
125            'lcms2' 'liblcms2.so' 'libnet' 'freetype2' 'libfreetype.so' 'harfbuzz' 'libharfbuzz.so'
126            'glibc' 'gcc-libs')
127   optdepends=('java-rhino: for some JavaScript support')
128   provides=("java-runtime-headless=${_majorver}" "java-runtime-headless-openjdk=${_majorver}" "jre${_majorver}-openjdk-headless=${pkgver}-${pkgrel}")
129   backup=(etc/${pkgbase}/logging.properties
130           etc/${pkgbase}/management/jmxremote.access
131           etc/${pkgbase}/management/jmxremote.password.template
132           etc/${pkgbase}/management/management.properties
133           etc/${pkgbase}/net.properties
134           etc/${pkgbase}/security/java.policy
135           etc/${pkgbase}/security/java.security
136           etc/${pkgbase}/security/policy/README.txt
137           etc/${pkgbase}/security/policy/limited/default_US_export.policy
138           etc/${pkgbase}/security/policy/limited/default_local.policy
139           etc/${pkgbase}/security/policy/limited/exempt_local.policy
140           etc/${pkgbase}/security/policy/unlimited/default_US_export.policy
141           etc/${pkgbase}/security/policy/unlimited/default_local.policy
142           etc/${pkgbase}/sound.properties)
143   install=install_jre-openjdk-headless.sh
145   cd ${_imgdir}/jre
147   install -dm 755 "${pkgdir}${_jvmdir}"
149   cp -a bin lib \
150     "${pkgdir}${_jvmdir}"
152   for f in "${_nonheadless[@]}"; do
153     rm "${pkgdir}${_jvmdir}/${f}"
154   done
156   cp ../jdk/release "${pkgdir}${_jvmdir}"
157   cp ../jdk/lib/modules "${pkgdir}${_jvmdir}/lib"
159   # Conf
160   install -dm 755 "${pkgdir}/etc"
161   cp -r conf "${pkgdir}/etc/${pkgbase}"
162   ln -s /etc/${pkgbase} "${pkgdir}/${_jvmdir}/conf"
164   # Legal
165   install -dm 755 "${pkgdir}/usr/share/licenses"
166   cp -r legal "${pkgdir}/usr/share/licenses/${pkgbase}"
167   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
168   ln -s /usr/share/licenses/${pkgbase} "${pkgdir}/${_jvmdir}/legal"
170   # Man pages
171   for f in bin/*; do
172     f=$(basename "${f}")
173     _man=../jdk/man/man1/"${f}.1"
174     test -f "${_man}" && install -Dm 644 "${_man}" "${pkgdir}/usr/share/man/man1/${f}-openjdk${_majorver}.1"
175   done
176   ln -s /usr/share/man "${pkgdir}/${_jvmdir}/man"
178   # Link JKS keystore from ca-certificates-utils
179   rm -f "${pkgdir}${_jvmdir}/lib/security/cacerts"
180   ln -sf /etc/ssl/certs/java/cacerts "${pkgdir}${_jvmdir}/lib/security/cacerts"
183 package_jre17-openjdk() {
184   pkgdesc="OpenJDK Java ${_majorver} full runtime environment"
185   depends=("jre${_majorver}-openjdk-headless=${pkgver}-${pkgrel}" 'giflib' 'libgif.so'
186            'glibc' 'gcc-libs' 'libpng')
187   optdepends=('alsa-lib: for basic sound support'
188               'gtk2: for the Gtk+ 2 look and feel - desktop usage'
189               'gtk3: for the Gtk+ 3 look and feel - desktop usage')
190   provides=("java-runtime=${_majorver}" "java-runtime-openjdk=${_majorver}" "jre${_majorver}-openjdk=${pkgver}-${pkgrel}")
191   install=install_jre-openjdk.sh
193   cd ${_imgdir}/jre
195   install -dm 755 "${pkgdir}${_jvmdir}"
197   for f in "${_nonheadless[@]}"; do
198     install -Dm 644 ${f} "${pkgdir}${_jvmdir}/${f}"
199   done
201   # Licenses
202   install -dm 755 "${pkgdir}/usr/share/licenses"
203   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
206 package_jdk17-openjdk() {
207   pkgdesc="OpenJDK Java ${_majorver} development kit"
208   depends=("jre${_majorver}-openjdk=${pkgver}-${pkgrel}" 'java-environment-common=3'
209            'hicolor-icon-theme' 'libelf' 'glibc' 'gcc-libs')
210   provides=("java-environment=${_majorver}" "java-environment-openjdk=${_majorver}" "jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
211   install=install_jdk-openjdk.sh
213   cd ${_imgdir}/jdk
215   install -dm 755 "${pkgdir}${_jvmdir}"
217   cp -a bin demo include jmods lib \
218     "${pkgdir}${_jvmdir}"
220   rm "${pkgdir}${_jvmdir}/lib/src.zip"
222   # Remove files held by JRE
223   pushd ../jre
224   for d in bin lib; do
225     find ${d} ! -type d -exec rm "${pkgdir}${_jvmdir}/{}" \;
226   done
227   popd
228   find "${pkgdir}${_jvmdir}/lib" -type d -empty -delete
230   # Conf files all belong to JRE
232   # Legal
233   install -dm 755 "${pkgdir}/usr/share/licenses"
234   cp -r legal "${pkgdir}/usr/share/licenses/${pkgbase}"
235   pushd ../jre/legal
236   find . ! -type d -exec rm "${pkgdir}/usr/share/licenses/${pkgbase}/{}" \;
237   popd
238   find "${pkgdir}/usr/share/licenses" -type d -empty -delete
239   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
241   # Man pages
242   for f in bin/*; do
243     f=$(basename "${f}")
244     _man=man/man1/"${f}.1"
245     test -f "../jre/bin/${f}" && continue
246     test -f "${_man}" && install -Dm 644 "${_man}" "${pkgdir}/usr/share/man/man1/${f}-openjdk${_majorver}.1"
247   done
249   # Icons
250   for s in 16 24 32 48; do
251     install -Dm 644 \
252       "${srcdir}/${_jdkdir}/src/java.desktop/unix/classes/sun/awt/X11/java-icon${s}.png" \
253       "${pkgdir}/usr/share/icons/hicolor/${s}x${s}/apps/${pkgbase}.png"
254   done
256   # Desktop files
257   for f in jconsole java jshell; do
258     install -Dm 644 \
259       "${srcdir}/freedesktop-${f}.desktop" \
260       "${pkgdir}/usr/share/applications/${f}-${pkgbase}.desktop"
261   done
264 package_openjdk17-src() {
265   pkgdesc="OpenJDK Java ${_majorver} sources"
266   # Depends on JDK to get license files
267   depends=("jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
268   provides=("openjdk${_majorver}-src=${pkgver}-${pkgrel}")
270   install -Dm 644 -t "${pkgdir}${_jvmdir}/lib" ${_imgdir}/jdk/lib/src.zip
272   install -dm 755 "${pkgdir}/usr/share/licenses"
273   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
276 package_openjdk17-doc() {
277   pkgdesc="OpenJDK Java ${_majorver} documentation"
278   # Depends on JDK to get license files
279   depends=("jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
280   provides=("openjdk${_majorver}-doc=${pkgver}-${pkgrel}")
282   install -dm 755 "${pkgdir}/usr/share/doc"
283   cp -r ${_imgdir}/docs "${pkgdir}/usr/share/doc/${pkgbase}"
285   install -dm 755 "${pkgdir}/usr/share/licenses"
286   ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
289 # vim: ts=2 sw=2 et: