qemu-arm-static isn't needed when already on an arm64 box
When building a Pi image, if you're already on an arm64/aarch64 system, there's no need to try to install/use qemu-arm-static binary for the build.
It is needed if you want to build from amd64. Unless I missed something then you need this in that case.
I will have to test this again. I was building an arm64 image on an arm64 system and kept hitting that and the script failed.
Ok if it fails then I wonder why - I am building on an arm64 arm64 images and it does not fail. It might be that if you install qemu-user-static on your arm machine it would build with the current code. There might be an optimization in place though if its using qemu.
Yeah I will do more testing. I specifically don’t want to use qemu-arm-static because this is being built in a per-minute VPS builder. Dropping the unneeded emulator cuts the assembly by 2/3 or more.
Any update on this?
I am still using the patch and it continues to work and be accurate. I'm building the Pi images on an arm64 Amazon instance where the system type is aarch64/armv8 and not armhf/armv7hf. The use of qemu-arm-static is entirely unnecessary for that.
I have re-confirmed that this patch is still necessary if you are already on an aarch64 system with the right stuff installed:
# uname -a
Linux ip-172-31-15-100 6.1.0-23-cloud-arm64 #1 SMP Debian 6.1.99-1 (2024-07-15) aarch64 GNU/Linux
In the code:
++ uname -m
+ '[' aarch64 '!=' armv7l ']'
+ '[' armhf == armv7l ']'
+ '[' armhf == armhf ']'
+ grep -q gentoo /etc/os-release
++ which qemu-arm-static
+ cp usr/bin/qemu-arm-static
cp: missing destination file operand after 'usr/bin/qemu-arm-static'
Try 'cp --help' for more information.
++++ echo_red 'build failed, unmounting image...'
All of the tests in the code lead to the system still trying to use qemu-arm-static to build an aarch64 system even though it already is an aarch64 system and doesn't need qemu. This is seen later in the code here:
if [ "$(uname -m)" != "armv7l" ] && [ "$(uname -m)" != "aarch64" ] && [ "$(uname -m)" != "arm64" ] ; then
... bunch of stuff omitted ...
else
echo "Building on ARM device a armv7l/aarch64/arm64 system, not using qemu"
chroot . /bin/bash /chroot_script
fi
Replacing this is a better fix contained in #240