fix(rootfs): mount procfs for uutils coreutils in early chroot (native arm64 builds) - #10270
#10270fix(rootfs): mount procfs for uutils coreutils in early chroot (native arm64 builds)#10270lukaszsobala wants to merge 5 commits intoarmbian:mainarmbian/build:mainfrom lukaszsobala:fix/native-arm64-uutils-auxv-chrootlukaszsobala/build:fix/native-arm64-uutils-auxv-chrootCopy head branch name to clipboard
Conversation
…e builds)
Ubuntu 26.04 (resolute) ships uutils as the default coreutils. Those
binaries are built on rustix, which reads the process auxiliary vector at
startup. When the kernel's primary auxv path fails -- observed on arm64
vendor/BSP kernels such as Rockchip RK3588 -- rustix falls back to reading
/proc/self/auxv. Inside a bare chroot that file does not exist, so the
binary panics:
thread 'main' panicked at rustix/.../auxv.rs:269:22:
called `Result::unwrap()` on an `Err` value: ()
This aborts the very first chroot command run against a freshly-extracted
rootfs, during the rootfs-cache extraction phase:
chroot "${basedir}" /bin/bash -c \
"ln -fs armbian-archive-keyring.gpg /usr/share/keyrings/armbian.gpg"
-> Aborted (Error 134)
qemu-user cross-builds are immune: qemu supplies the guest auxv directly,
so the /proc fallback is never taken. It only bites native (e.g.
arm64->arm64) builds, where the framework skips qemu entirely and no
mounts have been set up yet at this early stage.
create_sources_list_and_deploy_repo_key() runs chroot commands before the
normal mount_chroot() has mounted procfs (for the "image-early" caller in
extract_rootfs_artifact). Add mount_chroot_proc_for_uutils(), which mounts
procfs into the target only when it is absent (guarded on
${target}/proc/self/auxv), and registers teardown with the cleanup-handler
registry so the mount is removed even if a later chroot step aborts. It is
a no-op for the "root"/"image-late" callers where mount_chroot() already
mounted procfs, keeping cross-builds and later stages unaffected.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds conditional procfs mounting for Ubuntu 26.04+ uutils coreutils chroot operations, registers cleanup for abort paths, and unmounts procfs on successful completion. Changesuutils procfs support
Estimated code review effort: 3 (Moderate) | ~15–30 minutes Sequence Diagram(s)sequenceDiagram
participant create_sources_list_and_deploy_repo_key
participant mount_chroot_proc_for_uutils
participant target_chroot
participant cleanup_handler
create_sources_list_and_deploy_repo_key->>mount_chroot_proc_for_uutils: Request procfs setup
mount_chroot_proc_for_uutils->>target_chroot: Check /proc/self/auxv
mount_chroot_proc_for_uutils->>target_chroot: Mount procfs when unavailable
mount_chroot_proc_for_uutils->>cleanup_handler: Register teardown callback
create_sources_list_and_deploy_repo_key->>cleanup_handler: Complete procfs cleanup
cleanup_handler->>target_chroot: Unmount procfs if mounted
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@lib/functions/general/chroot-helpers.sh`:
- Around line 127-128: Update lib/functions/general/chroot-helpers.sh lines
127-128 by assigning target_proc="${target}/proc" and passing "${target_proc@Q}"
to both run_host_command_logged calls. At lines 150-150, pass the complete proc
path as "${target_proc@Q}" before the existing || true tokens, preserving the
command behavior while protecting paths containing whitespace or shell
metacharacters.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 75594674-17dd-44d4-b644-283e097cda88
📒 Files selected for processing (2)
lib/functions/general/chroot-helpers.shlib/functions/rootfs/distro-specific.sh
run_host_command_logged re-parses its arguments through `bash -e -o
pipefail -c "$*"`, so paths are word-split a second time by that inner
shell. An unquoted "${target}/proc" containing whitespace or shell
metacharacters would break the mkdir/mount/umount invocations. Quote the
path with @q, matching the framework's convention for command strings that
pass through run_host_command_logged. Addresses CodeRabbit review feedback
on PR armbian#10270.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Armbian rebuilt after applying the coderabbit fixes, still builds on both x86 and arm64 |
|
Any chance for a review? |
Here is a solution to a problem that existed for months but nobody could reproduce so far. I've tested arm64 native builds and x86. Both work correctly.
Problem
Building Ubuntu 26.04 (Resolute) images natively on an arm64 host targeting arm64 fails at the first chroot operation of the rootfs-cache extraction phase:
Root cause
Ubuntu 26.04 ships uutils as the default coreutils. Those binaries are built on rustix, which reads the process auxiliary vector at startup. When the kernel's primary auxv path fails — observed on Rockchip RK3588 vendor BSP kernels — rustix falls back to reading
/proc/self/auxv. Inside a bare chroot that file does not exist, producing theunwrap()panic and aborting the very first chroot command run against a freshly-extracted rootfs.Why it only affects native arm64→arm64 builds
x86 cross-builds are unaffected because qemu-user supplies the auxv directly, so the
/procfallback is never exercised. This only bites native arm64→arm64 builds, where the framework skips qemu setup entirely:At the extraction phase (
extract_rootfs_artifact→create_sources_list_and_deploy_repo_key "image-early"),mount_chroot()has not run yet, so the target has no procfs — and on native builds there is no qemu to paper over the missing/proc/self/auxv.Manual reproduction
Against a rootfs extracted outside the build framework, on a native arm64 RK3588 host:
The fix
Add
mount_chroot_proc_for_uutils()(inlib/functions/general/chroot-helpers.sh, next tomount_chroot) and call it fromcreate_sources_list_and_deploy_repo_key()before its chroot commands, tearing it down at the end of the function. The helper:${target}/proc/self/auxv— mounts procfs only when it is genuinely absent, so it is a no-op when procfs is already present.add_cleanup_handler/execute_and_remove_cleanup_handler, mirroring the prepare/done idiom inhost/mktemp-utils.sh) rather than a bare umount, so the mount is removed even if a later chroot step aborts partway.run_host_command_loggedwrappers anddisplay_alertlogging.Why it's a no-op everywhere else
create_sources_list_and_deploy_repo_key()has three callers:whenrootfs-create.sh:201rootmount_chroot@:167rootfs-image.sh:41image-latemount_chroot@:20create-cache.sh:190image-earlyOnly the
image-earlypath runs bare, and only on native builds does the missing auxv actually panic. On the other two callersmount_chroot()already mounted procfs, so theauxvguard short-circuits and the helper does nothing. Cross-builds keep their existing (working) behavior.Scope
Narrow: the change is confined to the function that contains the failing chroots (
create_sources_list_and_deploy_repo_key) plus a reusable helper. Audit confirmed this function is the only chroot invocation in the extraction phase (write_build_resolv_confmerely writes a file), and placing the guard here makes the function self-sufficient regardless of which caller invoked it.Notes
mount_chrootstage.Summary by CodeRabbit
procfor specific core utilities when needed.procmounts are cleaned up reliably, even if the setup process is interrupted midway.