# Reference: <https://postmarketos.org/devicepkg>
maintainer="Jethrob <jeybee@hotmail.com>"
pkgname=device-microsoft-surface-rt
pkgdesc="Microsoft Surface RT"
pkgver=9
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="armv7"
# pmb:strict: avoid grub-related install error during build with pmbootstrap
options="!check !archcheck pmb:strict"
depends="
	alsa-ucm-conf
	linux-postmarketos-grate
	postmarketos-base
"
makedepends="devicepkg-dev grub grub-efi"
subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
	$pkgname-x11
"
source="deviceinfo kernel-cmdline.conf modules-initfs"

build() {
	devicepkg_build $startdir $pkgname

	grub-mkimage \
		--prefix="/grub" \
		--output="bootarm.efi" \
		--format="arm-efi" \
		--compression="xz" \
		\
		disk \
		fat \
		gzio \
		iso9660 \
		linux \
		normal \
		part_gpt \
		part_msdos
}

package() {
	devicepkg_package $startdir $pkgname

	install -D bootarm.efi \
		"$pkgdir"/boot/EFI/Boot/bootarm.efi
}

nonfree_firmware() {
	pkgdesc="WiFi firmware"
	depends="linux-firmware-mrvl"
	mkdir "$subpkgdir"
}

x11() {
	install_if="$pkgname xorg-server"
	depends="xf86-video-opentegra libvdpau-tegra"
	mkdir "$subpkgdir"
}

sha512sums="
4bb0449c31a9c6481f0f42290d25c6222577ceb6a414b58101077f4273e9f04c8f095aa7257b073869255308e6b8f3cd66d9b10fb258e448c736341733600bc0  deviceinfo
97ba87687ec3bbe2d8473d310f17b6771e7a8758f2585e77915025b1f211120dca615946e13fb561771a557081984a4f6f74cf8686d3bd822f614876498b0328  kernel-cmdline.conf
67ff4306270b7e6e292ddb48ac5fcb1472840d8eaa412f9cd989442fb20139ee3c844fd1ca5c5b923c7980403d945999a77fc6617127059e56e22bdc8dca2bf8  modules-initfs
"
