# Maintainer: Alec Su (AlecJY) <ae40515@yahoo.com.tw>
# Reference: <https://postmarketos.org/devicepkg>

pkgname=device-xiaomi-natrium
pkgdesc="Xiaomi Mi 5s Plus"
pkgver=1
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="
	linux-postmarketos-qcom-msm8996
	mesa-egl
	mkbootimg
	postmarketos-base
	postmarketos-update-kernel
	soc-qcom-msm8996
	soc-qcom-msm8996-ucm
"
makedepends="devicepkg-dev"
subpackages="$pkgname-nonfree-firmware:nonfree_firmware $pkgname-phosh"

source="
	deviceinfo
	pointercal
	phoc.ini
	30-gpu-firmware.files
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname

	install -D -m644 "$srcdir"/pointercal \
		"$pkgdir"/etc/pointercal
}

nonfree_firmware() {
	pkgdesc="GPU/Modem/Venus/ADSP/SLPI/WiFi/Bluetooth Firmware"
	depends="
		firmware-xiaomi-natrium
		linux-firmware-ath10k
		linux-firmware-qca
		soc-qcom-msm8996-nonfree-firmware
		"
	install="$subpkgname.post-install"
	mkdir "$subpkgdir"

	install -Dm644 "$srcdir/30-gpu-firmware.files" -t \
		"$subpkgdir/etc/postmarketos-mkinitfs/files"
}

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


sha512sums="
b1e93eb146f3fd9adc4197d2b39a89ac1cfb2dc06587692262654444d4ba2642103cc7895bedfc02b2243a38645beceb91d1f66cdd654ff1d298c4eb3120b13a  deviceinfo
e9ee9c1404b41ba15eafff3f728ff6e0e78dc17e9a88483fca92db1aa3efe0e4d5bf26142e533c4ff12b1bf8ce04ccabb7ca0f93aaea586d5b30910282aad237  pointercal
38409d4ce48db4624539dbfd695d3c6e1596a29fd7c3004a41368b28cba646495d05360420ad728f82c63d6ddeeca71d09944df06ebaca120aedd9cc2b436eb3  phoc.ini
4babc3e499cbc3fab555d3d939b34e763d31ee8e36f3766f3b0bc8c6d1e2ec67f119b87e4a5bc898ad6881b9da98c06f184a567dc9f96b08857ee185ff05f6ae  30-gpu-firmware.files
"
