dev-java/icedtea-bin: Revbump 7.2.6.6, I forgot to increase glibc dep
[gentoo.git] / dev-java / oracle-jdk-bin / oracle-jdk-bin-1.8.0.92.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 inherit eutils java-vm-2 prefix versionator
8
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"
12
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 )
16
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 )
20
21 if [[ "$(get_version_component_range 4)" == 0 ]] ; then
22         S_PV="$(get_version_component_range 1-3)"
23 else
24         MY_PV_EXT="u$(get_version_component_range 4)"
25         S_PV="$(get_version_component_range 1-4)"
26 fi
27
28 MY_PV="$(get_version_component_range 2)${MY_PV_EXT}"
29
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"
37
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"
45
46 JCE_DIR="UnlimitedJCEPolicyJDK8"
47 JCE_FILE="jce_policy-8.zip"
48
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/-/_})}") )"
55         fi
56         SRC_URI+=" )"
57 done
58 unset d
59 SRC_URI+=" jce? ( ${JCE_FILE} )"
60
61 LICENSE="Oracle-BCLA-JavaSE examples? ( BSD )"
62 SLOT="1.8"
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 )"
66
67 RESTRICT="fetch preserve-libs strip"
68 QA_PREBUILT="*"
69
70 # NOTES:
71 #
72 # * cups is dlopened.
73 #
74 # * libpng is also dlopened but only by libsplashscreen, which isn't
75 #   important, so we can exclude that.
76 #
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
79 #   dependencies below.
80 #
81 RDEPEND="!x64-macos? (
82                 !headless-awt? (
83                         x11-libs/libX11
84                         x11-libs/libXext
85                         x11-libs/libXi
86                         x11-libs/libXrender
87                         x11-libs/libXtst
88                 )
89                 javafx? (
90                         dev-libs/glib:2
91                         dev-libs/libxml2:2
92                         dev-libs/libxslt
93                         media-libs/freetype:2
94                         x11-libs/cairo
95                         x11-libs/gtk+:2
96                         x11-libs/libX11
97                         x11-libs/libXtst
98                         x11-libs/libXxf86vm
99                         x11-libs/pango
100                         virtual/opengl
101                 )
102         )
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 )"
109
110 # A PaX header isn't created by scanelf so depend on paxctl to avoid
111 # fallback marking. See bug #427642.
112 DEPEND="app-arch/zip
113         jce? ( app-arch/unzip )
114         examples? ( x64-macos? ( app-arch/unzip ) )
115         pax_kernel? ( sys-apps/paxctl )"
116
117 S="${WORKDIR}/jdk"
118
119 check_tarballs_available() {
120         local uri=$1; shift
121         local dl= unavailable=
122         for dl in "${@}" ; do
123                 [[ ! -f "${DISTDIR}/${dl}" ]] && unavailable+=" ${dl}"
124         done
125
126         if [[ -n "${unavailable}" ]] ; then
127                 if [[ -z ${_check_tarballs_available_once} ]] ; then
128                         einfo
129                         einfo "Oracle requires you to download the needed files manually after"
130                         einfo "accepting their license through a javascript capable web browser."
131                         einfo
132                         _check_tarballs_available_once=1
133                 fi
134                 einfo "Download the following files:"
135                 for dl in ${unavailable}; do
136                         einfo "  ${dl}"
137                 done
138                 einfo "at '${uri}'"
139                 einfo "and move them to '${DISTDIR}'"
140                 einfo
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:"
143                 einfo
144                 einfo "   http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-${MY_PV}-oth-JPR"
145                 einfo
146         fi
147 }
148
149 pkg_nofetch() {
150         local distfiles=( $(eval "echo \${$(echo AT_${ARCH/-/_})}") )
151         if use examples && has ${ARCH} "${DEMOS_AVAILABLE[@]}"; then
152                 distfiles+=( $(eval "echo \${$(echo DEMOS_${ARCH/-/_})}") )
153         fi
154         check_tarballs_available "${JDK_URI}" "${distfiles[@]}"
155
156         use jce && check_tarballs_available "${JCE_URI}" "${JCE_FILE}"
157 }
158
159 src_unpack() {
160         if use x64-macos ; then
161                 pushd "${T}" > /dev/null
162                 mkdir dmgmount
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}
171                 popd > /dev/null
172                 use jce && unpack "${JCE_FILE}"
173         else
174                 default
175         fi
176
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
181 }
182
183 src_prepare() {
184         if use jce ; then
185                 mv "${WORKDIR}"/${JCE_DIR} jre/lib/security/ || die
186         fi
187
188         if [[ -n ${JAVA_PKG_STRICT} ]] ; then
189                 # Mark this binary early to run it now.
190                 pax-mark Cm ./bin/javap
191
192                 eqawarn "Ensure that this only calls trackJavaUsage(). If not, see bug #559936."
193                 eqawarn
194                 eqawarn "$(./bin/javap -J-Duser.home=${T} -c sun.misc.PostVMInitHook || die)"
195         fi
196
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
202 }
203
204 src_install() {
205         local dest="/opt/${P}"
206         local ddest="${ED}${dest#/}"
207
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
212
213         if ! use alsa ; then
214                 rm -vf jre/lib/*/libjsoundalsa.* || die
215         fi
216
217         if use headless-awt ; then
218                 rm -vf {,jre/}lib/*/lib*{[jx]awt,splashscreen}* \
219                    {,jre/}bin/{javaws,policytool} \
220                    bin/appletviewer || die
221         fi
222
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
227         fi
228
229         if ! use nsplugin ; then
230                 rm -vf jre/lib/*/libnpjp2.* || die
231         else
232                 local nsplugin=$(echo jre/lib/*/libnpjp2.*)
233         fi
234
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
238
239         dodoc COPYRIGHT
240         dodir "${dest}"
241         cp -pPR bin include jre lib man "${ddest}" || die
242
243         if use derby ; then
244                 cp -pPR db "${ddest}" || die
245         fi
246
247         if use examples && has ${ARCH} "${DEMOS_AVAILABLE[@]}" ; then
248                 cp -pPR demo sample "${ddest}" || die
249         fi
250
251         if use jce ; then
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
261         fi
262
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}"
267         fi
268
269         if use source ; then
270                 cp -v src.zip "${ddest}" || die
271
272                 if use javafx ; then
273                         cp -v javafx-src.zip "${ddest}" || die
274                 fi
275         fi
276
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;##" \
288                         -e "/Encoding/d" \
289                         jre/lib/desktop/applications/sun_java.desktop \
290                         > "${T}"/jcontrol-${PN}-${SLOT}.desktop || die
291                 domenu "${T}"/jcontrol-${PN}-${SLOT}.desktop
292         fi
293
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
303         fi
304
305         # This needs to be done before CDS - #215225
306         java-vm_set-pax-markings "${ddest}"
307
308         # see bug #207282
309         einfo "Creating the Class Data Sharing archives"
310         case ${ARCH} in
311                 arm|ia64)
312                         ${ddest}/bin/java -client -Xshare:dump || die
313                         ;;
314                 x86)
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
319                         ;;
320                 *)
321                         ${ddest}/bin/java -server -Xshare:dump || die
322                         ;;
323         esac
324
325         # Remove empty dirs we might have copied.
326         find "${D}" -type d -empty -exec rmdir -v {} + || die
327
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
333                         lib=lib${lib}.dylib
334                         einfo "Fixing self-reference of ${lib}"
335                         install_name_tool \
336                                 -id "${EPREFIX}${dest}/jre/lib/${lib}" \
337                                 "${lib}"
338                 done
339                 popd > /dev/null
340
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
351                 done
352         fi
353
354         set_java_env
355         java-vm_revdep-mask
356         java-vm_sandbox-predict /dev/random /proc/self/coredump_filter
357 }
358
359 pkg_postinst() {
360         java-vm-2_pkg_postinst
361
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."
365         fi
366 }