# Contributor: Nikita Travkin <nikita@trvn.ru>
# Maintainer: Nikita Travkin <nikita@trvn.ru>
pkgname=dtbloader
pkgver=1.5.1
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="
b273cf9611c5f8a1622c9d9eeb1f2bee7c5b55fa0c1fa8d52001c69f2fb1ab4dbe14f17f2bb5d065209181675788147f900b99c41ee3c3f2bd04cfd66ba7bf98  dtbloader-1.5.1.tar.gz
"
