You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
3.5 KiB

  1. # Copyright 1999-2021 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit java-vm-2 toolchain-funcs
  5. abi_uri() {
  6. local os=linux
  7. case ${2} in
  8. *-macos) os=mac ;;
  9. *-solaris) os=solaris ;;
  10. esac
  11. echo "${2-$1}? (
  12. https://github.com/adoptium/temurin${SLOT}-binaries/releases/download/jdk-${MY_PV}/OpenJDK${SLOT}U-jdk_${1}_${os}_hotspot_${MY_PV//+/_}.tar.gz
  13. )"
  14. }
  15. MY_PV=${PV/_p/+}
  16. SLOT=${MY_PV%%[.+]*}
  17. SRC_URI="
  18. $(abi_uri arm)
  19. $(abi_uri aarch64 arm64)
  20. $(abi_uri ppc64le ppc64)
  21. $(abi_uri x64 amd64)
  22. $(abi_uri x64 x64-macos)
  23. "
  24. DESCRIPTION="Prebuilt Java JDK binaries provided by Eclipse Temurin"
  25. HOMEPAGE="https://adoptium.net"
  26. LICENSE="GPL-2-with-classpath-exception"
  27. KEYWORDS="amd64 ~arm arm64 ~ppc64 ~x64-macos"
  28. IUSE="alsa cups +gentoo-vm headless-awt selinux source"
  29. RDEPEND="
  30. >=sys-apps/baselayout-java-0.1.0-r1
  31. kernel_linux? (
  32. media-libs/fontconfig:1.0
  33. media-libs/freetype:2
  34. media-libs/harfbuzz
  35. >=sys-libs/glibc-2.2.5:*
  36. sys-libs/zlib
  37. alsa? ( media-libs/alsa-lib )
  38. cups? ( net-print/cups )
  39. selinux? ( sec-policy/selinux-java )
  40. !headless-awt? (
  41. x11-libs/libX11
  42. x11-libs/libXext
  43. x11-libs/libXi
  44. x11-libs/libXrender
  45. x11-libs/libXtst
  46. )
  47. )"
  48. RESTRICT="preserve-libs splitdebug"
  49. QA_PREBUILT="*"
  50. S="${WORKDIR}/jdk-${MY_PV}"
  51. pkg_pretend() {
  52. if [[ "$(tc-is-softfloat)" != "no" ]]; then
  53. die "These binaries require a hardfloat system."
  54. fi
  55. }
  56. src_unpack() {
  57. default
  58. if [[ ${A} == *_mac_* ]] ; then
  59. mv -v "${S}/Contents/Home/"* "${S}" || die
  60. rm -Rf "${S}/Contents" # drop macOS executable
  61. fi
  62. }
  63. src_install() {
  64. local dest="/opt/${P}"
  65. local ddest="${ED%/}/${dest#/}"
  66. # on macOS if they would exist they would be called .dylib, but most
  67. # importantly, there are no different providers, so everything
  68. # that's shipped works.
  69. if [[ ${A} != *_mac_* ]] ; then
  70. # Not sure why they bundle this as it's commonly available and they
  71. # only do so on x86_64. It's needed by libfontmanager.so. IcedTea
  72. # also has an explicit dependency while Oracle seemingly dlopens it.
  73. rm -vf lib/libfreetype.so || die
  74. # prefer system copy # https://bugs.gentoo.org/776676
  75. rm -vf lib/libharfbuzz.so || die
  76. # Oracle and IcedTea have libjsoundalsa.so depending on
  77. # libasound.so.2 but AdoptOpenJDK only has libjsound.so. Weird.
  78. if ! use alsa ; then
  79. rm -v lib/libjsound.* || die
  80. fi
  81. if use headless-awt ; then
  82. rm -v lib/lib*{[jx]awt,splashscreen}* || die
  83. fi
  84. fi
  85. if ! use source ; then
  86. rm -v lib/src.zip || die
  87. fi
  88. rm -v lib/security/cacerts || die
  89. dosym ../../../../etc/ssl/certs/java/cacerts \
  90. "${dest}"/lib/security/cacerts
  91. dodir "${dest}"
  92. cp -pPR * "${ddest}" || die
  93. # provide stable symlink
  94. dosym "${P}" "/opt/${PN}-${SLOT}"
  95. use gentoo-vm && java-vm_install-env "${FILESDIR}"/${PN}-${SLOT}.env.sh
  96. java-vm_set-pax-markings "${ddest}"
  97. java-vm_revdep-mask
  98. java-vm_sandbox-predict /dev/random /proc/self/coredump_filter
  99. }
  100. pkg_postinst() {
  101. java-vm-2_pkg_postinst
  102. if use gentoo-vm ; then
  103. ewarn "WARNING! You have enabled the gentoo-vm USE flag, making this JDK"
  104. ewarn "recognised by the system. This will almost certainly break"
  105. ewarn "many java ebuilds as they are not ready for openjdk-11"
  106. else
  107. ewarn "The experimental gentoo-vm USE flag has not been enabled so this JDK"
  108. ewarn "will not be recognised by the system. For example, simply calling"
  109. ewarn "\"java\" will launch a different JVM. This is necessary until Gentoo"
  110. ewarn "fully supports Java 11. This JDK must therefore be invoked using its"
  111. ewarn "absolute location under ${EPREFIX}/opt/${P}."
  112. fi
  113. }