# Reference: <https://postmarketos.org/devicepkg>
maintainer="Arseniy Velikanov <adomerlee@gmail.com>"
pkgname=device-xiaomi-vayu
pkgdesc="Xiaomi POCO X3 Pro"
pkgver=3
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="
	linux-postmarketos-qcom-sm8150
	mkbootimg
	postmarketos-base
	make-dynpart-mappings
"
makedepends="devicepkg-dev"
source="
	deviceinfo
	phoc.ini
"

subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
	$pkgname-nonfree-firmware-openrc:nonfree_firmware_openrc
	$pkgname-phosh
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
}

nonfree_firmware() {
	pkgdesc="Firmware for GPU, Audio, Modem, WiFi, etc."
	depends="
		firmware-xiaomi-vayu-adreno
		firmware-xiaomi-vayu-adsp
		firmware-xiaomi-vayu-cdsp
		firmware-xiaomi-vayu-touchscreen
		firmware-xiaomi-vayu-wlan
		firmware-xiaomi-vayu-modem
		firmware-xiaomi-vayu-ath10k
		msm-modem
		pd-mapper
		tqftpserv
		"
	mkdir "$subpkgdir"
}

nonfree_firmware_openrc() {
	install_if="$pkgname-nonfree-firmware=$pkgver-r$pkgrel openrc"
	install="$subpkgname.post-install"
	depends="openrc"

	mkdir "$subpkgdir"
}

phosh() {
	install_if="$pkgname=$pkgver-r$pkgrel phosh"
	install -Dm644 "$srcdir"/phoc.ini \
		"$subpkgdir"/etc/phosh/phoc.ini
}

sha512sums="
8f07455ec97c160456469a1fa0bcfb0fa9fd418a93e42f4250b3b171d72b07a91450ddc0580e3c5b16296d48374d20b0dec37c55953714796a486772cd12a6b6  deviceinfo
eef80842915acfa8d8bcbd9ac9fcb057ad912d582e4a78b8ddd9774ef688971d2878b83f4a54adaa1d613dce8645a85ffb25e8a98c55e32a91dfe73002e91fe0  phoc.ini
"
