1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils java-vm-2 prefix versionator
9 MY_PV="$(get_version_component_range 2)u$(get_version_component_range 4)"
10 S_PV="$(replace_version_separator 3 '_')"
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)"
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"
33 FXDEMOS_linux="javafx_samples-${FX_VERSION}-linux.zip"
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"
45 JCE_DIR="UnlimitedJCEPolicy"
46 JCE_FILE="${JCE_DIR}JDK7.zip"
48 DESCRIPTION="Oracle's Java SE Development Kit"
49 HOMEPAGE="http://www.oracle.com/technetwork/java/javase/"
50 for d in "${AT_AVAILABLE[@]}"; do
52 SRC_URI+=" $(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 ~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"
66 RESTRICT="fetch strip"
70 RDEPEND="${COMMON_DEP}
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
86 jce? ( app-arch/unzip )
87 examples? ( kernel_linux? ( app-arch/unzip ) )
88 pax_kernel? ( sys-apps/paxctl )"
90 S="${WORKDIR}"/jdk${S_PV}
92 check_tarballs_available() {
94 local dl= unavailable=
96 [[ ! -f "${DISTDIR}/${dl}" ]] && unavailable+=" ${dl}"
99 if [[ -n "${unavailable}" ]]; then
100 if [[ -z ${_check_tarballs_available_once} ]]; then
102 einfo "Oracle requires you to download the needed files manually after"
103 einfo "accepting their license through a javascript capable web browser."
105 _check_tarballs_available_once=1
107 einfo "Download the following files:"
108 for dl in ${unavailable}; do
112 einfo "and move them to '${DISTDIR}'"
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:"
117 einfo " http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jdk-${MY_PV}-oth-JPR"
123 local distfiles=( $(eval "echo \${$(echo AT_${ARCH/-/_})}") )
124 if use examples && has ${ARCH} "${DEMOS_AVAILABLE[@]}"; then
125 distfiles+=( $(eval "echo \${$(echo DEMOS_${ARCH/-/_})}") )
127 check_tarballs_available "${JDK_URI}" "${distfiles[@]}"
129 use jce && check_tarballs_available "${JCE_URI}" "${JCE_FILE}"
133 # Special case for ARM soft VS hard float.
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
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
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
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}"
161 mv "${WORKDIR}"/${JCE_DIR} "${S}"/jre/lib/security/ || die
166 local dest="/opt/${P}"
167 local ddest="${ED}${dest}"
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
174 # We should not need the ancient plugin for Firefox 2 anymore, plus it has
175 # writable executable segments
177 rm -vf {,jre/}lib/i386/libjavaplugin_oji.so \
178 {,jre/}lib/i386/libjavaplugin_nscp*.so
179 rm -vrf jre/plugin/i386
181 # Without nsplugin flag, also remove the new plugin
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
193 cp -pPR bin include jre lib man "${ddest}" || die
196 cp -pPR db "${ddest}" || die
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
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
219 if use nsplugin; then
220 install_mozilla_plugin "${dest}"/jre/lib/${arch}/libnpjp2.so
224 cp -p src.zip "${ddest}" || die
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;##" \
239 jre/lib/desktop/applications/sun_java.desktop \
240 > "${T}"/jcontrol-${PN}-${SLOT}.desktop || die
241 domenu "${T}"/jcontrol-${PN}-${SLOT}.desktop
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
255 # This needs to be done before CDS - #215225
256 java-vm_set-pax-markings "${ddest}"
259 einfo "Creating the Class Data Sharing archives"
262 ${ddest}/bin/java -client -Xshare:dump || die
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
271 ${ddest}/bin/java -server -Xshare:dump || die
275 # Remove empty dirs we might have copied
276 find "${D}" -type d -empty -exec rmdir -v {} + || die
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
283 libJObjC libdecora-sse libglass libjavafx-{font,iio} \
284 libjfxmedia libjfxwebkit libprism-es2 ;
287 einfo "Fixing self-reference of ${lib}"
289 -id "${EPREFIX}${dest}/jre/lib/${lib}" \
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
306 java-vm_sandbox-predict /dev/random /proc/self/coredump_filter