PKGBUILD 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. # Maintainer: Noah Vogt (noahvogt) <noah@noahvogt.com>
  2. # Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
  3. # Maintainer: Guillaume ALAUX <guillaume@archlinux.org>
  4. # TODO add test, see about packaging jtreg and using it here
  5. pkgbase=java-openjdk-xdg
  6. pkgname=('jre-openjdk-headless-xdg' 'jre-openjdk-xdg' 'jdk-openjdk-xdg' 'openjdk-src-xdg' 'openjdk-doc-xdg')
  7. _majorver=17
  8. _minorver=0
  9. _securityver=3
  10. _updatever=3
  11. pkgrel=1
  12. pkgver=${_majorver}.${_minorver}.${_securityver}.u${_updatever}
  13. #pkgver=${_majorver}.u${_updatever}
  14. _git_tag=jdk-${_majorver}.${_minorver}.${_securityver}+${_updatever}
  15. #_git_tag=jdk-${_majorver}+${_updatever}
  16. arch=('x86_64')
  17. url='https://openjdk.java.net/'
  18. license=('custom')
  19. makedepends=('java-environment>=11' 'cpio' 'unzip' 'zip' 'libelf' 'libcups' 'libx11'
  20. 'libxrender' 'libxtst' 'libxt' 'libxext' 'libxrandr' 'alsa-lib' 'pandoc'
  21. 'graphviz' 'freetype2' 'libjpeg-turbo' 'giflib' 'libpng' 'lcms2'
  22. 'libnet' 'bash' 'harfbuzz' 'gcc-libs' 'glibc')
  23. options=(!lto)
  24. source=(https://github.com/openjdk/jdk${_majorver}u/archive/${_git_tag}.tar.gz
  25. freedesktop-java.desktop
  26. freedesktop-jconsole.desktop
  27. freedesktop-jshell.desktop
  28. xdg-basedir-compliant-fontconfig.patch
  29. xdg-basedir-compliant-userPrefs.patch)
  30. sha256sums=('f985bc954c50b9c09d1f8fab698b6591cc46ce3ef6a18570aa192567ff661ca0'
  31. '85c4742764590783160af74587a47269e6797fbdf17ec485c7644bd239adf61d'
  32. 'abac1ab09a33a3654378bc69be5a7cf075263ab3ae9efec1eb25cf388e711bb7'
  33. 'e7cce0ecf868f656d8dc2eb25ab82ab665526a0a28aba20f02632dd29962dac3'
  34. '25860396475759236e0edf66711b842143b0ddee47eed61e080da158bbc58ce9'
  35. '48f9e40c4ae8eb79d17fb676893a89b95ac43616827725a9d10de2b1f357642c')
  36. provides=('jre-openjdk-headless' 'jre-openjdk' 'jdk-openjdk' 'openjdk-src' 'openjdk-doc')
  37. conflicts=('jre-openjdk-headless' 'jre-openjdk' 'jdk-openjdk' 'openjdk-src' 'openjdk-doc')
  38. case "${CARCH}" in
  39. x86_64) _JARCH='x86_64';;
  40. i686) _JARCH='x86';;
  41. esac
  42. _jvmdir=/usr/lib/jvm/java-${_majorver}-openjdk
  43. _jdkdir=jdk${_majorver}u-${_git_tag//+/-}
  44. _imgdir=${_jdkdir}/build/linux-${_JARCH}-server-release/images
  45. _nonheadless=(lib/libawt_xawt.{so,debuginfo}
  46. lib/libjawt.{so,debuginfo}
  47. lib/libjsound.{so,debuginfo}
  48. lib/libsplashscreen.{so,debuginfo})
  49. prepare() {
  50. cd ${_jdkdir}
  51. patch -p1 -i ../xdg-basedir-compliant-fontconfig.patch
  52. patch -p1 -i ../xdg-basedir-compliant-userPrefs.patch
  53. }
  54. build() {
  55. cd ${_jdkdir}
  56. # export old flags to avoid zlist fail with hotspot agent (used in artix)
  57. export CPPFLAGS="-D_FORTIFY_SOURCE=2"
  58. export CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt"
  59. export CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt"
  60. NUM_PROC_OPT=''
  61. MAKEFLAG_J=$(echo ${MAKEFLAGS} | sed -En 's/.*-j([0-9]+).*/\1/p')
  62. if [ -n "${MAKEFLAG_J}" ]; then
  63. # http://hg.openjdk.java.net/jdk10/jdk10/file/85e6cb013b98/make/InitSupport.gmk#l105
  64. echo "Removing '-j${MAKEFLAG_J}' from MAKEFLAGS to prevent build fail. Passing it directly to ./configure."
  65. export MAKEFLAGS=${MAKEFLAGS/-j${MAKEFLAG_J}/}
  66. NUM_PROC_OPT="--with-num-cores=${MAKEFLAG_J}"
  67. fi
  68. # Avoid optimization of HotSpot to be lowered from O3 to O2
  69. local _CFLAGS="${CFLAGS//-O2/-O3} ${CPPFLAGS} -fcommon"
  70. local _CXXFLAGS="${CXXFLAGS//-O2/-O3} ${CPPFLAGS} -fcommon"
  71. local _LDFLAGS=${LDFLAGS}
  72. if [[ ${CARCH} = i686 ]]; then
  73. echo "Removing '-fno-plt' from CFLAGS and CXXFLAGS to prevent build fail with this architecture"
  74. _CFLAGS=${CFLAGS/-fno-plt/}
  75. _CXXFLAGS=${CXXFLAGS/-fno-plt/}
  76. 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/}
  84. # CFLAGS, CXXFLAGS and LDFLAGS are ignored as shown by a warning
  85. # in the output of ./configure unless used like such:
  86. # --with-extra-cflags="${CFLAGS}"
  87. # --with-extra-cxxflags="${CXXFLAGS}"
  88. # --with-extra-ldflags="${LDFLAGS}"
  89. # See also paragraph "Configure Control Variables from "jdk${_majorver}-${_git_tag}/common/doc/building.md
  90. unset CFLAGS
  91. unset CXXFLAGS
  92. unset LDFLAGS
  93. bash configure \
  94. --with-version-build="${_updatever}" \
  95. --with-version-pre="" \
  96. --with-version-opt="" \
  97. --with-stdc++lib=dynamic \
  98. --with-extra-cflags="${_CFLAGS}" \
  99. --with-extra-cxxflags="${_CXXFLAGS}" \
  100. --with-extra-ldflags="${_LDFLAGS}" \
  101. --with-libjpeg=system \
  102. --with-giflib=system \
  103. --with-libpng=system \
  104. --with-lcms=system \
  105. --with-zlib=system \
  106. --with-harfbuzz=system \
  107. --with-jvm-features=zgc \
  108. --enable-unlimited-crypto \
  109. --disable-warnings-as-errors \
  110. ${NUM_PROC_OPT}
  111. #--disable-javac-server
  112. make images legacy-jre-image docs
  113. # https://bugs.openjdk.java.net/browse/JDK-8173610
  114. find "../${_imgdir}" -iname '*.so' -exec chmod +x {} \;
  115. }
  116. check() {
  117. cd ${_jdkdir}
  118. # TODO package jtreg
  119. # make -k check
  120. }
  121. package_jre-openjdk-headless-xdg() {
  122. pkgdesc="OpenJDK Java ${_majorver} headless runtime environment - with improved Support for the XDG Base Directory Specification"
  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
  143. cd ${_imgdir}/jre
  144. install -dm 755 "${pkgdir}${_jvmdir}"
  145. cp -a bin lib \
  146. "${pkgdir}${_jvmdir}"
  147. for f in "${_nonheadless[@]}"; do
  148. rm "${pkgdir}${_jvmdir}/${f}"
  149. done
  150. cp ../jdk/release "${pkgdir}${_jvmdir}"
  151. cp ../jdk/lib/modules "${pkgdir}${_jvmdir}/lib"
  152. # Conf
  153. install -dm 755 "${pkgdir}/etc"
  154. cp -r conf "${pkgdir}/etc/${pkgbase}"
  155. ln -s /etc/${pkgbase} "${pkgdir}/${_jvmdir}/conf"
  156. # Legal
  157. install -dm 755 "${pkgdir}/usr/share/licenses"
  158. cp -r legal "${pkgdir}/usr/share/licenses/${pkgbase}"
  159. ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
  160. ln -s /usr/share/licenses/${pkgbase} "${pkgdir}/${_jvmdir}/legal"
  161. # Man pages
  162. for f in bin/*; do
  163. f=$(basename "${f}")
  164. _man=../jdk/man/man1/"${f}.1"
  165. test -f "${_man}" && install -Dm 644 "${_man}" "${pkgdir}/usr/share/man/man1/${f}-openjdk${_majorver}.1"
  166. done
  167. ln -s /usr/share/man "${pkgdir}/${_jvmdir}/man"
  168. # Link JKS keystore from ca-certificates-utils
  169. rm -f "${pkgdir}${_jvmdir}/lib/security/cacerts"
  170. ln -sf /etc/ssl/certs/java/cacerts "${pkgdir}${_jvmdir}/lib/security/cacerts"
  171. }
  172. package_jre-openjdk-xdg() {
  173. pkgdesc="OpenJDK Java ${_majorver} full runtime environment - with improved Support for the XDG Base Directory Specification"
  174. depends=("jre${_majorver}-openjdk-headless=${pkgver}-${pkgrel}" 'giflib' 'libgif.so'
  175. 'glibc' 'gcc-libs' 'libpng')
  176. optdepends=('alsa-lib: for basic sound support'
  177. 'gtk2: for the Gtk+ 2 look and feel - desktop usage'
  178. 'gtk3: for the Gtk+ 3 look and feel - desktop usage')
  179. provides=("java-runtime=${_majorver}" "java-runtime-openjdk=${_majorver}" "jre${_majorver}-openjdk=${pkgver}-${pkgrel}")
  180. install=install_jre-openjdk.sh
  181. cd ${_imgdir}/jre
  182. install -dm 755 "${pkgdir}${_jvmdir}"
  183. for f in "${_nonheadless[@]}"; do
  184. install -Dm 644 ${f} "${pkgdir}${_jvmdir}/${f}"
  185. done
  186. # Licenses
  187. install -dm 755 "${pkgdir}/usr/share/licenses"
  188. ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
  189. }
  190. package_jdk-openjdk-xdg() {
  191. pkgdesc="OpenJDK Java ${_majorver} development kit - with improved Support for the XDG Base Directory Specification"
  192. depends=("jre${_majorver}-openjdk=${pkgver}-${pkgrel}" 'java-environment-common=3'
  193. 'hicolor-icon-theme' 'libelf' 'glibc' 'gcc-libs')
  194. provides=("java-environment=${_majorver}" "java-environment-openjdk=${_majorver}" "jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
  195. install=install_jdk-openjdk.sh
  196. cd ${_imgdir}/jdk
  197. install -dm 755 "${pkgdir}${_jvmdir}"
  198. cp -a bin demo include jmods lib \
  199. "${pkgdir}${_jvmdir}"
  200. rm "${pkgdir}${_jvmdir}/lib/src.zip"
  201. # Remove files held by JRE
  202. pushd ../jre
  203. for d in bin lib; do
  204. find ${d} ! -type d -exec rm "${pkgdir}${_jvmdir}/{}" \;
  205. done
  206. popd
  207. find "${pkgdir}${_jvmdir}/lib" -type d -empty -delete
  208. # Conf files all belong to JRE
  209. # Legal
  210. install -dm 755 "${pkgdir}/usr/share/licenses"
  211. cp -r legal "${pkgdir}/usr/share/licenses/${pkgbase}"
  212. pushd ../jre/legal
  213. find . ! -type d -exec rm "${pkgdir}/usr/share/licenses/${pkgbase}/{}" \;
  214. popd
  215. find "${pkgdir}/usr/share/licenses" -type d -empty -delete
  216. ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
  217. # Man pages
  218. for f in bin/*; do
  219. f=$(basename "${f}")
  220. _man=man/man1/"${f}.1"
  221. test -f "../jre/bin/${f}" && continue
  222. test -f "${_man}" && install -Dm 644 "${_man}" "${pkgdir}/usr/share/man/man1/${f}-openjdk${_majorver}.1"
  223. done
  224. # Icons
  225. for s in 16 24 32 48; do
  226. install -Dm 644 \
  227. "${srcdir}/${_jdkdir}/src/java.desktop/unix/classes/sun/awt/X11/java-icon${s}.png" \
  228. "${pkgdir}/usr/share/icons/hicolor/${s}x${s}/apps/${pkgbase}.png"
  229. done
  230. # Desktop files
  231. for f in jconsole java jshell; do
  232. install -Dm 644 \
  233. "${srcdir}/freedesktop-${f}.desktop" \
  234. "${pkgdir}/usr/share/applications/${f}-${pkgbase}.desktop"
  235. done
  236. }
  237. package_openjdk-src-xdg() {
  238. pkgdesc="OpenJDK Java ${_majorver} sources - with improved Support for the XDG Base Directory Specification"
  239. # Depends on JDK to get license files
  240. depends=("jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
  241. provides=("openjdk${_majorver}-src=${pkgver}-${pkgrel}")
  242. install -Dm 644 -t "${pkgdir}${_jvmdir}/lib" ${_imgdir}/jdk/lib/src.zip
  243. install -dm 755 "${pkgdir}/usr/share/licenses"
  244. ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
  245. }
  246. package_openjdk-doc-xdg() {
  247. pkgdesc="OpenJDK Java ${_majorver} documentation - with improved Support for the XDG Base Directory Specification"
  248. # Depends on JDK to get license files
  249. depends=("jdk${_majorver}-openjdk=${pkgver}-${pkgrel}")
  250. provides=("openjdk${_majorver}-doc=${pkgver}-${pkgrel}")
  251. install -dm 755 "${pkgdir}/usr/share/doc"
  252. cp -r ${_imgdir}/docs "${pkgdir}/usr/share/doc/${pkgbase}"
  253. install -dm 755 "${pkgdir}/usr/share/licenses"
  254. ln -s ${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
  255. }
  256. # vim: ts=2 sw=2 et: