# Maintainer: Eli Riggs <eli@rje.li>
# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-xiaomi-willow
pkgdesc="Xiaomi Redmi Note 8T"
pkgver=1
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="postmarketos-base linux-xiaomi-willow mkbootimg"
makedepends="devicepkg-dev"
subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
	$pkgname-weston
"
source="
	deviceinfo
	modules-load.conf
	weston.ini
	weston-fixes.sh
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
}

nonfree_firmware() {
	pkgdesc="Touchscreen firmware"
	depends="firmware-xiaomi-willow"
	mkdir "$subpkgdir"
}

weston() {
	install_if="$pkgname weston"

	# weston use drm backend, 2x dpi, don't use virtual output
	install -Dm644 "$srcdir"/weston.ini \
		"$subpkgdir"/etc/xdg/weston/weston.ini

	# weston msm_drm hax
	install -Dm755 "$srcdir"/weston-fixes.sh \
		"$subpkgdir"/etc/X11/xinit/xinitrc.d/00-xiaomi-willow-weston-fixes.sh
}

sha512sums="
c1a6b538e1c42a878e0af079829b4b01ce8e530012259a42319baafcc7f73fb1798ffd859935f1da135b3ffc4b49a388b86a88aab3ca4d87b6f1c256c32d4fa6  deviceinfo
1689a1294cfca52351f384324a0fc17ccfa520e33d9d8c616e6a000cc44273b72ca560f1407886e105cdb60282a6f096262e1499eb46ebd0c470599cfe639442  modules-load.conf
4fdc188f9cd5c0316959322568916a6e36e67ff316e90fa7bd7c7b642cb137a9ff7002b0475728c6ba53abcbfe8c50d82112e4943460ee424aee4bbfd0efecfe  weston.ini
2ecdd4f25c1047071f8f300d177bc1c288e7af6d05c0f2fa821f722494c92381416ee7969d7d4a7aff7eb7c4fa18d988b7a12bd3ba769022fd95987ca3b5f065  weston-fixes.sh
"
