Skip to content

prepare-host: support Ubuntu resolute's qemu-user packaging changes#9790

Merged
igorpecovnik merged 2 commits into
mainfrom
prepare-host-resolute-qemu-user-static
May 8, 2026
Merged

prepare-host: support Ubuntu resolute's qemu-user packaging changes#9790
igorpecovnik merged 2 commits into
mainfrom
prepare-host-resolute-qemu-user-static

Conversation

@igorpecovnik
Copy link
Copy Markdown
Member

@igorpecovnik igorpecovnik commented May 8, 2026

Summary

Two changes, both required for armbian/build to run on Ubuntu 26.04 (resolute) hosts and for the daily framework Docker image to build there:

  1. Package nameqemu-user-static is virtual on resolute (split into qemu-user-binfmt + qemu-user-binfmt-hwe). apt refuses to auto-pick a provider, so apt-get install errors out:

    E: Package 'qemu-user-static' has no installation candidate
    

    Match the existing python2 release-conditional pattern in prepare-host.sh and pick qemu-user-binfmt on resolute. Older releases keep qemu-user-static.

  2. Binary name (raised by @pyavitz) — qemu-user-binfmt ships the binaries without the -static suffix: /usr/bin/qemu-aarch64 instead of /usr/bin/qemu-aarch64-static. The chroot-deploy code in qemu-static.sh hardcoded the historical name and would fail on resolute hosts even with the apt fix in (1).

    • deploy_qemu_binary_to_chroot: resolve the source path by trying /usr/bin/${QEMU_BINARY} first, fall back to the bare name. Copy the binary to both names inside the chroot, so whichever path the host's binfmt registration points at resolves at chroot time. The old qemu-user-static package registered the -static name; the new qemu-user-binfmt registers the bare name.
    • undeploy_qemu_binary_from_chroot: remove and restore both names symmetrically.

    runners.sh already had a fallback for executing host-side x86 binaries; this PR brings the chroot-side code into parity.

QEMU_BINARY itself stays as qemu-<arch>-static in the per-arch configs — the host-side resolution and the chroot-side dual-deploy mean the rest of the build framework can keep using the historical name.

How to verify

Reproducer that hit (1) in CI:

Once this PR lands and the docker-armbian-build daily run picks it up, both armbian-ubuntu-resolute-amd64-latest and armbian-ubuntu-resolute-arm64-latest should build cleanly.

Test plan

  • ./compile.sh requirements on a resolute host completes without the no installation candidate error.
  • On a resolute host, an actual cross-arch image build (e.g. BOARD=uefi-arm64) successfully copies the qemu binary into the chroot under both qemu-aarch64 and qemu-aarch64-static, and chrooted commands run.
  • On jammy / noble / bookworm / trixie hosts, the installed package set and chroot deploy paths are unchanged.
  • After merge, the next daily run of docker-armbian-build's update_docker.yml produces armbian-ubuntu-resolute-{amd64,arm64}-latest and joins them into armbian-ubuntu-resolute-latest.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed QEMU emulation dependency selection to use the appropriate package variant based on host distribution, improving compatibility.
    • Improved deployment and removal of QEMU binaries inside chroots to preserve alternate binary names and restore original backups, reducing emulation breakage during install/uninstall.

Ubuntu 26.04 (resolute) split qemu-user-static into qemu-user-binfmt
and qemu-user-binfmt-hwe, leaving qemu-user-static as a virtual
package with two providers. apt won't auto-pick a provider, so the
generated Dockerfile (and any direct ./compile.sh requirements run on
a resolute host) fails with:

    E: Package 'qemu-user-static' has no installation candidate

Match the existing python2 pattern (release-conditional host deps)
and pick the concrete non-HWE package on resolute. Older releases
keep qemu-user-static.
@igorpecovnik igorpecovnik requested a review from a team as a code owner May 8, 2026 13:07
@igorpecovnik igorpecovnik requested review from dimitry-ishenko and sgjava and removed request for a team May 8, 2026 13:07
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Make host QEMU package selection conditional on host_release (resolute → qemu-user-binfmt; others → qemu-user-static) and update chroot qemu deploy/undeploy to handle both primary and alternate binary names with preservation/restoration of .armbian.orig backups.

Changes

QEMU host selection and chroot deployment

Layer / File(s) Summary
Conditional Dependency Selection
lib/functions/host/prepare-host.sh
Removes unconditional qemu-user-static and adds a case on host_release to append qemu-user-binfmt for resolute or qemu-user-static otherwise; arch-test remains in common deps.
Deploy: host binary resolution & paths
lib/functions/rootfs/qemu-static.sh
Probe ${QEMU_BINARY} then a derived non--static name, fail if neither exists; compute primary and alternate chroot destination paths and .armbian.orig backup names.
Deploy: preserve and copy binaries
lib/functions/rootfs/qemu-static.sh
Preserve existing primary and alternate binaries as .armbian.orig when present and copy the selected host qemu binary into both primary and alternate destinations (if different).
Undeploy: remove and restore backups
lib/functions/rootfs/qemu-static.sh
Compute alternate deployed path and backups, remove alternate deployed binary when applicable, and restore primary and alternate originals from their .armbian.orig backups if present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I probe the burrow for qemu's home,
Copy two names so chroots can roam,
Resolv'd distros get binfmt delight,
Others keep static through day and night,
Backups kept safe — hop, patch, and write.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title directly addresses the main change: conditional qemu-user package selection on Ubuntu resolute, which is the core fix for the build failure on resolute.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch prepare-host-resolute-qemu-user-static

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size/small PR with less then 50 lines 05 Milestone: Second quarter release Needs review Seeking for review Framework Framework components labels May 8, 2026
@pyavitz
Copy link
Copy Markdown
Collaborator

