From f69844d5e0fa0c6bb42ffcb727010bfdd0d76344 Mon Sep 17 00:00:00 2001
From: Michal Suchanek <hramrach@gmail.com>
Date: Tue, 22 Oct 2024 10:17:11 +0200
Subject: [PATCH] Copy qemu into the chroot

Skipping this step sometimes happens to work on x86. However, in general
the binary emulating the architecture is needed.
---
 mkimage.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mkimage.sh b/mkimage.sh
index f36026d..4356aa8 100755
--- a/mkimage.sh
+++ b/mkimage.sh
@@ -594,6 +594,12 @@ set -- "$@" \
 # any initramfs generated on the target platform using update-initramfs.
 set -- "$@" --customize-hook='rm "$1/etc/initramfs-tools/scripts/local-premount/reform-firstboot-premount" "$1/etc/initramfs-tools/hooks/reform-firstboot-hook" "$1/etc/initramfs-tools/hooks/reform-mkimage-hook"'
 
+# This should be the last customize hook
+set -- "$@" --extract-hook='mkdir -p "$1"/usr/libexec/qemu-binfmt/'
+set -- "$@" --extract-hook='copy-in /usr/libexec/qemu-binfmt/aarch64-binfmt-P /usr/libexec/qemu-binfmt/'
+set -- "$@" --extract-hook='copy-in /usr/bin/qemu-aarch64-static /usr/bin/'
+set -- "$@" --customize-hook='rm -f "$1/usr/libexec/qemu-binfmt/aarch64-binfmt-P" "$1/usr/bin/qemu-aarch64-static"'
+
 case "$DIST" in
 	testing)
 		set -- "$@" testing
-- 
GitLab