# Template file for 'rpi-firmware'
pkgname=rpi-firmware
version=20130514
revision=1
short_desc="Firmware files for the Raspberry Pi"
maintainer="Juan RP <xtraeme@gmail.com>"
license="Propietary -- see /usr/share/licences/${pkgname}/"
homepage="https://github.com/raspberrypi/firmware"

noarch=yes
nofetch=yes
noextract=yes

do_fetch() {
	local url="git://github.com/raspberrypi/firmware.git"
	# Latest commit from 20130514 is f53948f
	git clone --depth 1 $url ${pkgname}-${version}
}

do_install() {
	rm -f boot/kernel.img
	rm -f boot/kernel_emergency.img
	rm -f boot/COPYING.linux

	vmkdir boot
	cp -R boot/* ${DESTDIR}/boot

	vmkdir opt/vc
	cp -R hardfp/opt/vc/{bin,include,lib,sbin,src,LICENCE} ${DESTDIR}/opt/vc

	vmkdir etc/ld.so.conf.d
	echo "/opt/vc/lib/" > ${DESTDIR}//etc/ld.so.conf.d/${pkgname}.conf

	vmkdir usr/share/licenses/${pkgname}
	mv ${DESTDIR}/boot/LICENCE.broadcom ${DESTDIR}/usr/share/licenses/${pkgname}
	mv ${DESTDIR}/opt/vc/LICENCE ${DESTDIR}/usr/share/licenses/${pkgname}

	# Install configuration files.
	vinstall ${FILESDIR}/cmdline.txt 644 boot
	vinstall ${FILESDIR}/config.txt 644 boot
}

rpi-firmware_package() {
	conf_files="/boot/cmdline.txt /boot/config.txt"
	noarch="yes"
	pkg_install() {
		vmove all
	}
}
