toes-image-builder/scripts/check-qemu.sh
2026-05-18 06:46:40 +00:00

29 lines
648 B
Bash
Executable File

#! /bin/bash
set -ex
# make sure the repo is properly setup by bootstrap-repo.sh
case "$(uname -m)" in
aarch64|arm64)
echo "native arm64 host detected; qemu-aarch64 binfmt is not required"
exit 0
;;
esac
required_binfmt="/proc/sys/fs/binfmt_misc/qemu-aarch64"
if [ ! -e "$required_binfmt" ]; then
echo "missing qemu-aarch64 binfmt registration" >&2
exit 1
fi
if ! grep -q '^enabled$' "$required_binfmt"; then
echo "qemu-aarch64 binfmt is not enabled" >&2
exit 1
fi
if ! grep -q 'flags:.*F' "$required_binfmt"; then
echo "qemu-aarch64 binfmt lacks F flag; this builder expects systemd-binfmt with fixed interpreter" >&2
exit 1
fi