pyavitz commented May 8, 2026

Not sure if this has been touched on yet, but the bins are also named differently on Resolute.

ls /usr/bin/qemu-aarch64*
/usr/bin/qemu-aarch64  /usr/bin/qemu-aarch64_be

No -static in the name.

Ubuntu 26.04's qemu-user-binfmt drops the -static suffix on the actual
binary names: /usr/bin/qemu-aarch64 instead of /usr/bin/qemu-aarch64
-static. The chroot-deploy code in qemu-static.sh hardcoded the
historical name and would fail on resolute hosts even with the apt
package now resolved.

deploy_qemu_binary_to_chroot:
  - Resolve the host source path: try /usr/bin/${QEMU_BINARY} (the
    -static name) first, fall back to the bare name.
  - Copy to both /usr/bin/qemu-<arch>-static and /usr/bin/qemu-<arch>
    inside the chroot, so whichever path the host's binfmt
    registration points at resolves at chroot time. The qemu-user
    -static package on older releases registers the -static name; the
    qemu-user-binfmt package on resolute registers the bare name.

undeploy_qemu_binary_from_chroot:
  - Remove and restore both names symmetrically.

Reported by @pyavitz on the previous commit's PR.
@github-actions github-actions Bot added size/medium PR with more then 50 and less then 250 lines and removed size/small PR with less then 50 lines labels May 8, 2026
@igorpecovnik igorpecovnik changed the title prepare-host: use qemu-user-binfmt on Ubuntu resolute prepare-host: support Ubuntu resolute's qemu-user packaging changes May 8, 2026
@igorpecovnik
Copy link
Copy Markdown
Member Author

@pyavitz good catch — pushed a follow-up commit (5518b77) that handles the binary-name change too:

  • deploy_qemu_binary_to_chroot() now resolves the host source by trying /usr/bin/qemu-<arch>-static first and falling back to the bare /usr/bin/qemu-<arch> (resolute), and copies the binary to both names inside the chroot so whichever path the host's binfmt registration uses resolves at chroot time.
  • undeploy_qemu_binary_from_chroot() cleans up and restores both names symmetrically.

QEMU_BINARY in the per-arch configs stays at qemu-<arch>-static — the rest of the framework can keep using that name; this code is the only spot that actually touches the host filesystem.

PR title and body updated to reflect the broader scope.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/functions/rootfs/qemu-static.sh (1)

63-101: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

undeploy comment on line 67 says "deploy" — stale copy-paste.

The inline comment at line 67 (# Only deploy the binary if we're actually building a non-native architecture.) inside undeploy_qemu_binary_from_chroot is copied from the deploy function and says "deploy" instead of "undeploy".

📝 Proposed fix
-	# Only deploy the binary if we're actually building a non-native architecture.
+	# Only undeploy the binary if we're actually building a non-native architecture.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/functions/rootfs/qemu-static.sh` around lines 63 - 101, Update the stale
comment inside the function undeploy_qemu_binary_from_chroot: replace the copied
"deploy" wording in the comment that starts with "# Only deploy the binary if
we're actually building a non-native architecture." so it accurately reflects
undeploy semantics (e.g., "Only undeploy the binary if we're actually building a
non-native architecture." or similar). Edit the comment near the
dpkg-architecture check in undeploy_qemu_binary_from_chroot to correct the
wording.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@lib/functions/rootfs/qemu-static.sh`:
- Around line 63-101: Update the stale comment inside the function
undeploy_qemu_binary_from_chroot: replace the copied "deploy" wording in the
comment that starts with "# Only deploy the binary if we're actually building a
non-native architecture." so it accurately reflects undeploy semantics (e.g.,
"Only undeploy the binary if we're actually building a non-native architecture."
or similar). Edit the comment near the dpkg-architecture check in
undeploy_qemu_binary_from_chroot to correct the wording.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5278f85f-f8dd-466a-91a4-5ee18bd8c889

📥 Commits

Reviewing files that changed from the base of the PR and between f00b32b and 5518b77.

📒 Files selected for processing (1)
  • lib/functions/rootfs/qemu-static.sh

@igorpecovnik
Copy link
Copy Markdown
Member Author

[🌱] Deploying qemu-user-static binary to chroot [ qemu-aarch64-static during initrd# (from /usr/bin/qemu-aarch64) ]
[🔨]   '/usr/bin/qemu-aarch64' -> '/root/build/.tmp/mount-no-uuidgen-yet-6902-7197/usr/bin/qemu-aarch64-static'
[🔨]   '/usr/bin/qemu-aarch64' -> '/root/build/.tmp/mount-no-uuidgen-yet-6902-7197/usr/bin/qemu-aarch64'
[🌿] Updating initramfs... [ TMPDIR=/tmp update-initramfs -u -k 6.18.28-current-arm64 ]

Made arm64 image on x86 resolute host.

@igorpecovnik igorpecovnik added Ready to merge Reviewed, tested and ready for merge and removed Needs review Seeking for review labels May 8, 2026
@igorpecovnik igorpecovnik merged commit 3168cf7 into main May 8, 2026
13 checks passed
@igorpecovnik igorpecovnik deleted the prepare-host-resolute-qemu-user-static branch May 8, 2026 18:48
@igorpecovnik
Copy link
Copy Markdown
Member Author

Resolute Docker images works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release Framework Framework components Ready to merge Reviewed, tested and ready for merge size/medium PR with more then 50 and less then 250 lines

Development

Successfully merging this pull request may close these issues.

2 participants