From bd138afa2f01f376ee8dadbd81c3f67a94ae43cc Mon Sep 17 00:00:00 2001
From: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
Date: Fri, 22 Sep 2023 04:26:35 +0200
Subject: [PATCH] Run flash-kernel on all platforms and update-initramfs on
 ls1028a

---
 mkimage.sh | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/mkimage.sh b/mkimage.sh
index 5a23bca..daa97e5 100755
--- a/mkimage.sh
+++ b/mkimage.sh
@@ -97,17 +97,14 @@ set -- "$@" --include="apt apt-utils apt-listbugs apt-file cron cryptsetup lvm2
 set -- "$@" --include="busybox console-data console-setup cpio file flash-kernel gnupg gpgv htop kbd lm-sensors readline-common usbutils xdg-utils bsdmainutils less nano micro vim alsa-utils dosfstools python3-psutil reform-handbook"
 # miscellaneous
 set -- "$@" --include="brightnessctl brightness-udev ca-certificates debian-archive-keyring dialog gpm ncurses-term locales bash-completion man-db cryptsetup-initramfs linux-image-arm64 linux-headers-arm64 reform-tools"
-# should not be necessary anymore because mmdebstrap sets up systemd-firstboot
-#	--skip=cleanup/reproducible
 # apt preferences
 set -- "$@" --setup-hook='{ echo "Package: *"; echo "Pin: release n=reform, l=reform"; echo "Pin-Priority: 990"; } > "$1"/etc/apt/preferences.d/reform.pref'
 # The board specific kernel commandline arguments now live in
 # /usr/share/flash-kernel/ubootenv.d/00reform2_ubootenv which does the
 # platform detection and then adds the options to ${bootargs}.
-set -- "$@" --essential-hook='{ echo LINUX_KERNEL_CMDLINE=\"\"; echo LINUX_KERNEL_CMDLINE_DEFAULTS=\"\"; } > "$1"/etc/default/flash-kernel'
 # We still want to overwrite /etc/default/flash-kernel because by default it will contain
 # LINUX_KERNEL_CMDLINE="quiet" and we don't want that
-#
+set -- "$@" --essential-hook='{ echo LINUX_KERNEL_CMDLINE=\"\"; echo LINUX_KERNEL_CMDLINE_DEFAULTS=\"\"; } > "$1"/etc/default/flash-kernel'
 # select timezone and locales
 # FIXME: this should be done by a firstboot script
 set -- "$@" \
@@ -160,15 +157,18 @@ for PLATFORM in $PLATFORMS; do
 	# fill $@ array with options passed to mmdebstrap
 	set -- --variant=custom --skip=update,setup,cleanup \
 		--setup-hook='mmtarfilter --path-exclude="/dev/*" --path-include=/dev/pts --path-include=/dev/shm < target-userland.tar | tar --numeric-owner --xattrs --xattrs-include="*" --directory "$1" --extract --file -' \
-		--customize-hook="upload flash-$PLATFORM.bin /boot/flash.bin"
-	case "$PLATFORM" in
-		ls1028a) set -- "$@" --customize-hook='upload ls1028a-mhdpfw.bin /boot/ls1028a-mhdpfw.bin';;
-	esac
-	set -- "$@" \
+		--customize-hook="upload flash-$PLATFORM.bin /boot/flash.bin" \
 		--chrooted-customize-hook="echo $MACHINE > /etc/flash-kernel/machine" \
 		--chrooted-customize-hook='echo yes > /etc/flash-kernel/ignore-efi' \
 		--chrooted-customize-hook='chown -R root:root /boot/flash.bin' \
-		--chrooted-customize-hook='update-initramfs -u'
+		--chrooted-customize-hook='flash-kernel'
+	case "$PLATFORM" in
+		ls1028a)
+			set -- "$@" \
+				--customize-hook='upload ls1028a-mhdpfw.bin /boot/ls1028a-mhdpfw.bin' \
+				--chrooted-customize-hook='update-initramfs -u'
+			;;
+	esac
 	mmdebstrap "$@" unstable - \
 	| mmtarfilter --path-exclude='*' --path-include=/boot \
 		--path-include='/boot/*' --strip-components=2 \
@@ -177,7 +177,7 @@ for PLATFORM in $PLATFORMS; do
 		--tarball - boot.ext2
 
 	# make sure that the filesystem includes boot.scr
-	debugfs boot.ext2 -R "stat boot.scr" \
+	/usr/sbin/debugfs boot.ext2 -R "stat boot.scr" \
 		| sed 's/ \+/ /g' | grep --quiet "Type: regular Mode: 0644 Flags: 0x0"
 
 	IMGNAME=reform-system-$PLATFORM.img
-- 
GitLab