# Maintainer: Craig Comstock <craig@unreasonablefarm.org>
pkgname=firmware-motorola-surnia
pkgver=2
pkgrel=0
pkgdesc="Firmware for Motorola Moto E 2015 (2nd gen)"
url="https://github.com/linuxgorl/vendor_motorola_surnia"
subpackages="$pkgname-wcnss-nv:wcnss_nv $pkgname-venus"
arch="aarch64"
license="proprietary"
options="!check !strip !archcheck !tracedeps pmb:cross-native"

_commit="b8dbec48197c086d22371d360fa41387880a1dcb"
source="$pkgname-$_commit.tar.gz::$url/archive/$_commit.tar.gz"

builddir="$srcdir/vendor_motorola_surnia-$_commit"

_fwdir="/lib/firmware/postmarketos"

package() {
	mkdir -p "$pkgdir"
}

wcnss_nv() {
	pkgdesc="Motorola Moto E 2015 (2nd gen) Wi-Fi/Bluetooth firmware configuration"
	replaces="firmware-motorola-surnia-wcnss"
	install -Dm644 "$builddir"/wlan/prima/WCNSS_qcom_wlan_nv.bin -t "$subpkgdir/$_fwdir/wlan/prima"
}

venus() {
	pkgdesc="Motorola Moto E 2015 (2nd gen) video firmware"

	# Linux detects squashed (.mbn) vs non-squashed (.mdt + .b*) based on
	# file contents, so it is fine to link venus.mbn to venus.mdt
	# Older kernels look for venus.mdt, newer ones directly for venus.mbn
	install -Dm644 "$builddir"/venus.mbn "$subpkgdir/$_fwdir"/qcom/venus-1.8/venus.mbn
	ln -s venus.mbn "$subpkgdir/$_fwdir"/qcom/venus-1.8/venus.mdt
}


sha512sums="
859f81ef316ee025245e217e8bca891c89dade23781cc386d6c930608cbd8aba78b0f3c93a0ad1a265ba20554379fe60331e32c1924ee4dd9151f8c146be347f  firmware-motorola-surnia-b8dbec48197c086d22371d360fa41387880a1dcb.tar.gz
"
