oracle-jdk-bin-1.8.0.121.ebuild 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit eutils java-vm-2 prefix versionator
  5. # This URIs need to be updated when bumping!
  6. JDK_URI="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"
  7. JCE_URI="http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html"
  8. # This is a list of archs supported by this update.
  9. # Currently arm comes and goes.
  10. AT_AVAILABLE=( amd64 arm arm64 x86 x64-solaris sparc64-solaris x64-macos )
  11. # Sometimes some or all of the demos are missing, this is to not have to rewrite half
  12. # the ebuild when it happens.
  13. DEMOS_AVAILABLE=( amd64 arm arm64 x86 x64-solaris sparc64-solaris x64-macos )
  14. if [[ "$(get_version_component_range 4)" == 0 ]] ; then
  15. S_PV="$(get_version_component_range 1-3)"
  16. else
  17. MY_PV_EXT="u$(get_version_component_range 4)"
  18. S_PV="$(get_version_component_range 1-4)"
  19. fi
  20. MY_PV="$(get_version_component_range 2)${MY_PV_EXT}"
  21. AT_amd64="jdk-${MY_PV}-linux-x64.tar.gz"
  22. AT_arm="jdk-${MY_PV}-linux-arm32-vfp-hflt.tar.gz"
  23. AT_arm64="jdk-${MY_PV}-linux-arm64-vfp-hflt.tar.gz"
  24. AT_x86="jdk-${MY_PV}-linux-i586.tar.gz"
  25. AT_x64_solaris="jdk-${MY_PV}-solaris-x64.tar.gz"
  26. AT_sparc64_solaris="${AT_sparc_solaris} jdk-${MY_PV}-solaris-sparcv9.tar.gz"
  27. AT_x64_macos="jdk-${MY_PV}-macosx-x64.dmg"
  28. DEMOS_amd64="jdk-${MY_PV}-linux-x64-demos.tar.gz"
  29. DEMOS_arm="jdk-${MY_PV}-linux-arm32-vfp-hflt-demos.tar.gz"
  30. DEMOS_arm64="jdk-${MY_PV}-linux-arm64-vfp-hflt-demos.tar.gz"
  31. DEMOS_x86="jdk-${MY_PV}-linux-i586-demos.tar.gz"
  32. DEMOS_x64_solaris="jdk-${MY_PV}-solaris-x64-demos.tar.gz"
  33. DEMOS_sparc64_solaris="jdk-${MY_PV}-solaris-sparcv9-demos.tar.gz"
  34. DEMOS_x64_macos="jdk-${MY_PV}-macosx-x86_64-demos.zip"
  35. JCE_DIR="UnlimitedJCEPolicyJDK8"
  36. JCE_FILE="jce_policy-8.zip"
  37. DESCRIPTION="Oracle's Java SE Development Kit"
  38. HOMEPAGE="http://www.oracle.com/technetwork/java/javase/"
  39. for d in "${AT_AVAILABLE[@]}"; do
  40. SRC_URI+=" ${d}? ( $(eval "echo \${$(echo AT_${d/-/_})}")"
  41. if has ${d} "${DEMOS_AVAILABLE[@]}"; then
  42. SRC_URI+=" examples? ( $(eval "echo \${$(echo DEMOS_${d/-/_})}") )"
  43. fi
  44. SRC_URI+=" )"
  45. done
  46. unset d
  47. SRC_URI+=" jce? ( ${JCE_FILE} )"
  48. LICENSE="Oracle-BCLA-JavaSE examples? ( BSD )"
  49. SLOT="1.8"
  50. KEYWORDS="amd64 ~arm ~arm64 x86 ~amd64-linux ~x86-linux ~x64-macos ~sparc64-solaris ~x64-solaris"
  51. IUSE="alsa commercial cups derby doc examples +fontconfig headless-awt javafx jce nsplugin selinux source"
  52. REQUIRED_USE="javafx? ( alsa fontconfig )"
  53. RESTRICT="fetch preserve-libs strip"
  54. QA_PREBUILT="*"
  55. # NOTES:
  56. #
  57. # * cups is dlopened.
  58. #
  59. # * libpng is also dlopened but only by libsplashscreen, which isn't
  60. # important, so we can exclude that.
  61. #
  62. # * We still need to work out the exact AWT and JavaFX dependencies
  63. # under MacOS. It doesn't appear to use many, if any, of the
  64. # dependencies below.
  65. #
  66. RDEPEND="!x64-macos? (
  67. !headless-awt? (
  68. x11-libs/libX11
  69. x11-libs/libXext
  70. x11-libs/libXi
  71. x11-libs/libXrender
  72. x11-libs/libXtst
  73. )
  74. javafx? (
  75. dev-libs/glib:2
  76. dev-libs/libxml2:2
  77. dev-libs/libxslt
  78. media-libs/freetype:2
  79. x11-libs/cairo
  80. x11-libs/gtk+:2
  81. x11-libs/libX11
  82. x11-libs/libXtst
  83. x11-libs/libXxf86vm
  84. x11-libs/pango
  85. virtual/opengl
  86. )
  87. )
  88. alsa? ( media-libs/alsa-lib )
  89. cups? ( net-print/cups )
  90. doc? ( dev-java/java-sdk-docs:${SLOT} )
  91. fontconfig? ( media-libs/fontconfig:1.0 )
  92. !prefix? ( sys-libs/glibc:* )
  93. selinux? ( sec-policy/selinux-java )"
  94. DEPEND="app-arch/zip
  95. jce? ( app-arch/unzip )
  96. examples? ( x64-macos? ( app-arch/unzip ) )"
  97. S="${WORKDIR}/jdk"
  98. check_tarballs_available() {
  99. local uri=$1; shift
  100. local dl= unavailable=
  101. for dl in "${@}" ; do
  102. [[ ! -f "${DISTDIR}/${dl}" ]] && unavailable+=" ${dl}"
  103. done
  104. if [[ -n "${unavailable}" ]] ; then
  105. if [[ -z ${_check_tarballs_available_once} ]] ; then
  106. einfo
  107. einfo "Oracle requires you to download the needed files manually after"
  108. einfo "accepting their license through a javascript capable web browser."
  109. einfo
  110. _check_tarballs_available_once=1
  111. fi
  112. einfo "Download the following files:"
  113. for dl in ${unavailable}; do
  114. einfo " ${dl}"
  115. done
  116. einfo "at '${uri}'"
  117. einfo "and move them to '${DISTDIR}'"
  118. einfo
  119. einfo "If the above mentioned urls do not point to the correct version anymore,"
  120. einfo "please download the files from Oracle's java download archive:"
  121. einfo
  122. einfo " http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-${MY_PV}-oth-JPR"
  123. einfo
  124. fi
  125. }
  126. pkg_nofetch() {
  127. local distfiles=( $(eval "echo \${$(echo AT_${ARCH/-/_})}") )
  128. if use examples && has ${ARCH} "${DEMOS_AVAILABLE[@]}"; then
  129. distfiles+=( $(eval "echo \${$(echo DEMOS_${ARCH/-/_})}") )
  130. fi
  131. check_tarballs_available "${JDK_URI}" "${distfiles[@]}"
  132. use jce && check_tarballs_available "${JCE_URI}" "${JCE_FILE}"
  133. }
  134. src_unpack() {
  135. if use x64-macos ; then
  136. pushd "${T}" > /dev/null || die
  137. mkdir dmgmount || die
  138. hdiutil attach "${DISTDIR}"/jdk-${MY_PV}-macosx-x64.dmg \
  139. -mountpoint "${T}"/dmgmount || die
  140. printf -v update "%02d" $(get_version_component_range 4) || die
  141. xar -xf dmgmount/JDK\ $(get_version_component_range 2)\ Update\ ${update}.pkg || die
  142. hdiutil detach "${T}"/dmgmount || die
  143. zcat jdk1${MY_PV%u*}0${update}.pkg/Payload | cpio -idv || die
  144. mv Contents/Home "${WORKDIR}"/jdk${MY_PV} || die
  145. popd > /dev/null || die
  146. use jce && unpack "${JCE_FILE}"
  147. else
  148. default
  149. fi
  150. # Upstream is changing their versioning scheme every release around 1.8.0.*;
  151. # to stop having to change it over and over again, just wildcard match and
  152. # live a happy life instead of trying to get this new jdk1.8.0_05 to work.
  153. mv "${WORKDIR}"/jdk* "${S}" || die
  154. }
  155. src_prepare() {
  156. if use jce ; then
  157. mv "${WORKDIR}"/${JCE_DIR} jre/lib/security/ || die
  158. fi
  159. default
  160. if [[ -n ${JAVA_PKG_STRICT} ]] ; then
  161. # Mark this binary early to run it now.
  162. pax-mark m ./bin/javap
  163. eqawarn "Ensure that this only calls trackJavaUsage(). If not, see bug #559936."
  164. eqawarn
  165. eqawarn "$(./bin/javap -J-Duser.home=${T} -c sun.misc.PostVMInitHook || die)"
  166. fi
  167. # Remove the hook that calls Oracle's evil usage tracker. Not just
  168. # because it's evil but because it breaks the sandbox during builds
  169. # and we can't find any other feasible way to disable it or make it
  170. # write somewhere else. See bug #559936 for details.
  171. zip -d jre/lib/rt.jar sun/misc/PostVMInitHook.class || die
  172. }
  173. src_install() {
  174. local dest="/opt/${P}"
  175. local ddest="${ED}${dest#/}"
  176. # Create files used as storage for system preferences.
  177. mkdir jre/.systemPrefs || die
  178. touch jre/.systemPrefs/.system.lock || die
  179. touch jre/.systemPrefs/.systemRootModFile || die
  180. if ! use alsa ; then
  181. rm -vf jre/lib/*/libjsoundalsa.* || die
  182. fi
  183. if ! use commercial; then
  184. rm -vfr lib/missioncontrol jre/lib/jfr* || die
  185. fi
  186. if use headless-awt ; then
  187. rm -vf {,jre/}lib/*/lib*{[jx]awt,splashscreen}* \
  188. {,jre/}bin/{javaws,policytool} \
  189. bin/appletviewer || die
  190. fi
  191. if ! use javafx ; then
  192. rm -vf jre/lib/*/lib*{decora,fx,glass,prism}* \
  193. jre/lib/*/libgstreamer-lite.* {,jre/}lib/{,ext/}*fx* \
  194. bin/*javafx* bin/javapackager || die
  195. fi
  196. if ! use nsplugin ; then
  197. rm -vf jre/lib/*/libnpjp2.* || die
  198. else
  199. local nsplugin=$(echo jre/lib/*/libnpjp2.*)
  200. fi
  201. # Even though plugins linked against multiple ffmpeg versions are
  202. # provided, they generally lag behind what Gentoo has available.
  203. rm -vf jre/lib/*/libavplugin* || die
  204. # We package this as dev-util/visualvm.
  205. rm -vfr lib/visualvm || die
  206. dodoc COPYRIGHT
  207. dodir "${dest}"
  208. cp -pPR bin include jre lib man "${ddest}" || die
  209. if use derby ; then
  210. cp -pPR db "${ddest}" || die
  211. fi
  212. if use examples && has ${ARCH} "${DEMOS_AVAILABLE[@]}" ; then
  213. cp -pPR demo sample "${ddest}" || die
  214. fi
  215. if use jce ; then
  216. dodir "${dest}"/jre/lib/security/strong-jce
  217. mv "${ddest}"/jre/lib/security/US_export_policy.jar \
  218. "${ddest}"/jre/lib/security/strong-jce || die
  219. mv "${ddest}"/jre/lib/security/local_policy.jar \
  220. "${ddest}"/jre/lib/security/strong-jce || die
  221. dosym "${dest}"/jre/lib/security/${JCE_DIR}/US_export_policy.jar \
  222. "${dest}"/jre/lib/security/US_export_policy.jar
  223. dosym "${dest}"/jre/lib/security/${JCE_DIR}/local_policy.jar \
  224. "${dest}"/jre/lib/security/local_policy.jar
  225. fi
  226. if use nsplugin ; then
  227. local nsplugin_link=${nsplugin##*/}
  228. nsplugin_link=${nsplugin_link/./-${PN}-${SLOT}.}
  229. dosym "${dest}/${nsplugin}" "/usr/$(get_libdir)/nsbrowser/plugins/${nsplugin_link}"
  230. fi
  231. if use source ; then
  232. cp -v src.zip "${ddest}" || die
  233. if use javafx ; then
  234. cp -v javafx-src.zip "${ddest}" || die
  235. fi
  236. fi
  237. if [[ -d jre/lib/desktop ]] ; then
  238. # Install desktop file for the Java Control Panel.
  239. # Using ${PN}-${SLOT} to prevent file collision with jre and or
  240. # other slots. make_desktop_entry can't be used as ${P} would
  241. # end up in filename.
  242. newicon jre/lib/desktop/icons/hicolor/48x48/apps/sun-jcontrol.png \
  243. sun-jcontrol-${PN}-${SLOT}.png || die
  244. sed -e "s#Name=.*#Name=Java Control Panel for Oracle JDK ${SLOT}#" \
  245. -e "s#Exec=.*#Exec=/opt/${P}/jre/bin/jcontrol#" \
  246. -e "s#Icon=.*#Icon=sun-jcontrol-${PN}-${SLOT}#" \
  247. -e "s#Application;##" \
  248. -e "/Encoding/d" \
  249. jre/lib/desktop/applications/sun_java.desktop \
  250. > "${T}"/jcontrol-${PN}-${SLOT}.desktop || die
  251. domenu "${T}"/jcontrol-${PN}-${SLOT}.desktop
  252. fi
  253. # Prune all fontconfig files so libfontconfig will be used and only install
  254. # a Gentoo specific one if fontconfig is disabled.
  255. # http://docs.oracle.com/javase/8/docs/technotes/guides/intl/fontconfig.html
  256. rm "${ddest}"/jre/lib/fontconfig.* || die
  257. if ! use fontconfig ; then
  258. cp "${FILESDIR}"/fontconfig.Gentoo.properties "${T}"/fontconfig.properties || die
  259. eprefixify "${T}"/fontconfig.properties
  260. insinto "${dest}"/jre/lib/
  261. doins "${T}"/fontconfig.properties
  262. fi
  263. # This needs to be done before CDS - #215225
  264. java-vm_set-pax-markings "${ddest}"
  265. # see bug #207282
  266. einfo "Creating the Class Data Sharing archives"
  267. case ${ARCH} in
  268. arm|ia64)
  269. ${ddest}/bin/java -client -Xshare:dump || die
  270. ;;
  271. x86)
  272. ${ddest}/bin/java -client -Xshare:dump || die
  273. # limit heap size for large memory on x86 #467518
  274. # this is a workaround and shouldn't be needed.
  275. ${ddest}/bin/java -server -Xms64m -Xmx64m -Xshare:dump || die
  276. ;;
  277. *)
  278. ${ddest}/bin/java -server -Xshare:dump || die
  279. ;;
  280. esac
  281. # Remove empty dirs we might have copied.
  282. find "${D}" -type d -empty -exec rmdir -v {} + || die
  283. if use x64-macos ; then
  284. # Fix miscellaneous install_name issues.
  285. local lib
  286. for lib in decora_sse glass prism_{common,es2,sw} ; do
  287. lib=lib${lib}.dylib
  288. einfo "Fixing self-reference of ${lib}"
  289. install_name_tool \
  290. -id "${EPREFIX}${dest}/jre/lib/${lib}" \
  291. "${ddest}"/jre/lib/${lib} || die
  292. done
  293. fi
  294. java-vm_install-env "${FILESDIR}"/${PN}.env.sh
  295. java-vm_revdep-mask
  296. java-vm_sandbox-predict /dev/random /proc/self/coredump_filter
  297. }
  298. pkg_postinst() {
  299. java-vm-2_pkg_postinst
  300. if ! use headless-awt && ! use javafx; then
  301. ewarn "You have disabled the javafx flag. Some modern desktop Java applications"
  302. ewarn "require this and they may fail with a confusing error message."
  303. fi
  304. }