# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-java/sun-jre-bin/sun-jre-bin-1.6.0.22.ebuild,v 1.3 2010/10/13 11:24:06 hwoarang Exp $

inherit versionator pax-utils eutils java-vm-2

MY_PVR="$(replace_version_separator 3 _)"
MY_PV="$(replace_all_version_separators _ )"

SUFFIX=".tar.gz"
ARMV5_AT="ejre-${MY_PV}-fcs-b42-linux-armv5-sflt-eabi-headless-10_jun_2010${SUFFIX}"

DESCRIPTION="Sun's Java SE Embedded Runtime Environment"
HOMEPAGE="http://www.oracle.com/technetwork/java/embedded/overview/index.html"
URL_BASE="http://download.java.net/dlj/binaries"
SRC_URI="arm? ( ${URL_BASE}/${ARMV5_AT} )"
SLOT="1.6"
LICENSE="ejre-6"
KEYWORDS="~arm"
RESTRICT="strip fetch"
IUSE="X jce odbc"

DEPEND="jce? ( =dev-java/sun-jce-bin-1.6.0* )"
RDEPEND="${DEPEND}
	sys-libs/glibc
	X? (
		x11-libs/libXext
		x11-libs/libX11
	)
	odbc? ( dev-db/unixODBC )"

JAVA_PROVIDE="jdbc-stdext jdbc-rowset"

QA_TEXTRELS_x86="opt/${P}/lib/arm/client/libjvm.so
	opt/${P}/lib/arm/motif21/libmawt.so
	opt/${P}/lib/arm/libdeploy.so
	opt/${P}/lib/arm/server/libjvm.so"

S="${WORKDIR}/ejre${MY_PVR}"

src_compile() {
	# Set PaX markings on all JDK/JRE executables to allow code-generation on
	# the heap by the JIT compiler. This has to be done before CDS - #215225
	pax-mark m $(list-paxables "${S}"/bin/*)

	# see bug #207282
	if use arm; then
		einfo "Creating the Class Data Sharing archives"
		"${S}"/bin/java -client -Xshare:dump || die
	#	"${S}"/bin/java -server -Xshare:dump || die
	fi
}

src_install() {
	local dirs="bin lib"

	dodir /opt/${P}

	cp -pPR $dirs "${D}/opt/${P}/" || die "failed to copy"

	dodoc legal/COPYRIGHT.txt legal/THIRDPARTYLICENSEREADME.txt || die
	dohtml *.html || die
	dodir /opt/${P}/share/

	if use jce; then
		cd "${D}/opt/${P}/lib/security"
		dodir /opt/${P}/lib/security/strong-jce
		mv "${D}"/opt/${P}/lib/security/US_export_policy.jar \
			"${D}"/opt/${P}/lib/security/strong-jce || die
		mv "${D}"/opt/${P}/lib/security/local_policy.jar \
			"${D}"/opt/${P}/lib/security/strong-jce || die
		dosym /opt/sun-jce-bin-1.6.0/jre/lib/security/unlimited-jce/US_export_policy.jar /opt/${P}/lib/security/
		dosym /opt/sun-jce-bin-1.6.0/jre/lib/security/unlimited-jce/local_policy.jar /opt/${P}/lib/security/
	fi


	# bug #56444
	insinto /opt/${P}/lib/
	newins "${FILESDIR}"/fontconfig.Gentoo.properties fontconfig.properties

	set_java_env
	java-vm_revdep-mask
}

pkg_postinst() {
	# Set as default VM if none exists
	java-vm-2_pkg_postinst
}

pkg_nofetch() {
	einfo "This files require you to register at ${HOMEPAGE} (free account)"
	einfo "Please download following file:"
	einfo " - ${ARMV5_AT}"
	einfo "from ${HOMEPAGE}"
	einfo "and place them in ${DISTDIR}"
}