# Maintainer: Milan P. Stanić <mps@arvanta.net>
# **** temporary aport till all is upstreamed *****
pkgname=u-boot-asahi
pkgver=2024.07_p1
pkgrel=0
pkgdesc="u-boot bootloader for Apple Silicon Macs"
url="https://github.com/AsahiLinux/u-boot"
arch="aarch64"
license="GPL-2.0-or-later OFL-1.1 BSD-2-Clause BSD-3-Clause eCos-2.0 IBM-pibs
	ISC LGPL-2.0-only LGPL-2.1-only X11"
options="!check" # no tests
depends="m1n1"
triggers="$pkgname.trigger=/boot/dtbs-asahi/apple:/usr/share/m1n1/m1n1.bin:/usr/share/u-boot-asahi/u-boot-nodtb.bin"

makedepends="$depends_dev
	bash
	bc
	bison
	dtc
	flex
	gnutls-dev
	linux-headers
	openssl-dev
	py3-setuptools
	python3-dev
	swig
	util-linux-dev
	"
source="https://github.com/AsahiLinux/u-boot/archive/refs/tags/asahi-v${pkgver/_p/-}.tar.gz
	update-u-boot-asahi
	0001-video-add-simple-cursor.patch
	"
builddir="$srcdir"/$pkgname-v${pkgver/_p/-}

prepare() {
	default_prepare
	make apple_m1_defconfig
	scripts/config --file .config --disable "VIDEO_FONT_8X16"
	scripts/config --file .config --enable "VIDEO_FONT_16X32"
}

build() {
	make
}

package() {
	mkdir -p $pkgdir/usr/share/$pkgname/dtb
	mkdir -p $pkgdir/usr/sbin
	install -m644 "$builddir"/u-boot-nodtb.bin "$pkgdir"/usr/share/$pkgname/
	cp "$builddir"/arch/arm/dts/t[86]*.dtb "$pkgdir"/usr/share/$pkgname/dtb/
	install -m744 "$srcdir"/update-u-boot-asahi "$pkgdir"/usr/sbin/
}

sha512sums="
f70c8f3cabbac6e11e81b787008548248f320c6f1b3bc75eb36c5e13ceefc6a0a8d4968b3fb66eac187626034e6483e8fad7ff79d28cef94c673d2ac7a4ca961  asahi-v2024.07-1.tar.gz
e096055da0c0fbd2b072098fe47f434c7798ab4cd9a602555e0750656feb5b7d1a0d6f8a20380afbbb53dafabd2a0455a7146c0f69e33c404c79028ad9e7a394  update-u-boot-asahi
efd3e8cf9996fd8984a15bf9bd4b780d32c30e1fb880d8f85cc102550f61dec60e885160b454deb2f909d84174e8fe05873944c02a3239dcf6ba8319aa84ec94  0001-video-add-simple-cursor.patch
"
