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.7.0.80.ebuild
1 # Copyright 1999-2015 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 MY_PV="$(get_version_component_range 2)u$(get_version_component_range 4)"
10 S_PV="$(replace_version_separator 3 '_')"
11
12 # This URIs need to be updated when bumping!
13 JDK_URI="http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html#jdk-${MY_PV}-oth-JPR"
14 JCE_URI="http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html"
15 # This is a list of archs supported by this update.
16 # Currently arm comes and goes.
17 AT_AVAILABLE=( amd64 x86 x64-solaris x86-solaris sparc-solaris sparc64-solaris x86-macos x64-macos )
18 # Sometimes some or all of the demos are missing, this is to not have to rewrite half
19 # the ebuild when it happens.
20 DEMOS_AVAILABLE=( amd64 x86 x64-solaris x86-solaris sparc-solaris sparc64-solaris x86-macos x64-macos )
21 FX_VERSION="2_2_$(get_version_component_range 4)"
22
23 AT_x86="jdk-${MY_PV}-linux-i586.tar.gz"
24 AT_amd64="jdk-${MY_PV}-linux-x64.tar.gz"
25 AT_arm="jdk-${MY_PV}-linux-arm-vfp-sflt.tar.gz jdk-${MY_PV}-linux-arm-vfp-hflt.tar.gz"
26 AT_x86_solaris="jdk-${MY_PV}-solaris-i586.tar.gz"
27 AT_x64_solaris="${AT_x86_solaris} jdk-${MY_PV}-solaris-x64.tar.gz"
28 AT_sparc_solaris="jdk-${MY_PV}-solaris-sparc.tar.gz"
29 AT_sparc64_solaris="${AT_sparc_solaris} jdk-${MY_PV}-solaris-sparcv9.tar.gz"
30 AT_x86_macos="jdk-${MY_PV}-macosx-x64.dmg"
31 AT_x64_macos="jdk-${MY_PV}-macosx-x64.dmg"
32
33 FXDEMOS_linux="javafx_samples-${FX_VERSION}-linux.zip"
34
35 DEMOS_x86="${FXDEMOS_linux} jdk-${MY_PV}-linux-i586-demos.tar.gz"
36 DEMOS_amd64="${FXDEMOS_linux} jdk-${MY_PV}-linux-x64-demos.tar.gz"
37 DEMOS_arm="${FXDEMOS_linux} jdk-${MY_PV}-linux-arm-vfp-sflt-demos.tar.gz jdk-${MY_PV}-linux-arm-vfp-hflt-demos.tar.gz"
38 DEMOS_x86_solaris="jdk-${MY_PV}-solaris-i586-demos.tar.gz"
39 DEMOS_x64_solaris="${DEMOS_x86_solaris} jdk-${MY_PV}-solaris-x64-demos.tar.gz"
40 DEMOS_sparc_solaris="jdk-${MY_PV}-solaris-sparc-demos.tar.gz"
41 DEMOS_sparc64_solaris="${DEMOS_sparc_solaris} jdk-${MY_PV}-solaris-sparcv9-demos.tar.gz"
42 DEMOS_x86_macos="jdk-${MY_PV}-macosx-x86_64-demos.tar.gz"
43 DEMOS_x64_macos="jdk-${MY_PV}-macosx-x86_64-demos.tar.gz"
44
45 JCE_DIR="UnlimitedJCEPolicy"
46 JCE_FILE="${JCE_DIR}JDK7.zip"
47
48 DESCRIPTION="Oracle's Java SE Development Kit"
49 HOMEPAGE="http://www.oracle.com/technetwork/java/javase/"
50 for d in "${AT_AVAILABLE[@]}"; do
51         SRC_URI+=" ${d}? ("
52         SRC_URI+=" $(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.7"
63 KEYWORDS="amd64 x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
64 IUSE="+X alsa aqua derby doc examples +fontconfig jce nsplugin pax_kernel selinux source"
65
66 RESTRICT="fetch strip"
67 QA_PREBUILT="*"
68
69 COMMON_DEP=""
70 RDEPEND="${COMMON_DEP}
71         X? ( !aqua? (
72                 x11-libs/libX11
73                 x11-libs/libXext
74                 x11-libs/libXi
75                 x11-libs/libXrender
76                 x11-libs/libXtst
77         ) )
78         alsa? ( media-libs/alsa-lib )
79         doc? ( dev-java/java-sdk-docs:1.7 )
80         fontconfig? ( media-libs/fontconfig )
81         !prefix? ( sys-libs/glibc )
82         selinux? ( sec-policy/selinux-java )"
83 # scanelf won't create a PaX header, so depend on paxctl to avoid fallback
84 # marking. #427642
85 DEPEND="${COMMON_DEP}
86         jce? ( app-arch/unzip )
87         examples? ( kernel_linux? ( app-arch/unzip ) )
88         pax_kernel? ( sys-apps/paxctl )"
89
90 S="${WORKDIR}"/jdk${S_PV}
91
92 check_tarballs_available() {
93         local uri=$1; shift
94         local dl= unavailable=
95         for dl in "${@}"; do
96                 [[ ! -f "${DISTDIR}/${dl}" ]] && unavailable+=" ${dl}"
97         done
98
99         if [[ -n "${unavailable}" ]]; then
100                 if [[ -z ${_check_tarballs_available_once} ]]; then
101                         einfo
102                         einfo "Oracle requires you to download the needed files manually after"
103                         einfo "accepting their license through a javascript capable web browser."
104                         einfo
105                         _check_tarballs_available_once=1
106                 fi
107                 einfo "Download the following files:"
108                 for dl in ${unavailable}; do
109                         einfo "  ${dl}"
110                 done
111                 einfo "at '${uri}'"
112                 einfo "and move them to '${DISTDIR}'"
113                 einfo
114                 einfo "If the above mentioned urls do not point to the correct version anymore,"
115                 einfo "please download the files from Oracle's java download archive:"
116                 einfo
117                 einfo "   http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jdk-${MY_PV}-oth-JPR"
118                 einfo
119         fi
120 }
121
122 pkg_nofetch() {
123         local distfiles=( $(eval "echo \${$(echo AT_${ARCH/-/_})}") )
124         if use examples && has ${ARCH} "${DEMOS_AVAILABLE[@]}"; then
125                 distfiles+=( $(eval "echo \${$(echo DEMOS_${ARCH/-/_})}") )
126         fi
127         check_tarballs_available "${JDK_URI}" "${distfiles[@]}"
128
129         use jce && check_tarballs_available "${JCE_URI}" "${JCE_FILE}"
130 }
131
132 src_unpack() {
133         # Special case for ARM soft VS hard float.
134         if use arm ; then
135                 if [[ ${CHOST} == *-hardfloat-* ]] ; then
136                         unpack jdk-${MY_PV}-linux-arm-vfp-hflt.tar.gz
137                         use examples && unpack jdk-${MY_PV}-linux-arm-vfp-hflt-demos.tar.gz
138                 else
139                         unpack jdk-${MY_PV}-linux-arm-vfp-sflt.tar.gz
140                         use examples && unpack jdk-${MY_PV}-linux-arm-vfp-sflt-demos.tar.gz
141                 fi
142                 use examples && unpack javafx_samples-${FX_VERSION}-linux.zip
143                 use jce && unpack ${JCE_FILE}
144         elif use x86-macos || use x64-macos ; then
145                 pushd "${T}" > /dev/null
146                 mkdir dmgmount
147                 hdiutil attach "${DISTDIR}"/jdk-${MY_PV}-macosx-x64.dmg \
148                         -mountpoint "${T}"/dmgmount
149                 xar -xf dmgmount/JDK\ $(get_version_component_range 2)\ Update\ $(get_version_component_range 4).pkg
150                 hdiutil detach "${T}"/dmgmount
151                 zcat jdk1${MY_PV/u/0}.pkg/Payload | cpio -idv
152                 mv Contents/Home "${S}"
153                 popd > /dev/null
154         else
155                 default
156         fi
157 }
158
159 src_prepare() {
160         if use jce; then
161                 mv "${WORKDIR}"/${JCE_DIR} "${S}"/jre/lib/security/ || die
162         fi
163 }
164
165 src_install() {
166         local dest="/opt/${P}"
167         local ddest="${ED}${dest}"
168
169         # Create files used as storage for system preferences.
170         mkdir jre/.systemPrefs || die
171         touch jre/.systemPrefs/.system.lock || die
172         touch jre/.systemPrefs/.systemRootModFile || die
173
174         # We should not need the ancient plugin for Firefox 2 anymore, plus it has
175         # writable executable segments
176         if use x86; then
177                 rm -vf {,jre/}lib/i386/libjavaplugin_oji.so \
178                         {,jre/}lib/i386/libjavaplugin_nscp*.so
179                 rm -vrf jre/plugin/i386
180         fi
181         # Without nsplugin flag, also remove the new plugin
182         local arch=${ARCH};
183         use x86 && arch=i386;
184         if ! use nsplugin; then
185                 rm -vf {,jre/}lib/${arch}/libnpjp2.so \
186                         {,jre/}lib/${arch}/libjavaplugin_jni.so
187         fi
188
189         dodoc COPYRIGHT
190         dohtml README.html
191
192         dodir "${dest}"
193         cp -pPR bin include jre lib man "${ddest}" || die
194
195         if use derby; then
196                 cp -pPR db "${ddest}" || die
197         fi
198
199         if use examples && has ${ARCH} "${DEMOS_AVAILABLE[@]}"; then
200                 cp -pPR demo sample "${ddest}" || die
201                 if use kernel_linux; then
202                         cp -pPR "${WORKDIR}"/javafx-samples-${FX_VERSION//_/.} \
203                                 "${ddest}"/javafx-samples || die
204                 fi
205         fi
206
207         if use jce; then
208                 dodir "${dest}"/jre/lib/security/strong-jce
209                 mv "${ddest}"/jre/lib/security/US_export_policy.jar \
210                         "${ddest}"/jre/lib/security/strong-jce || die
211                 mv "${ddest}"/jre/lib/security/local_policy.jar \
212                         "${ddest}"/jre/lib/security/strong-jce || die
213                 dosym "${dest}"/jre/lib/security/${JCE_DIR}/US_export_policy.jar \
214                         "${dest}"/jre/lib/security/US_export_policy.jar
215                 dosym "${dest}"/jre/lib/security/${JCE_DIR}/local_policy.jar \
216                         "${dest}"/jre/lib/security/local_policy.jar
217         fi
218
219         if use nsplugin; then
220                 install_mozilla_plugin "${dest}"/jre/lib/${arch}/libnpjp2.so
221         fi
222
223         if use source; then
224                 cp -p src.zip "${ddest}" || die
225         fi
226
227         if use !arm && use !x86-macos && use !x64-macos ; then
228                 # Install desktop file for the Java Control Panel.
229                 # Using ${PN}-${SLOT} to prevent file collision with jre and or
230                 # other slots.  make_desktop_entry can't be used as ${P} would
231                 # end up in filename.
232                 newicon jre/lib/desktop/icons/hicolor/48x48/apps/sun-jcontrol.png \
233                         sun-jcontrol-${PN}-${SLOT}.png || die
234                 sed -e "s#Name=.*#Name=Java Control Panel for Oracle JDK ${SLOT}#" \
235                         -e "s#Exec=.*#Exec=/opt/${P}/jre/bin/jcontrol#" \
236                         -e "s#Icon=.*#Icon=sun-jcontrol-${PN}-${SLOT}#" \
237                         -e "s#Application;##" \
238                         -e "/Encoding/d" \
239                         jre/lib/desktop/applications/sun_java.desktop \
240                         > "${T}"/jcontrol-${PN}-${SLOT}.desktop || die
241                 domenu "${T}"/jcontrol-${PN}-${SLOT}.desktop
242         fi
243
244         # Prune all fontconfig files so libfontconfig will be used and only install
245         # a Gentoo specific one if fontconfig is disabled.
246         # http://docs.oracle.com/javase/7/docs/technotes/guides/intl/fontconfig.html
247         rm "${ddest}"/jre/lib/fontconfig.*
248         if ! use fontconfig; then
249                 cp "${FILESDIR}"/fontconfig.Gentoo.properties "${T}"/fontconfig.properties || die
250                 eprefixify "${T}"/fontconfig.properties
251                 insinto "${dest}"/jre/lib/
252                 doins "${T}"/fontconfig.properties
253         fi
254
255         # This needs to be done before CDS - #215225
256         java-vm_set-pax-markings "${ddest}"
257
258         # see bug #207282
259         einfo "Creating the Class Data Sharing archives"
260         case ${ARCH} in
261                 arm|ia64)
262                         ${ddest}/bin/java -client -Xshare:dump || die
263                         ;;
264                 x86)
265                         ${ddest}/bin/java -client -Xshare:dump || die
266                         # limit heap size for large memory on x86 #467518
267                         # this is a workaround and shouldn't be needed.
268                         ${ddest}/bin/java -server -Xms64m -Xmx64m -Xshare:dump || die
269                         ;;
270                 *)
271                         ${ddest}/bin/java -server -Xshare:dump || die
272                         ;;
273         esac
274
275         # Remove empty dirs we might have copied
276         find "${D}" -type d -empty -exec rmdir -v {} + || die
277
278         if use x86-macos || use x64-macos ; then
279                 # fix misc install_name issues
280                 pushd "${ddest}"/jre/lib > /dev/null || die
281                 local lib needed nlib npath
282                 for lib in \
283                                 libJObjC libdecora-sse libglass libjavafx-{font,iio} \
284                                 libjfxmedia libjfxwebkit libprism-es2 ;
285                 do
286                         lib=${lib}.dylib
287                         einfo "Fixing self-reference of ${lib}"
288                         install_name_tool \
289                                 -id "${EPREFIX}${dest}/jre/lib/${lib}" \
290                                 "${lib}"
291                 done
292                 popd > /dev/null
293                 for nlib in jdk1{5,6} ; do
294                         install_name_tool -change \
295                                 /usr/lib/libgcc_s_ppc64.1.dylib \
296                                 /usr/lib/libSystem.B.dylib \
297                                 "${ddest}"/lib/visualvm/profiler/lib/deployed/${nlib}/mac/libprofilerinterface.jnilib
298                         install_name_tool -id \
299                                 "${EPREFIX}${dest}"/lib/visualvm/profiler/lib/deployed/${nlib}/mac/libprofilerinterface.jnilib \
300                                 "${ddest}"/lib/visualvm/profiler/lib/deployed/${nlib}/mac/libprofilerinterface.jnilib
301                 done
302         fi
303
304         set_java_env
305         java-vm_revdep-mask
306         java-vm_sandbox-predict /dev/random /proc/self/coredump_filter
307 }