# Maintainer: Raffaele Tranquillini <raffaele.tranquillini@gmail.com>

pkgname=device-pegatron-chagall
pkgdesc="Pegatron Chagall"
pkgver=6
pkgrel=1
url="https://postmarketos.org"
license="MIT"
arch="armv7"
options="!check !archcheck"
depends="
	alsa-ucm-conf
	asus-transformer-blobtools
	libvdpau-tegra
	linux-postmarketos-grate
	mkbootimg
	postmarketos-base
"
makedepends="devicepkg-dev"
source="
	deviceinfo
	pointercal
	phoc.ini
"
subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
	$pkgname-phosh
	$pkgname-x11
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname

	# osk-sdl touchscreen calibration
	install -Dm644 "$srcdir"/pointercal \
		"$pkgdir"/etc/pointercal
}

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

nonfree_firmware() {
	pkgdesc="Pegatron Chagall WiFi & Bluetooth firmware"
	depends="firmware-asus-transformer"
	mkdir "$subpkgdir"
}

x11() {
	install_if="$pkgname=$pkgver-r$pkgrel xorg-server"
	depends="xf86-video-opentegra"
	mkdir "$subpkgdir"
}

sha512sums="
4d66f7523c28d917fdd7470dadb175e56964e93572478a322f8219911b31d30afd94fb611f4dae4e535f3e0885e821e2eb107deb4d3820a3b9421d7ad30023b8  deviceinfo
61418c6a0df6c1a4d4bacafb98abcd8897d81fc1ae319cbe451aaebd90a8d231e2ec1812b45d72687f901cc1e2c874f12960b50026becdf42917c8c2d5fbad77  pointercal
064129c96a617d3e7bfc56f399b9b46ca3d56325c3777ab28b1f7de242e8199cf33c03a9a071c83a833180a12d9d2abb5d32174f0d8d792a370e6320ec4d7808  phoc.ini
"
