# Template file for 'm1n1'
pkgname=m1n1
version=1.6.0
revision=1
archs="aarch64*"
hostmakedepends="ImageMagick void-artwork cargo rust-src"
short_desc="Asahi Linux bootloader"
maintainer="dkwo <npiazza@disroot.org>, Will Springer <skirmisher@protonmail.com>"
license="MIT"
homepage="https://asahilinux.org"
distfiles="https://github.com/AsahiLinux/m1n1/archive/refs/tags/v${version}.tar.gz"
checksum=4ef1f89116aedce60f5886bd37feef7fba294e2f44ef136d4547e54d09c15b8b
conf_files="/etc/m1n1.conf /etc/default/m1n1-kernel-hook"

pre_patch() {
	rm -rf rust/vendor/rust-fatfs
}

pre_build() {
	for size in 128 256; do
		cp /usr/share/icons/hicolor/${size}x${size}/apps/void-logo.png data/custom_${size}.png
	done
}

do_build() {
	make LOGO=custom RELEASE=1 ARCH=${CROSS_BUILD:+${XBPS_CROSS_TRIPLET}-} BUILDSTD=1 build/m1n1.bin
}

do_install() {
	vinstall build/m1n1.bin 644 usr/lib/asahi-boot
}

post_install() {
	vlicense LICENSE
	vinstall m1n1.conf.example 644 etc m1n1.conf
	vinstall ${FILESDIR}/m1n1-kernel-hook.confd 644 etc/default m1n1-kernel-hook
	vinstall ${FILESDIR}/kernel.d/m1n1.post-install 744 etc/kernel.d/post-install 50-m1n1
}
