# Template file for 'oracle-jdk'
pkgname=oracle-jdk-arm
version=8u33
_longVersion=1.8.0_33
revision=1
_build=05

short_desc="Java Development Kit (JDK)"
maintainer="Enno Boland <eb@s01.de>"
homepage="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-arm-downloads-2187472.html"
license="oracle"
lib32disabled=yes
repository="nonfree"
only_for_archs="armv7l armv6l"
depends="hicolor-icon-theme desktop-file-utils xdg-utils shared-mime-info wget"
hostmakedepends="wget"
provides="java-environment-${version}_1 oracle-jdk-${version}_${revision}"
replaces="java-environment>=0"

_arch=arm
_filename=jdk-${version}-linux-arm-vfp-hflt.tar.gz
checksum="e550a8eb903ecb8e6a46b5a1efd3d87a0672084cf40315ed8a1b8208eeb17286"

distfiles="http://download.oracle.com/otn-pub/java/jdk/${version}-b${_build}/${_filename}"
wrksrc="jdk$_longVersion"

do_fetch() {
	mkdir -p $wrksrc
	cd $wrksrc
	wget \
		--no-check-certificate \
		--header "Cookie: oraclelicense=accept-securebackup-cookie" \
		--progress=bar:force \
		-c -O $_filename \
		$distfiles
	echo "$checksum  $_filename" | sha256sum -c || { sha256sum "$_filename"; return 1; }
}

do_extract() {
	tar xf $_filename -C ..
}

do_build() {
	sed \
		-e "s|%LONG_VERSION%|${_longVersion}|" \
			${FILESDIR}/oracle-jdk.sh.in > 10_oracle-jdk.sh
	sed \
		-e "s|%LONG_VERSION%|${_longVersion}|" \
		-e "s|%ORACLE_JDK_URL%|${distfiles}|" \
		-e "s|%ORACLE_JDK_CHECKSUM%|${checksum}|" \
			${FILESDIR}/oracle-jdk-vars.sh.in > oracle-jdk-vars.sh
}

do_install() {
	vmkdir "usr/lib/jvm"
	vinstall oracle-jdk-vars.sh 644 "usr/lib/jvm"

	vmkdir "usr/share/licenses/${pkgname}"
	vlicense LICENSE
	ln -s jdk${_longVersion} ${DESTDIR}/usr/lib/jvm/oracle-jdk

	vmkdir "etc/profile.d"
	vinstall 10_oracle-jdk.sh 644 "etc/profile.d"
}
