[multipass] improve support for arm64 #5

Merged
Ark74 merged 1 commits from improve_arm64_mp into main 2026-01-12 16:34:37 +00:00
1 changed files with 57 additions and 14 deletions

View File

@ -33,14 +33,16 @@
set -euo pipefail set -euo pipefail
DPKG_ARCH="$(dpkg --print-architecture)"
# Debian 13 (Trixie) official cloud image (qcow2). Multipass can launch from URL/file:// on Linux. # Debian 13 (Trixie) official cloud image (qcow2). Multipass can launch from URL/file:// on Linux.
# Source: Debian cloud images live under cloud.debian.org/images/cloud/ ('genericcloud' includes cloud-init). # Source: Debian cloud images live under cloud.debian.org/images/cloud/ ('genericcloud' includes cloud-init).
DEBIAN13_IMAGE_URL="${DEBIAN13_IMAGE_URL:-https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.qcow2}" DEBIAN13_IMAGE_URL="${DEBIAN13_IMAGE_URL:-https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-${DPKG_ARCH}.qcow2}"
IMAGE="${IMAGE:-24.04}" IMAGE="${IMAGE:-24.04}"
BASE="${BASE:-ubu2404}" BASE="${BASE:-ubu2404}"
COUNT="${COUNT:-1}" COUNT="${COUNT:-1}"
CPUS="${CPUS:-3}" [ "$DPKG_ARCH" = "arm64" ] && CPUS="${CPUS:-2}" # SBC don't have spare CPUs.
[ "$DPKG_ARCH" = "amd64" ] && CPUS="${CPUS:-3}"
MEM="${MEM:-4G}" MEM="${MEM:-4G}"
DISK="${DISK:-20G}" DISK="${DISK:-20G}"
@ -53,6 +55,8 @@ LOCAL_VARS_URL="${LOCAL_VARS_URL:-https://raw.githubusercontent.com/iiab/iiab/re
WAIT_TRIES="${WAIT_TRIES:-60}" # used ONLY for the first auto-resume WAIT_TRIES="${WAIT_TRIES:-60}" # used ONLY for the first auto-resume
WAIT_SLEEP="${WAIT_SLEEP:-5}" WAIT_SLEEP="${WAIT_SLEEP:-5}"
STAGGER="${STAGGER:-20}" STAGGER="${STAGGER:-20}"
RESUME_TRIES="${RESUME_TRIES:-3}"
RESUME_RETRY_SLEEP="${RESUME_RETRY_SLEEP:-8}"
ACTION="run" ACTION="run"
modules=() modules=()
@ -92,7 +96,7 @@ PR options:
--run-pr N Add PR number and force --run --run-pr N Add PR number and force --run
Env: Env:
IMAGE BASE COUNT CPUS MEM DISK IIAB_PR IIAB_FAST LOCAL_VARS_URL WAIT_TRIES WAIT_SLEEP STAGGER IMAGE BASE COUNT CPUS MEM DISK IIAB_PR IIAB_FAST LOCAL_VARS_URL WAIT_TRIES WAIT_SLEEP STAGGER RESUME_TRIES RESUME_RETRY_SLEEP
EOF EOF
} }
@ -145,7 +149,7 @@ if [[ ( "$FIRST_UBUNTU" == "1" || "$FIRST_DEBIAN" == "1" ) && "$BOTH_DISTROS" !=
echo "[ERROR] --first-ubuntu/--first-debian requires --both-distros." echo "[ERROR] --first-ubuntu/--first-debian requires --both-distros."
exit 2 exit 2
fi fi
# ---- # ----
# Default module # Default module
if [[ "${#modules[@]}" -eq 0 ]]; then if [[ "${#modules[@]}" -eq 0 ]]; then
@ -439,17 +443,56 @@ resume_iiab() {
fi fi
fi fi
multipass exec "$vm" -- bash -lc ' # Retry on rc=255 (SSH connection dropped; often reboot/network restart during apt/upgrade)
set -euo pipefail # Also neutralize apt-listchanges/pagers to avoid "Waiting for data..." stalls.
echo "--- resume: sudo iiab -f ---" local attempt r
if command -v iiab >/dev/null 2>&1; then r=1
sudo iiab -f for attempt in $(seq 1 "$RESUME_TRIES"); do
else echo "[INFO] Resume attempt ${attempt}/${RESUME_TRIES} on $vm"
echo "[ERROR] iiab command not found; install likely not finished."
exit 89 multipass exec "$vm" -- bash -lc '
set -euo pipefail
echo "--- resume: sudo /usr/sbin/iiab -f ---"
if ! sudo test -x /usr/sbin/iiab; then
echo "[ERROR] /usr/sbin/iiab not found/executable; install likely not finished."
exit 89
fi
# Avoid interactive/pager behaviour during apt actions that IIAB may trigger.
# (apt-listchanges commonly causes: "Waiting for data... (interrupt to abort)")
sudo env \
DEBIAN_FRONTEND=noninteractive \
APT_LISTCHANGES_FRONTEND=none \
NEEDRESTART_MODE=a \
TERM=dumb \
PAGER=cat \
/usr/sbin/iiab -f
echo "--- resume done ---"
'
r=$?
if [[ "$r" -eq 0 ]]; then
break
fi fi
echo "--- resume done ---"
' if [[ "$r" -eq 255 ]]; then
echo "[WARN] multipass exec rc=255 (connection dropped; likely reboot). Waiting for VM and retrying..."
if ! wait_for_vm "$vm"; then
echo "[ERROR] VM did not become ready after reconnect wait: $vm"
r=88
break
fi
sleep "$RESUME_RETRY_SLEEP"
continue
fi
# Any other non-zero: don't loop forever.
break
done
exit "$r"
} >"$log" 2>&1 } >"$log" 2>&1
echo "$?" >"$rc" echo "$?" >"$rc"
set -e set -e