diff --git a/srcpkgs/m1n1/INSTALL b/srcpkgs/m1n1/INSTALL deleted file mode 100644 index 4fb11b952aaca5..00000000000000 --- a/srcpkgs/m1n1/INSTALL +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -case $ACTION in -post) - if [ -f "usr/lib/asahi-boot/u-boot-nodtb.bin" ]; then - update-m1n1 - fi - ;; -esac 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 00000000000000..e96d90103ab42c --- /dev/null +++ b/srcpkgs/m1n1/files/kernel.d/m1n1.post-install @@ -0,0 +1,52 @@ +#!/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" + +. "${ROOTDIR}/etc/default/m1n1-kernel-hook" + +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 + +if [ "$PAYLOAD" -eq 1 ]; then + 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" +fi +if [ "$PAYLOAD" -eq 2 ]; then + cat "${M1N1}" ${DTBS} >"${TARGET}.new" + gzip -c "${U_BOOT}" >>"${TARGET}.new" + cat $m1n1config >>"${TARGET}.new" + echo "Payload: m1n1 dtbs uboot config" +fi + +[ -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 00000000000000..483bd6413cecd0 --- /dev/null +++ b/srcpkgs/m1n1/files/m1n1-kernel-hook.confd @@ -0,0 +1,10 @@ +# can be either 1=kernel or 2=uboot +PAYLOAD=1 +U_BOOT=/usr/lib/asahi-boot/u-boot-nodtb.bin +M1N1=/usr/lib/asahi-boot/m1n1.bin +# the location where m1n1 payload is put +TARGET=/boot/m1n1/boot.bin +DTBS=/boot/dtbs/"dtbs-${VERSION}"/apple/*.dtb +CONFIG=/etc/m1n1.conf +# the location where kernel and initramfs are located +BOOT=/boot diff --git a/srcpkgs/m1n1/template b/srcpkgs/m1n1/template index 7f20503193928f..5c3fd32a1793ff 100644 --- a/srcpkgs/m1n1/template +++ b/srcpkgs/m1n1/template @@ -12,7 +12,7 @@ homepage="http://asahilinux.org" distfiles="https://github.com/AsahiLinux/m1n1/archive/refs/tags/v${version}.tar.gz" checksum=3dec944688e1b43e287a9c4d6a3964814b4994bf2e7ff9b6cd60e256a60ee8d8 # make_dirs="/boot/efi/m1n1 0700 root root" -# conf_files="/etc/m1n1.conf" +conf_files="/etc/m1n1.conf /etc/default/m1n1-kernel-hook" post_extract() { for size in 128 256; do @@ -29,6 +29,8 @@ do_build() { do_install() { vinstall build/m1n1.bin 644 usr/lib/asahi-boot vlicense LICENSE -# mkdir $DESTDIR/etc -# touch $DESTDIR/etc/m1n1.conf + mkdir $DESTDIR/etc + touch $DESTDIR/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 }