1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils java-vm-2 prefix versionator
9 # This URIs need to be updated when bumping!
10 JDK_URI="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"
11 JCE_URI="http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html"
13 # This is a list of archs supported by this update.
14 # Currently arm comes and goes.
15 AT_AVAILABLE=( amd64 x86 x64-solaris sparc64-solaris x64-macos )
17 # Sometimes some or all of the demos are missing, this is to not have to rewrite half
18 # the ebuild when it happens.
19 DEMOS_AVAILABLE=( amd64 x86 x64-solaris sparc64-solaris x64-macos )
21 if [[ "$(get_version_component_range 4)" == 0 ]] ; then
22 S_PV="$(get_version_component_range 1-3)"
24 MY_PV_EXT="u$(get_version_component_range 4)"
25 S_PV="$(get_version_component_range 1-4)"
28 MY_PV="$(get_version_component_range 2)${MY_PV_EXT}"
30 AT_amd64="jdk-${MY_PV}-linux-x64.tar.gz"
31 AT_arm="jdk-${MY_PV}-linux-arm32-vfp-hflt.tar.gz"
32 AT_arm64="jdk-${MY_PV}-linux-arm64-vfp-hflt.tar.gz"
33 AT_x86="jdk-${MY_PV}-linux-i586.tar.gz"
34 AT_x64_solaris="jdk-${MY_PV}-solaris-x64.tar.gz"
35 AT_sparc64_solaris="${AT_sparc_solaris} jdk-${MY_PV}-solaris-sparcv9.tar.gz"
36 AT_x64_macos="jdk-${MY_PV}-macosx-x64.dmg"
38 DEMOS_amd64="jdk-${MY_PV}-linux-x64-demos.tar.gz"
39 DEMOS_arm="jdk-${MY_PV}-linux-arm32-vfp-hflt-demos.tar.gz"
40 DEMOS_arm64="jdk-${MY_PV}-linux-arm64-vfp-hflt-demos.tar.gz"
41 DEMOS_x86="jdk-${MY_PV}-linux-i586-demos.tar.gz"
42 DEMOS_x64_solaris="jdk-${MY_PV}-solaris-x64-demos.tar.gz"
43 DEMOS_sparc64_solaris="jdk-${MY_PV}-solaris-sparcv9-demos.tar.gz"
44 DEMOS_x64_macos="jdk-${MY_PV}-macosx-x86_64-demos.zip"
46 JCE_DIR="UnlimitedJCEPolicyJDK8"
47 JCE_FILE="jce_policy-8.zip"
49 DESCRIPTION="Oracle's Java SE Development Kit"
50 HOMEPAGE="http://www.oracle.com/technetwork/java/javase/"
51 for d in "${AT_AVAILABLE[@]}"; do
52 SRC_URI+=" ${d}? ( $(eval "echo \${$(echo AT_${d/-/_})}")"
53 if has ${d} "${DEMOS_AVAILABLE[@]}"; then
54 SRC_URI+=" examples? ( $(eval "echo \${$(echo DEMOS_${d/-/_})}") )"
59 SRC_URI+=" jce? ( ${JCE_FILE} )"
61 LICENSE="Oracle-BCLA-JavaSE examples? ( BSD )"
63 KEYWORDS="amd64 x86 ~amd64-linux ~x86-linux ~x64-macos ~sparc64-solaris ~x64-solaris"
64 IUSE="alsa cups derby doc examples +fontconfig headless-awt javafx jce nsplugin pax_kernel selinux source"
65 REQUIRED_USE="javafx? ( alsa fontconfig )"
67 RESTRICT="fetch preserve-libs strip"
74 # * libpng is also dlopened but only by libsplashscreen, which isn't
75 # important, so we can exclude that.
77 # * We still need to work out the exact AWT and JavaFX dependencies
78 # under MacOS. It doesn't appear to use many, if any, of the
81 RDEPEND="!x64-macos? (
103 alsa? ( media-libs/alsa-lib )
104 cups? ( net-print/cups )
105 doc? ( dev-java/java-sdk-docs:${SLOT} )
106 fontconfig? ( media-libs/fontconfig:1.0 )
107 !prefix? ( sys-libs/glibc:* )
108 selinux? ( sec-policy/selinux-java )"
110 # A PaX header isn't created by scanelf so depend on paxctl to avoid
111 # fallback marking. See bug #427642.
113 jce? ( app-arch/unzip )
114 examples? ( x64-macos? ( app-arch/unzip ) )
115 pax_kernel? ( sys-apps/paxctl )"
119 check_tarballs_available() {
121 local dl= unavailable=
122 for dl in "${@}" ; do
123 [[ ! -f "${DISTDIR}/${dl}" ]] && unavailable+=" ${dl}"
126 if [[ -n "${unavailable}" ]] ; then
127 if [[ -z ${_check_tarballs_available_once} ]] ; then
129 einfo "Oracle requires you to download the needed files manually after"
130 einfo "accepting their license through a javascript capable web browser."
132 _check_tarballs_available_once=1
134 einfo "Download the following files:"
135 for dl in ${unavailable}; do
139 einfo "and move them to '${DISTDIR}'"
141 einfo "If the above mentioned urls do not point to the correct version anymore,"
142 einfo "please download the files from Oracle's java download archive:"
144 einfo " http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-${MY_PV}-oth-JPR"
150 local distfiles=( $(eval "echo \${$(echo AT_${ARCH/-/_})}") )
151 if use examples && has ${ARCH} "${DEMOS_AVAILABLE[@]}"; then
152 distfiles+=( $(eval "echo \${$(echo DEMOS_${ARCH/-/_})}") )
154 check_tarballs_available "${JDK_URI}" "${distfiles[@]}"
156 use jce && check_tarballs_available "${JCE_URI}" "${JCE_FILE}"
160 if use x64-macos ; then
161 pushd "${T}" > /dev/null
163 hdiutil attach "${DISTDIR}"/jdk-${MY_PV}-macosx-x64.dmg \
164 -mountpoint "${T}"/dmgmount
165 local update=$(get_version_component_range 4)
166 [[ ${#update} == 1 ]] && update="0${update}"
167 xar -xf dmgmount/JDK\ $(get_version_component_range 2)\ Update\ ${update}.pkg
168 hdiutil detach "${T}"/dmgmount
169 zcat jdk1${MY_PV%u*}0${update}.pkg/Payload | cpio -idv
170 mv Contents/Home "${WORKDIR}"/jdk${MY_PV}
172 use jce && unpack "${JCE_FILE}"
177 # Upstream is changing their versioning scheme every release around 1.8.0.*;
178 # to stop having to change it over and over again, just wildcard match and
179 # live a happy life instead of trying to get this new jdk1.8.0_05 to work.
180 mv "${WORKDIR}"/jdk* "${S}" || die
185 mv "${WORKDIR}"/${JCE_DIR} jre/lib/security/ || die
188 if [[ -n ${JAVA_PKG_STRICT} ]] ; then
189 # Mark this binary early to run it now.
190 pax-mark Cm ./bin/javap
192 eqawarn "Ensure that this only calls trackJavaUsage(). If not, see bug #559936."
194 eqawarn "$(./bin/javap -J-Duser.home=${T} -c sun.misc.PostVMInitHook || die)"
197 # Remove the hook that calls Oracle's evil usage tracker. Not just
198 # because it's evil but because it breaks the sandbox during builds
199 # and we can't find any other feasible way to disable it or make it
200 # write somewhere else. See bug #559936 for details.
201 zip -d jre/lib/rt.jar sun/misc/PostVMInitHook.class || die
205 local dest="/opt/${P}"
206 local ddest="${ED}${dest#/}"
208 # Create files used as storage for system preferences.
209 mkdir jre/.systemPrefs || die
210 touch jre/.systemPrefs/.system.lock || die
211 touch jre/.systemPrefs/.systemRootModFile || die
214 rm -vf jre/lib/*/libjsoundalsa.* || die
217 if use headless-awt ; then
218 rm -vf {,jre/}lib/*/lib*{[jx]awt,splashscreen}* \
219 {,jre/}bin/{javaws,policytool} \
220 bin/appletviewer || die
223 if ! use javafx ; then
224 rm -vf jre/lib/*/lib*{decora,fx,glass,prism}* \
225 jre/lib/*/libgstreamer-lite.* {,jre/}lib/{,ext/}*fx* \
226 bin/*javafx* bin/javapackager || die
229 if ! use nsplugin ; then
230 rm -vf jre/lib/*/libnpjp2.* || die
232 local nsplugin=$(echo jre/lib/*/libnpjp2.*)
235 # Even though plugins linked against multiple ffmpeg versions are
236 # provided, they generally lag behind what Gentoo has available.
237 rm -vf jre/lib/*/libavplugin* || die
241 cp -pPR bin include jre lib man "${ddest}" || die
244 cp -pPR db "${ddest}" || die
247 if use examples && has ${ARCH} "${DEMOS_AVAILABLE[@]}" ; then
248 cp -pPR demo sample "${ddest}" || die
252 dodir "${dest}"/jre/lib/security/strong-jce
253 mv "${ddest}"/jre/lib/security/US_export_policy.jar \
254 "${ddest}"/jre/lib/security/strong-jce || die
255 mv "${ddest}"/jre/lib/security/local_policy.jar \
256 "${ddest}"/jre/lib/security/strong-jce || die
257 dosym "${dest}"/jre/lib/security/${JCE_DIR}/US_export_policy.jar \
258 "${dest}"/jre/lib/security/US_export_policy.jar
259 dosym "${dest}"/jre/lib/security/${JCE_DIR}/local_policy.jar \
260 "${dest}"/jre/lib/security/local_policy.jar
263 if use nsplugin ; then
264 local nsplugin_link=${nsplugin##*/}
265 nsplugin_link=${nsplugin_link/./-${PN}-${SLOT}.}
266 dosym "${dest}/${nsplugin}" "/usr/$(get_libdir)/nsbrowser/plugins/${nsplugin_link}"
270 cp -v src.zip "${ddest}" || die
273 cp -v javafx-src.zip "${ddest}" || die
277 if [[ -d jre/lib/desktop ]] ; then
278 # Install desktop file for the Java Control Panel.
279 # Using ${PN}-${SLOT} to prevent file collision with jre and or
280 # other slots. make_desktop_entry can't be used as ${P} would
281 # end up in filename.
282 newicon jre/lib/desktop/icons/hicolor/48x48/apps/sun-jcontrol.png \
283 sun-jcontrol-${PN}-${SLOT}.png || die
284 sed -e "s#Name=.*#Name=Java Control Panel for Oracle JDK ${SLOT}#" \
285 -e "s#Exec=.*#Exec=/opt/${P}/jre/bin/jcontrol#" \
286 -e "s#Icon=.*#Icon=sun-jcontrol-${PN}-${SLOT}#" \
287 -e "s#Application;##" \
289 jre/lib/desktop/applications/sun_java.desktop \
290 > "${T}"/jcontrol-${PN}-${SLOT}.desktop || die
291 domenu "${T}"/jcontrol-${PN}-${SLOT}.desktop
294 # Prune all fontconfig files so libfontconfig will be used and only install
295 # a Gentoo specific one if fontconfig is disabled.
296 # http://docs.oracle.com/javase/8/docs/technotes/guides/intl/fontconfig.html
297 rm "${ddest}"/jre/lib/fontconfig.*
298 if ! use fontconfig ; then
299 cp "${FILESDIR}"/fontconfig.Gentoo.properties "${T}"/fontconfig.properties || die
300 eprefixify "${T}"/fontconfig.properties
301 insinto "${dest}"/jre/lib/
302 doins "${T}"/fontconfig.properties
305 # This needs to be done before CDS - #215225
306 java-vm_set-pax-markings "${ddest}"
309 einfo "Creating the Class Data Sharing archives"
312 ${ddest}/bin/java -client -Xshare:dump || die
315 ${ddest}/bin/java -client -Xshare:dump || die
316 # limit heap size for large memory on x86 #467518
317 # this is a workaround and shouldn't be needed.
318 ${ddest}/bin/java -server -Xms64m -Xmx64m -Xshare:dump || die
321 ${ddest}/bin/java -server -Xshare:dump || die
325 # Remove empty dirs we might have copied.
326 find "${D}" -type d -empty -exec rmdir -v {} + || die
328 if use x64-macos ; then
329 # Fix miscellaneous install_name issues.
330 pushd "${ddest}"/jre/lib > /dev/null || die
331 local lib needed nlib npath
332 for lib in decora_sse glass prism_{common,es2,sw} ; do
334 einfo "Fixing self-reference of ${lib}"
336 -id "${EPREFIX}${dest}/jre/lib/${lib}" \
341 # This is still jdk1{5,6}, even on Java 8, so don't change it
342 # until you know different.
343 for nlib in jdk1{5,6} ; do
344 install_name_tool -change \
345 /usr/lib/libgcc_s_ppc64.1.dylib \
346 /usr/lib/libSystem.B.dylib \
347 "${ddest}"/lib/visualvm/profiler/lib/deployed/${nlib}/mac/libprofilerinterface.jnilib
348 install_name_tool -id \
349 "${EPREFIX}${dest}"/lib/visualvm/profiler/lib/deployed/${nlib}/mac/libprofilerinterface.jnilib \
350 "${ddest}"/lib/visualvm/profiler/lib/deployed/${nlib}/mac/libprofilerinterface.jnilib
356 java-vm_sandbox-predict /dev/random /proc/self/coredump_filter
360 java-vm-2_pkg_postinst
362 if ! use headless-awt && ! use javafx; then
363 ewarn "You have disabled the javafx flag. Some modern desktop Java applications"
364 ewarn "require this and they may fail with a confusing error message."