don't ship qemu binary in rootfs cache + armhf image/rootfs building on non-armhf-capable-arm64 hosts (Apple M1+)

- refactor `prepare_host_binfmt_qemu()` out of `prepare_host_noninteractive()` and into `rootfs/qemu-static.sh`
  - further split into more functions and return early to avoid deep nesting
  - implement force import and load of qemu-arm for non-armhf capable arm64 hosts (incl magic numbers)
- enhance `deploy_qemu_binary_to_chroot()` & `undeploy_qemu_binary_from_chroot()`;
  - add 2nd param "caller" for better logging/tracking
  - does sanity-check and preserve existing binary if it exists
- explicitly deploy/undeploy for the 3 cases:
  - image: moved undeploy from `post_debootstrap_tweaks()` into image build proper for consistency
  - rootfs: was leaving trash behind (since post_debootstrap_tweaks never ran for rootfs), now properly undeploys
  - initrd: was already fine, just added caller info
- added `arch-test` host dependency
  - ensure `arch-test ${ARCH}` works during prepare-host
- > tl,dr: "can build 32-bit armv7 armhf using Apple silicon; can use rootfs cache cross-arch reliably"
This commit is contained in:
Ricardo Pardini
2024-12-28 15:15:45 +01:00
committed by Igor
parent 47cffce299
commit 6755e9190a
6 changed files with 192 additions and 103 deletions

View File

@@ -121,7 +121,7 @@ function create_new_rootfs_cache_via_debootstrap() {
skip_target_check="yes" local_apt_deb_cache_prepare "after debootstrap first stage" # just for size reference in logs; skip the target check: debootstrap uses it for second stage.
deploy_qemu_binary_to_chroot "${SDCARD}" # this is cleaned-up later by post_debootstrap_tweaks() @TODO: which is too late for a cache
deploy_qemu_binary_to_chroot "${SDCARD}" "rootfs" # undeployed near the end of this function
display_alert "Installing base system" "Stage 2/2" "info"
declare -g -a if_error_find_files_sdcard=("debootstrap.log") # if command fails, go look for this file and show it's contents during error processing
@@ -270,6 +270,9 @@ function create_new_rootfs_cache_via_debootstrap() {
# `armbian-first-run` will do the same thing later
chroot_sdcard systemctl mask systemd-firstboot.service
# undeploy the qemu binary; we don't want to ship the host's qemu binary in the rootfs cache.
undeploy_qemu_binary_from_chroot "${SDCARD}" "rootfs"
# stage: make rootfs cache archive
display_alert "Ending debootstrap process and preparing cache" "$RELEASE" "info"
wait_for_disk_sync "before tar rootfs"