Skip to content

cosmetic: clean up build warnings (locale, setfont, GPG, oras)#9684

Merged
igorpecovnik merged 2 commits intomainfrom
fix-chroot-locale-warnings
Apr 16, 2026
Merged

cosmetic: clean up build warnings (locale, setfont, GPG, oras)#9684
igorpecovnik merged 2 commits intomainfrom
fix-chroot-locale-warnings

Conversation

@igorpecovnik
Copy link
Copy Markdown
Member

@igorpecovnik igorpecovnik commented Apr 16, 2026

Summary

Silences five categories of noisy but harmless warnings that clutter every image build log. Two commits, 4 files, +46 / -7 lines.

Commit 1: chroot environment cleanup

warning cause fix
`bash: warning: setlocale: LC_ALL: cannot change locale (sl_SI.UTF-8)` Host's `LC_ALL` leaks into chroot via `chroot_sdcard` Set `LC_ALL=C LANG=C LANGUAGE="" SUDO_USER=""` in wrappers + direct `chroot` calls
`gpg: WARNING: unsafe ownership on homedir` `gpg --dearmor` under sudo uses builder's `~/.gnupg` Temporary `--homedir` for the single dearmor call
`setfont: ERROR kdfontop.c:29 is_kd_text: ioctl(KDGETMODE)` `setupcon --save --force` triggers setfont in chroot (no tty) Redirect stderr to `/dev/null`
`W: Download is performed unsandboxed as root` `_apt` user doesn't exist in fresh rootfs Pre-create `/etc/apt/apt.conf.d/99-armbian-sandbox` before mmdebstrap; removed in cleanup
`id: 'igorp': no such user` `SUDO_USER` leaks from host into chroot Cleared in the same wrapper fix

Files: `lib/functions/logging/runners.sh`, `lib/functions/rootfs/distro-specific.sh`, `lib/functions/rootfs/rootfs-create.sh`

Commit 2: oras 404 cosmetic

warning cause fix
`Error response from registry: failed to fetch` oras manifest probe returns 404 on cache miss (normal) Capture stderr; suppress if "not found"; show as warning for any other error

File: `lib/functions/general/oci-oras.sh`

Test plan

  • Build a desktop image — all five warning categories gone from the log
  • Locale generation still works (`en_US.UTF-8` generated correctly)
  • Console font config saved correctly in `/etc/default/console-setup`
  • Armbian GPG key correctly dearmored in `/usr/share/keyrings/`
  • `99-armbian-sandbox` file absent from the final image (`/etc/apt/apt.conf.d/`)
  • Cache miss shows single clean `[🌱] Artifact is not available in remote cache` line
  • Real oras errors (auth, network) still shown as `[⚠]` warning
  • No regression on arm64 cross-builds (qemu chroot with `LC_ALL=C`)

Summary by CodeRabbit

  • Bug Fixes

    • Prevented host locale and username from leaking into build chroots to avoid inconsistent package behavior and accidental host references.
    • Suppressed noisy console-setup errors during root filesystem creation to reduce misleading build output.
    • Improved external artifact fetch handling by capturing stderr and emitting clearer warnings on unexpected errors.
  • Chores

    • Isolated GPG operations to a temporary home to avoid using the builder's keyring.
    • Applied apt sandbox config only during build and removed it from the final filesystem.

@igorpecovnik igorpecovnik requested a review from a team as a code owner April 16, 2026 10:39
@igorpecovnik igorpecovnik requested review from ArkadiuszRaj and tystuyfzand and removed request for a team April 16, 2026 10:39
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d47ab17f-9c3e-4255-91e6-d19bf747d6e6

📥 Commits

Reviewing files that changed from the base of the PR and between 8081847 and 06bdf1b.

📒 Files selected for processing (4)
  • lib/functions/general/oci-oras.sh
  • lib/functions/logging/runners.sh
  • lib/functions/rootfs/distro-specific.sh
  • lib/functions/rootfs/rootfs-create.sh
✅ Files skipped from review due to trivial changes (1)
  • lib/functions/rootfs/distro-specific.sh
