# Reference: <https://postmarketos.org/devicepkg>
# Maintainer: Nikita Travkin <nikitos.tr@gmail.com>
# Co-Maintainer: Minecrell <minecrell@minecrell.net>
pkgname=device-wileyfox-crackling
pkgdesc="Wileyfox Swift"
pkgver=8
pkgrel=1
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="postmarketos-base mkbootimg linux-postmarketos-qcom-msm8916
	 soc-qcom-msm8916 soc-qcom-msm8916-rproc"
makedepends="devicepkg-dev"
source="
	deviceinfo
	modules-initfs
	10-crackling-proximity.rules
	"
subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
"
_pmb_select="soc-qcom-msm8916-rproc"

# Backwards compatibility for old kernel variant subpackages
replaces="$pkgname-kernel-mainline $pkgname-kernel-mainline-modem"
for pkg in $replaces; do provides="$provides $pkg=$pkgver-r$pkgrel"; done

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname

	install -D -m644 "$srcdir"/10-crackling-proximity.rules \
		"$pkgdir"/usr/lib/udev/rules.d/10-crackling-proximity.rules
}

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

sha512sums="
fb5ff1648128331dff061026e8c783a26f66dea4530de6ad3a27620e1aa0fc516e8c0b2f04fe3f6e9e5ce882b77b415d93981532c546129949caec802cdda883  deviceinfo
31f926acffed502edca7d6a26c97c197970b842122df42a1ea5c63f2707b4375465eae77a754f5d58f556f55e1f5f421af21a92ca6165a3a4bacf55c5fbf7faf  modules-initfs
a845e860cf43e58818bbffda62a9514e9a24527e14c485dd10944587b29dbf5864a1d3ec17d219c342512fac4bd6c25f5f0f4efb8883b8f383a79846759318ee  10-crackling-proximity.rules
"
