# Contributor: Nikita Travkin <nikita@trvn.ru>
maintainer="Nikita Travkin <nikita@trvn.ru>"
pkgname=dtbloader
pkgver=1.5.2
pkgrel=0
pkgdesc="EFI driver that finds and installs DeviceTree into the UEFI configuration table"
url="https://github.com/TravMurav/dtbloader"
arch="aarch64"
license="BSD-3-Clause"
makedepends="clang cmd:llvm-ar lld"
options="!check"
subpackages="$pkgname-boot-deploy:boot_deploy"
source="https://github.com/TravMurav/dtbloader/releases/download/$pkgver/dtbloader-$pkgver.tar.gz"

build() {
	make \
		ABORT_IF_UNSUPPORTED=1 \
		O=build

	./scripts/get_supported_dtbs.sh > "$builddir"/build/dtbs.txt
}

package() {
	install -Dt "$pkgdir"/usr/share/dtbloader \
		"$builddir"/build/dtbloader.efi \
		"$builddir"/build/dtbs.txt
}

boot_deploy() {
	pkgdesc="boot-deploy integration for dtbloader"
	install_if="$pkgname=$pkgver-r$pkgrel boot-deploy"

	mkdir -p "$subpkgdir"/usr/share/boot-deploy/efi-drivers/
	ln -s /usr/share/dtbloader/dtbloader.efi \
		"$subpkgdir"/usr/share/boot-deploy/efi-drivers/dtbloaderaa64.efi
}

sha512sums="
71b7e13b8660884767c316ad20fbc363d6d0b8059202e584c6c83fb0e39507906fded7431674f959d9ae0a8d7d98684ac231f69274a64babb704b1d5a3830752  dtbloader-1.5.2.tar.gz
"