🚧 Files skipped from review as they are similar to previous changes (3)
  • lib/functions/general/oci-oras.sh
  • lib/functions/logging/runners.sh
  • lib/functions/rootfs/rootfs-create.sh

📝 Walkthrough

Walkthrough

Chroot-invoked commands now run with neutralized locale environment variables (LC_ALL="C", LANG="C", LANGUAGE="") and SUDO_USER cleared; Armbian GPG dearmor/import uses a temporary GNUPGHOME removed after use; an APT sandbox drop-in is added before mmdebstrap and removed after; setupcon failures are suppressed.

Changes

Cohort / File(s) Summary
Chroot environment & runners
lib/functions/logging/runners.sh
chroot_sdcard() and chroot_mount() now call run_host_command_logged_raw with LC_ALL="C" LANG="C" LANGUAGE="" injected; SUDO_USER is cleared for chroot invocations.
Distro-specific GPG / chroot calls
lib/functions/rootfs/distro-specific.sh
GPG dearmor/import uses a temporary GNUPGHOME (via mktemp -d --homedir) and removes it afterward; chrooted keyring/apt-key steps are prefixed with forced locale env and empty SUDO_USER.
Rootfs creation / mmdebstrap adjustments
lib/functions/rootfs/rootfs-create.sh
Pre-creates etc/apt/apt.conf.d/99-armbian-sandbox in target (sets APT::Sandbox::User "root") before mmdebstrap and removes it after; setupcon --save --force inside chroot redirects stderr to /dev/null and uses `
OCI/ORAS manifest handling
lib/functions/general/oci-oras.sh
oras manifest fetch stderr is captured to a temp file; when no manifest and stderr is non-empty and not a "not found" message, a warning is emitted; parsing runs only when manifest exists.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped into chroots calm and free,
LANG set to C, no locale spree.
A temp GPG burrow, tidied tight,
apt sandbox placed by lantern light.
setupcon sighs — the build stays bright.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the PR's main objective: silencing multiple cosmetic build warnings across four subsystems (locale, setfont, GPG, and oras).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 fix-chroot-locale-warnings

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 Apr 16, 2026
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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/functions/rootfs/distro-specific.sh (1)

269-275: Use trap-based cleanup for temporary GPG homedir.

If gpg --dearmor fails, rm -rf "${gpg_tmp}" won’t run and temp dirs accumulate. Prefer a trap to guarantee cleanup.

Suggested patch
 	local gpg_tmp
 	gpg_tmp=$(mktemp -d)
+	trap 'rm -rf "${gpg_tmp}"' RETURN
 	gpg --homedir "${gpg_tmp}" --batch --yes --dearmor < "${SRC}"/config/armbian.key > "${basedir}${APT_SIGNING_KEY_FILE}"
-	rm -rf "${gpg_tmp}"
+	trap - RETURN
+	rm -rf "${gpg_tmp}"

Based on learnings scripts in this framework run with set -e, so failure paths should still guarantee cleanup.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/functions/rootfs/distro-specific.sh` around lines 269 - 275, The
temporary GPG homedir created with gpg_tmp=$(mktemp -d) can leak if gpg
--dearmor fails; set a trap immediately after creating gpg_tmp to always remove
it (e.g., trap 'rm -rf "${gpg_tmp}"' EXIT), then run gpg --homedir "${gpg_tmp}"
--batch --yes --dearmor < "${SRC}"/config/armbian.key >
"${basedir}${APT_SIGNING_KEY_FILE}"; after successful use you may optionally
clear the trap (trap - EXIT) or leave it to run on EXIT; reference gpg_tmp,
mktemp -d, gpg --homedir ... --dearmor and rm -rf "${gpg_tmp}" to locate where
to add the trap.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/functions/rootfs/distro-specific.sh`:
- Line 282: The two direct chroot invocations that currently prefix LC_ALL=C
LANG=C should also clear LANGUAGE and SUDO_USER to avoid leaking locale and sudo
user info; update both commands (the one creating the symlink to
armbian-archive-keyring.gpg and the other at the later occurrence) to prefix
with LC_ALL=C LANG=C LANGUAGE= SUDO_USER= before chroot so the environment
becomes: LC_ALL=C LANG=C LANGUAGE= SUDO_USER= chroot "${basedir}" /bin/bash -c
"…".

---

Nitpick comments:
In `@lib/functions/rootfs/distro-specific.sh`:
- Around line 269-275: The temporary GPG homedir created with gpg_tmp=$(mktemp
-d) can leak if gpg --dearmor fails; set a trap immediately after creating
gpg_tmp to always remove it (e.g., trap 'rm -rf "${gpg_tmp}"' EXIT), then run
gpg --homedir "${gpg_tmp}" --batch --yes --dearmor < "${SRC}"/config/armbian.key
> "${basedir}${APT_SIGNING_KEY_FILE}"; after successful use you may optionally
clear the trap (trap - EXIT) or leave it to run on EXIT; reference gpg_tmp,
mktemp -d, gpg --homedir ... --dearmor and rm -rf "${gpg_tmp}" to locate where
to add the trap.
🪄 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

Run ID: 6d387a8e-4a27-49ca-a40b-48fd4560d18f

📥 Commits

Reviewing files that changed from the base of the PR and between 8fb6c51 and f9faa5d.

📒 Files selected for processing (3)
  • lib/functions/logging/runners.sh
  • lib/functions/rootfs/distro-specific.sh
  • lib/functions/rootfs/rootfs-create.sh

Comment thread lib/functions/rootfs/distro-specific.sh Outdated
@igorpecovnik igorpecovnik force-pushed the fix-chroot-locale-warnings branch 2 times, most recently from e313e61 to 9c21142 Compare April 16, 2026 11:30
@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 Apr 16, 2026
@igorpecovnik igorpecovnik force-pushed the fix-chroot-locale-warnings branch 2 times, most recently from 89164b3 to 8081847 Compare April 16, 2026 11:35
@igorpecovnik igorpecovnik changed the title fix: suppress locale/gpg/setfont warnings in chroot operations fix: clean up chroot environment warnings (locale, GPG, setfont, apt sandbox, oras) Apr 16, 2026
@igorpecovnik igorpecovnik requested review from EvilOlaf and rpardini and removed request for ArkadiuszRaj and tystuyfzand April 16, 2026 11:36
@igorpecovnik igorpecovnik changed the title fix: clean up chroot environment warnings (locale, GPG, setfont, apt sandbox, oras) cosmetic: clean up build warnings (locale, setfont, GPG, oras) Apr 16, 2026
@igorpecovnik igorpecovnik requested review from iav and tabrisnet April 16, 2026 12:21
Comment thread lib/functions/rootfs/distro-specific.sh Outdated
@igorpecovnik igorpecovnik force-pushed the fix-chroot-locale-warnings branch from 8081847 to a109ae6 Compare April 16, 2026 21:10
1. LC_ALL="C" LANG="C" LANGUAGE="" SUDO_USER="" in chroot_sdcard/
   chroot_mount wrappers + direct chroot calls in distro-specific.sh
2. Temporary --homedir for gpg --dearmor call
3. setupcon --save --force 2>/dev/null (suppress setfont noise)
4. Pre-create /etc/apt/apt.conf.d/99-armbian-sandbox; removed in cleanup
Capture oras stderr via temp file; suppress if "not found"
(expected cache miss). Any other error still shown as warning.
@igorpecovnik igorpecovnik force-pushed the fix-chroot-locale-warnings branch from a109ae6 to 06bdf1b Compare April 16, 2026 21:12
@igorpecovnik igorpecovnik removed the Needs review Seeking for review label Apr 16, 2026
@igorpecovnik igorpecovnik added the Ready to merge Reviewed, tested and ready for merge label Apr 16, 2026
@igorpecovnik igorpecovnik merged commit aee0fe9 into main Apr 16, 2026
13 checks passed
@igorpecovnik igorpecovnik deleted the fix-chroot-locale-warnings branch April 16, 2026 21:54
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