SUMMARY="Ralink WiFi firmware modules"
DESCRIPTION="Ralink WiFi devices require firmware to operate. This package \
contains those necessary firmware files, corresponding to the WiFi drivers \
contained within the base system."
HOMEPAGE="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/"
COPYRIGHT="2005-2008, Ralink Technology Corp"
LICENSE="Ralink WiFi Firmware"
REVISION="1"
srcGitRev="f386f04f11679fd31731bce42208bb4363b79e75"
SOURCE_URI="https://github.com/freebsd/freebsd-src/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="327e6f4836c3c80ab388d53879f97a0bccd6b9f4873860750a0c00fecbcb39aa"
SOURCE_DIR="freebsd-src-$srcGitRev/sys/contrib/dev/"

ARCHITECTURES="any"
DISABLE_SOURCE_PACKAGE="yes"

PROVIDES="
	ralink_wifi_firmwares = $portVersion
	"

BUILD_REQUIRES="
	cmd:uudecode
	"

BUILD()
{
	rm -rf install-firmware
	mkdir -p install-firmware

	process_firmware()
	{
		freebsd_driver=$1
		haiku_driver=$2
		cd $freebsd_driver
		mkdir ../install-firmware/$haiku_driver
		for f in *.uu; do
			uudecode -o ../install-firmware/$haiku_driver/$(echo $f | cut -d'.' -f-1).ucode $f
		done
		cp LICENSE ../install-firmware/$haiku_driver
		cd ..
	}

	process_firmware ral ralinkwifi
}

INSTALL()
{
	mkdir -p $dataDir/firmware/
	cp -r install-firmware/. $dataDir/firmware/
}
