# Template file for 'broadcom-wl-dkms'

pkgname=broadcom-wl-dkms
version=6.30.223.271
revision=11
maintainer="Orphaned <orphan@voidlinux.org>"
license="custom:Proprietary Broadcom license"
homepage="http://broadcom.com"

archs="i686* x86_64*"
repository="nonfree"
create_wrksrc=yes

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

case "$XBPS_TARGET_MACHINE" in
i686*)
	distfiles="https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/hybrid-v35-nodebug-pcoem-${version//./_}.tar.gz"
	checksum=4f8b70b293ac8cc5c70e571ad5d1878d0f29d133a46fe7869868d9c19b5058cd
	;;
x86_64*)
	distfiles="https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/hybrid-v35_64-nodebug-pcoem-${version//./_}.tar.gz"

	checksum=5f79774d5beec8f7636b59c0fb07a03108eef1e3fd3245638b20858c714144be
	;;
esac

do_install() {
	sed -i -e "/BRCM_WLAN_IFNAME/s:eth:wlan:" src/wl/sys/wl_linux.c

	# 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

	# 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
	printf '' > ${DESTDIR}/usr/lib/modprobe.d/wl.conf
	for module in b43{,legacy} ssb bcm{43xx,a} brcm{80211,fmac,smac}; do
		echo "blacklist $module" >> ${DESTDIR}/usr/lib/modprobe.d/wl.conf
	done

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

post_install() {
	vlicense lib/LICENSE.txt LICENSE
}
