diff --git a/srcpkgs/m1n1/files/kernel.d/m1n1.post-install b/srcpkgs/m1n1/files/kernel.d/m1n1.post-install new file mode 100755 index 00000000000..48eb4378205 --- /dev/null +++ b/srcpkgs/m1n1/files/kernel.d/m1n1.post-install @@ -0,0 +1,58 @@ +#!/bin/sh +# +# Kernel hook for m1n1, taken from update-m1n1 and efibootmgr. +# +# Arguments passed to this script: $1 pkgname, $2 version. + +set -e + +PKGNAME="$1" +VERSION="$2" + +[ -e "${ROOTDIR}/etc/default/m1n1-kernel-hook" ] && . "${ROOTDIR}/etc/default/m1n1-kernel-hook" +[ -d "${BOOT}" ] || return 0 +[ -d "${M1N1_T}" ] || return 0 + +m1n1config=/run/m1n1.conf +: >"$m1n1config" + +if [ -e "$CONFIG" ]; then + echo "Reading m1n1 config from $CONFIG:" + while read line; do + case "$line" in + "") ;; + \#*) ;; + chosen.*=*|display=*) + echo "$line" >> "$m1n1config" + echo "Option: $line" + ;; + *) + echo "Ignoring unknown option: $line" + ;; + esac + done <$CONFIG +fi + +case "$PAYLOAD" in + kernel) + cat "${M1N1}" $m1n1config >"${TARGET}.new" + cat ${DTBS} >>"${TARGET}.new" + gzip -c "${BOOT}/initramfs-${VERSION}.img" >>"${TARGET}.new" + gzip -c "${BOOT}/vmlinux-${VERSION}" >>"${TARGET}.new" + echo "Payload: m1n1 config dtbs initram kernel" + ;; + uboot) + cat "${M1N1}" ${DTBS} >"${TARGET}.new" + gzip -c "${U_BOOT}" >>"${TARGET}.new" + cat $m1n1config >>"${TARGET}.new" + echo "Payload: m1n1 dtbs uboot config" + ;; + *) + echo "Error: unknown PAYLOAD" && return 1 + ;; +esac + +[ -e "$TARGET" ] && mv -f "$TARGET" "${TARGET}.old" +mv -f "${TARGET}.new" "$TARGET" + +echo "m1n1 updated at ${TARGET}" diff --git a/srcpkgs/m1n1/files/m1n1-kernel-hook.confd b/srcpkgs/m1n1/files/m1n1-kernel-hook.confd new file mode 100644 index 00000000000..64547b4ef76 --- /dev/null +++ b/srcpkgs/m1n1/files/m1n1-kernel-hook.confd @@ -0,0 +1,11 @@ +CONFIG=/etc/m1n1.conf +# payload can be either kernel or uboot (default) +PAYLOAD=uboot +# location where kernel, initramfs, dtbs are located +BOOT=/boot +DTBS=${BOOT}/dtbs/"dtbs-${VERSION}"/apple/*.dtb +U_BOOT=/usr/lib/asahi-boot/u-boot-nodtb.bin +M1N1=/usr/lib/asahi-boot/m1n1.bin +# location in ESP where m1n1 payload is put +M1N1_T=/boot/efi/m1n1 +TARGET=${M1N1_T}/boot.bin diff --git a/srcpkgs/m1n1/files/m1n1.conf b/srcpkgs/m1n1/files/m1n1.conf new file mode 100644 index 00000000000..6d847452dc5 --- /dev/null +++ b/srcpkgs/m1n1/files/m1n1.conf @@ -0,0 +1,23 @@ +# This configuration file specifies options for the m1n1 bootloader. +# +# Be careful when editing this file, as incorrect settings can cause your system to fail to boot. +# +# Display configuration (Mac Mini / Mac Studio only) + +# Force re-configuration of the display to defaults in m1n1 stage 2 +# This is redundant unless your m1n1 stage 1 is buggy or ancient +#display=auto + +# Configure the boot display to the default 4K mode +#display=3840x2160 + +# Configure the boot display to 4K at 60Hz (or closest available) +#display=3840x2160@60 + +# Configure the boot display to 4K at 59.97Hz (or closest available) +#display=3840x2160@59.94 + +# Add an arbitrary property to /chosen in the device tree +#chosen.foo=bar +# chosen.bootargs=console=tty0 loglevel=4 root=/dev/nvme0n1p6 rootwait rw + diff --git a/srcpkgs/m1n1/template b/srcpkgs/m1n1/template new file mode 100644 index 00000000000..802ec2154e1 --- /dev/null +++ b/srcpkgs/m1n1/template @@ -0,0 +1,37 @@ +# Template file for 'm1n1' +pkgname=m1n1 +version=1.4.17 +revision=1 +archs="aarch64*" +hostmakedepends="ImageMagick void-artwork" +short_desc="Asahi Linux bootloader" +maintainer="Will Springer , dkwo " +license="MIT" +homepage="https://asahilinux.org" +distfiles="https://github.com/AsahiLinux/m1n1/archive/refs/tags/v${version}.tar.gz" +checksum=59c960ada35880bf39e033d6cc5ac0079a693a3bb17fb06dfe91e431d2773f96 +conf_files="/etc/m1n1.conf /etc/default/m1n1-kernel-hook" + +post_extract() { + for size in 128 256; do + magick /usr/share/icons/hicolor/${size}x${size}/apps/void-logo.png \ + -background black \ + -flatten \ + -depth 8 \ + rgba:data/bootlogo_${size}.bin + done +} + +do_build() { + unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS + make RELEASE=1 ARCH=${CROSS_BUILD:+${XBPS_CROSS_TRIPLET}-} build/m1n1.bin +} + +do_install() { + vinstall build/m1n1.bin 644 usr/lib/asahi-boot + vlicense LICENSE + + vinstall ${FILESDIR}/m1n1.conf 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 +}