Skip to content

Commit

Permalink
m1n1: add kernel trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
dkwo committed Dec 1, 2022
1 parent f3f3403 commit 0ae5e7b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 11 deletions.
8 changes: 0 additions & 8 deletions srcpkgs/m1n1/INSTALL

This file was deleted.

52 changes: 52 additions & 0 deletions srcpkgs/m1n1/files/kernel.d/m1n1.post-install
Original file line number Diff line number Diff line change
@@ -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}"
10 changes: 10 additions & 0 deletions srcpkgs/m1n1/files/m1n1-kernel-hook.confd
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions srcpkgs/m1n1/template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

0 comments on commit 0ae5e7b

Please sign in to comment.