# Template file for 'broadcom-wl-dkms'

pkgname=broadcom-wl-dkms
version=6.30.223.141
revision=2
maintainer="ojab <ojab@ojab.ru>"
license="Proprietary Broadcom license"
homepage="http://broadcom.com"

only_for_archs="i686 x86_64"
nonfree=yes
create_wrksrc=yes

short_desc="Broadcom proprietary wireless drivers for Linux - DKMS kernel module"
triggers="dkms"
dkms_modules="wl ${version}"
depends="dkms"

if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
	distfiles="http://www.broadcom.com/docs/linux_sta/hybrid-v35-nodebug-pcoem-${version//./_}.tar.gz"
	checksum=d57c33f6bf4ebe68cac67ffe39c2260b8990bb0f07413dfd021dd4db845199a7
else
	distfiles="http://www.broadcom.com/docs/linux_sta/hybrid-v35_64-nodebug-pcoem-${version//./_}.tar.gz"
	checksum=5f37b2b879e29b220dc64ce2e93d922dc231d4241da03bcbab15ced10e649b4a
fi

do_install() {
	# dkms pkg
	vmkdir usr/src/wl-${version}/src
	vcopy "src/*" usr/src/wl-${version}/src
	vmkdir usr/src/wl-${version}/lib
	vcopy "lib/*" usr/src/wl-${version}/lib
	vcopy "Makefile" usr/src/wl-${version}

	vinstall ${FILESDIR}/dkms.conf 644 usr/src/wl-${version}
	sed -i -e "s/@VERSION@/${version}-${revision}/" ${PKGDESTDIR}/usr/src/wl-${version}/dkms.conf

	# systemd modules-load.d(5) file.
	vmkdir usr/lib/modules-load.d
	echo "wl" > ${DESTDIR}/usr/lib/modules-load.d/wl.conf
	chmod 644 ${DESTDIR}/usr/lib/modules-load.d/wl.conf

	# Blacklist OSS broadcom modules.
	vmkdir usr/lib/modprobe.d
	echo "blacklist b43" > ${DESTDIR}/usr/lib/modprobe.d/wl.conf
	echo "blacklist b43legacy" >> ${DESTDIR}/usr/lib/modprobe.d/wl.conf
	echo "blacklist ssb" >> ${DESTDIR}/usr/lib/modprobe.d/wl.conf
	echo "blacklist bcm43xx" >> ${DESTDIR}/usr/lib/modprobe.d/wl.conf
	echo "blacklist brcm80211" >> ${DESTDIR}/usr/lib/modprobe.d/wl.conf
	echo "blacklist brcmfmac" >> ${DESTDIR}/usr/lib/modprobe.d/wl.conf
	echo "blacklist brcmsmac" >> ${DESTDIR}/usr/lib/modprobe.d/wl.conf
	echo "blacklist bcma" >> ${DESTDIR}/usr/lib/modprobe.d/wl.conf

	chmod 644 ${DESTDIR}/usr/lib/modprobe.d/wl.conf
}
