Register aarch64 in binfmt misc (#694)

This modifies commit 6dc45a80e764eacd6e311c32164b623bbe7f8e08 for the
arm64 branch. For 64-bit builds we need to register qemu-aarch64-static
instead.

Improves on #685
This commit is contained in:
Stefan Becker 2023-05-09 16:27:36 +03:00 committed by GitHub
parent 7c750947a9
commit a86d732f58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,10 +109,10 @@ case $(uname -m) in
;; ;;
esac esac
# Check if qemu-arm-static and /proc/sys/fs/binfmt_misc are present # Check if qemu-aarch64-static and /proc/sys/fs/binfmt_misc are present
if [[ "${binfmt_misc_required}" == "1" ]]; then if [[ "${binfmt_misc_required}" == "1" ]]; then
if ! qemu_arm=$(which qemu-arm-static) ; then if ! qemu_arm=$(which qemu-aarch64-static) ; then
echo "qemu-arm-static not found (please install qemu-user-static)" echo "qemu-aarch64-static not found (please install qemu-user-static)"
exit 1 exit 1
fi fi
if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
@ -123,13 +123,15 @@ if [[ "${binfmt_misc_required}" == "1" ]]; then
fi fi
echo "binfmt_misc mounted" echo "binfmt_misc mounted"
fi fi
# Register qemu-arm for binfmt_misc (binfmt_misc won't care duplicate entries unless they have common names) if ! grep -q "^interpreter ${qemu_arm}" /proc/sys/fs/binfmt_misc/qemu-aarch64* ; then
reg="echo ':qemu-arm-rpi:M::"\ # Register qemu-aarch64 for binfmt_misc
"\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:"\ reg="echo ':qemu-aarch64-rpi:M::"\
"\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:"\
"\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:"\ "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:"\
"$qemu_arm:F' > /proc/sys/fs/binfmt_misc/register" "${qemu_arm}:F' > /proc/sys/fs/binfmt_misc/register"
echo "Registering qemu-arm for binfmt_misc..." echo "Registering qemu-aarch64 for binfmt_misc..."
sudo bash -c "$reg" 2>/dev/null || true sudo bash -c "${reg}" 2>/dev/null || true
fi
fi fi
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM