# Reference: <https://postmarketos.org/devicepkg>
maintainer="Raymond Hackley <raymondhackley@protonmail.com>"
pkgname=device-qcom-msm8909
pkgdesc="Generic device package for various Qualcomm MSM8905/MSM8909/MSM8916-based devices"
pkgver=4
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="armv7"
options="!check !archcheck"
depends="
	linux-postmarketos-qcom-msm8916
	postmarketos-base
	soc-qcom-msm8909
"
makedepends="devicepkg-dev"
source="
	deviceinfo
	modules-initfs
"
subpackages="$pkgname-nonfree-firmware:nonfree_firmware"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
}

nonfree_firmware() {
	pkgdesc="WiFi/BT/Modem/Video firmware"
	depends="msm-firmware-loader firmware-qcom-adreno-a300 firmware-qcom-db410c-wcnss-nv"
	mkdir "$subpkgdir"

	# HACK: For devices that don't have a nv file in persist we
	# temporarily link the db410c file to the expected location.
	# It will be overriden if the file is in persist or when user
	# installs the device-specific firmware packages.
	mkdir -p "$subpkgdir"/lib/firmware/wlan/prima/
	ln -s /lib/firmware/qcom/apq8016/WCNSS_qcom_wlan_nv_sbc.bin \
		"$subpkgdir"/lib/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin
}

sha512sums="
b2e9c3bc27ac8b4c6d326b313bfc60840d15b9c9f6fe120f99c4a1cbd5b9d95114c831f4a8f9ca8672f802f3c1f183f6d5b6c8ada1ce1cc0f082d9b410915013  deviceinfo
3c4ae8aad562270a6094add613912955bafed994e0df2f8842575fb4e38db0f21a57dc61fb772af418d1423512811e7f9f533c2e9b3f8edb657ed20f12ca2fc9  modules-initfs
"
