Skip to content

Conversation

@benhoff
Copy link
Collaborator

@benhoff benhoff commented Nov 21, 2025

Description

This reimplements this pull request, while fixing the edge case (hopefully). #8186

I don't have a bare metal device to test.

How Has This Been Tested?

I haven't checked this yet, I'll run it with a Qt buildout that I have

Checklist:

Please delete options that are not relevant.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

Release Notes

  • Chores
    • Build environment cache is now more safely mounted and unmounted during builds, with improved lifecycle handling and error warnings.
  • Bug Fixes
    • Safer mount/unmount sequences reduce failed bind mounts and preserve runtime stability.
  • Documentation
    • Added configuration docs describing the config directory and the ARMBIAN_CACHE_DIR host cache bind behavior and relocation guidance.

✏️ Tip: You can customize this high-level summary in your review settings.

@benhoff benhoff requested a review from a team as a code owner November 21, 2025 19:25
@benhoff benhoff added the Work in progress Unfinished / work in progress label Nov 21, 2025
@github-actions github-actions bot added the size/small PR with less then 50 lines label Nov 21, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 21, 2025

Walkthrough

The PR adds host cache bind-mount handling to chroot helper functions: mount_chroot now conditionally creates and bind-mounts the host ARMBIAN_CACHE_DIR into target/armbian/cache with error/warning logs; umount_chroot unmounts that bind before existing unmount steps. No public signatures changed.

Changes

Cohort / File(s) Summary
Chroot cache binding
lib/functions/general/chroot-helpers.sh
Added local cache_src handling and conditional creation/bind-mount logic in mount_chroot (with mountpoint checks and warnings on failure); added unmount sequence in umount_chroot to unbind target/armbian/cache before other unmounts.
Docs: config README
config/README.md
Added documentation describing the Configuration Directory and the ARMBIAN_CACHE_DIR environment variable, including default cache path and explanation of the host cache bind into the chroot.

Sequence Diagram(s)

sequenceDiagram
  participant Host
  participant Script as mount_chroot/umount_chroot
  participant TargetFS as target (chroot)

  rect rgba(173,216,230,0.15)
  Host->>Script: provide ARMBIAN_CACHE_DIR (optional)
  Script->>Host: check & create host cache dir (if needed)
  end

  rect rgba(144,238,144,0.12)
  Script->>TargetFS: ensure target/armbian/cache exists
  Script->>TargetFS: mount --bind host_cache -> target/armbian/cache (if not already mountpoint)
  Note right of TargetFS: Warnings logged on create/bind failures
  end

  rect rgba(255,228,196,0.12)
  Script->>TargetFS: umount target/armbian/cache (if mounted)
  Script->>TargetFS: continue existing umount sequence
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single main file change with predictable mount/unmount patterns.
  • Pay attention to mountpoint checks, error/log paths, and correct ordering in umount_chroot.

Possibly related PRs

Suggested reviewers

  • igorpecovnik

Poem

🐇 I hopped in scripts to bind a store,
A tiny cache on chroot's floor,
I mount, I warn, then unmount more,
Soft paws tidy buildroom door. ✨

Pre-merge checks and finishing touches

✅ 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 'Add configurable cache bind for chroot' accurately and concisely describes the main change: adding cache directory binding functionality to chroot operations with configurability.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dc6f301 and a51e9fd.

📒 Files selected for processing (2)
  • config/README.md (1 hunks)
  • lib/functions/general/chroot-helpers.sh (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/functions/general/chroot-helpers.sh
🧰 Additional context used
🧠 Learnings (10)
📚 Learning: 2025-07-17T04:12:33.125Z
Learnt from: pyavitz
Repo: armbian/build PR: 8388
File: config/boards/kickpik2b.conf:1-14
Timestamp: 2025-07-17T04:12:33.125Z
Learning: In the Armbian build system, board configuration files (*.conf) follow a project standard of not including shebang lines, even though they contain bash code and are sourced by the build system. This is an established Armbian convention that individual contributors are expected to follow, and changes to this standard would require broader project maintainer approval.

Applied to files:

  • config/README.md
📚 Learning: 2025-09-27T21:50:04.845Z
Learnt from: tabrisnet
Repo: armbian/build PR: 8678
File: config/kernel/linux-sm8250-edge.config:80-82
Timestamp: 2025-09-27T21:50:04.845Z
Learning: In the Armbian build system, kernel configuration files are generated through this automated process: taking previous config → applying scripted changes from armbian-kernel.sh → running kernel's `make oldconfig` → processing by Armbian machinery back into config files. This automated process properly handles kernel configuration dependencies and reduces the likelihood of manual configuration errors.

Applied to files:

  • config/README.md
📚 Learning: 2025-09-27T21:49:55.796Z
Learnt from: tabrisnet
Repo: armbian/build PR: 8678
File: config/kernel/linux-sm8250-current.config:78-80
Timestamp: 2025-09-27T21:49:55.796Z
Learning: In the Armbian build system, kernel configuration files are generated through an automated process: taking previous config → applying scripted changes from armbian-kernel.sh → running kernel's `make oldconfig` → processing by Armbian machinery back into config files. This automated process properly handles kernel configuration dependencies and reduces the likelihood of manual configuration errors.

Applied to files:

  • config/README.md
📚 Learning: 2025-09-14T11:37:35.089Z
Learnt from: amazingfate
Repo: armbian/build PR: 8619
File: config/sources/families/rockchip.conf:65-72
Timestamp: 2025-09-14T11:37:35.089Z
Learning: In the Armbian build system, patch directories referenced in BOOTPATCHDIR and KERNELPATCHDIR configurations can be non-existent without causing build failures. Empty patch directories are also ignored by git, so missing patch directories should not be flagged as errors during code review.

Applied to files:

  • config/README.md
📚 Learning: 2025-07-23T07:30:52.265Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8417
File: config/boards/orangepi5pro.csc:57-58
Timestamp: 2025-07-23T07:30:52.265Z
Learning: In the Armbian build system, BOOTPATCHDIR can contain board-specific subdirectories (e.g., board_orangepi5pro) for applying patches to specific boards only. The framework automatically checks if such board-specific subdirectories exist for the board being built and applies those patches accordingly.

Applied to files:

  • config/README.md
📚 Learning: 2025-09-27T21:47:58.020Z
Learnt from: tabrisnet
Repo: armbian/build PR: 8678
File: config/kernel/linux-bcm2711-edge.config:859-861
Timestamp: 2025-09-27T21:47:58.020Z
Learning: In the Armbian build system, kernel configuration files in config/kernel/ are generated through an automated process: taking previous config → applying scripted changes from armbian-kernel.sh → running kernel's `make oldconfig` → processing by Armbian machinery back into config files. This automated process properly handles kernel configuration dependencies and reduces the likelihood of manual configuration errors.

Applied to files:

  • config/README.md
📚 Learning: 2025-08-02T05:46:10.664Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-08-02T05:46:10.664Z
Learning: In the Armbian build system, the modern recommended approach for kernel configuration is to use the kernel-config command via "./compile.sh BOARD=boardname BRANCH=branchname kernel-config" instead of the deprecated KERNEL_CONFIGURE=yes flag. This provides a two-step workflow: configure using menuconfig, then build, with better transparency and control over configuration changes.

Applied to files:

  • config/README.md
📚 Learning: 2025-08-03T15:21:20.148Z
Learnt from: pyavitz
Repo: armbian/build PR: 8455
File: config/sources/families/sun50iw1.conf:19-24
Timestamp: 2025-08-03T15:21:20.148Z
Learning: In the Armbian build system, when copying firmware files during family_tweaks_s(), use /lib/firmware/updates/ instead of /lib/firmware/ to avoid conflicts with the Armbian firmware package. The /lib/firmware/updates directory takes precedence in Linux firmware loading hierarchy and is the proper location for user-installed firmware files.

Applied to files:

  • config/README.md
📚 Learning: 2025-05-16T15:34:34.672Z
Learnt from: Grippy98
Repo: armbian/build PR: 8202
File: config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh:2-3
Timestamp: 2025-05-16T15:34:34.672Z
Learning: The shell scripts in the Armbian build system's desktop configuration files, such as config/desktop/trixie/environments/gnome/armbian/create_desktop_package.sh, rely on environment variables like $SRC and $destination that are expected to be set externally before the script is executed.

Applied to files:

  • config/README.md
📚 Learning: 2025-06-14T05:53:10.627Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8298
File: extensions/https_proxy.sh:1-9
Timestamp: 2025-06-14T05:53:10.627Z
Learning: Armbian build framework extensions are NOT designed to run standalone but are called by the supervisor. The framework provides environment variables like USERPATCHES_PATH and SDCARD, and commands are executed with protection via run_host_command_logged and chroot_sdcard functions that use bash -e -o pipefail.

Applied to files:

  • config/README.md
🔇 Additional comments (1)
config/README.md (1)

5-5: Verify mount path consistency with implementation.

There's a discrepancy between the documented path and the AI-generated summaries: the README documents the default as /armbian/cache, but the PR summaries reference target/armbian/cache. This needs verification to ensure documentation matches the actual implementation in lib/functions/general/chroot-helpers.sh.

Please confirm:

  1. What is the actual host-side default path for ARMBIAN_CACHE_DIR?
  2. What is the bind-mount destination path within the chroot?
  3. Should the README reflect the full host path (e.g., /target/armbian/cache) for clarity, or is the relative path correct?

Verify by checking the implementation in the chroot-helpers.sh file and running a test build to confirm the paths are correctly documented.


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 11 Milestone: Fourth quarter release Needs review Seeking for review Framework Framework components labels Nov 21, 2025
Copy link
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: 2

Caution

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

⚠️ Outside diff range comments (1)
lib/functions/general/chroot-helpers.sh (1)

1-41: Document ARMBIAN_CACHE_DIR and add error handling for filesystem mounts.

The variable ARMBIAN_CACHE_DIR is not documented anywhere in the codebase—it only appears in the implementation. The cache mount itself is well-implemented (checks directory existence, validates already-bound mount points, logs warnings), but the early mounts lack error handling: tmpfs, proc, sysfs, and /dev bind mounts have no checks and will fail silently if permissions are denied or the target is read-only.

  1. Add ARMBIAN_CACHE_DIR to documentation (config/README.md or similar) with the default value and use case.
  2. Add error handling to the early mounts in mount_chroot (lines 21–27), since they're prerequisite operations that determine success or failure of the entire chroot setup.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d5bceb9 and dc6f301.

📒 Files selected for processing (1)
  • lib/functions/general/chroot-helpers.sh (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
lib/functions/general/chroot-helpers.sh (2)
lib/functions/image/initrd.sh (1)
  • update_initramfs (23-133)
lib/functions/rootfs/rootfs-create.sh (1)
  • create_new_rootfs_cache_via_debootstrap (54-365)
🔇 Additional comments (1)
lib/functions/general/chroot-helpers.sh (1)

49-56: Cache unmount ordering is correct; no issues identified.

Verification of call sites and the umount_chroot function confirms:

  • Cache unmount (lines 54–56) correctly executes before the proc/sys/dev/tmp/run cleanup loop (lines 58–69)
  • All call sites properly pair mount_chroot with umount_chroot
  • Error handling with || true allows partial failures without stopping cleanup
  • The implementation maintains proper mount/unmount semantics

Comment on lines 53 to 56
cache_src="${ARMBIAN_CACHE_DIR:-/armbian/cache}"
if mountpoint -q "${target}/armbian/cache"; then
umount "${target}/armbian/cache" || true
fi
Copy link
Contributor

@coderabbitai coderabbitai bot Nov 21, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove unused variable assignment.

Line 53 declares and assigns cache_src, but it is never referenced. The unmount logic on lines 54–56 works correctly without it.

Apply this diff to remove the unused variable:

- cache_src="${ARMBIAN_CACHE_DIR:-/armbian/cache}"
- if mountpoint -q "${target}/armbian/cache"; then
+ if mountpoint -q "${target}/armbian/cache"; then
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cache_src="${ARMBIAN_CACHE_DIR:-/armbian/cache}"
if mountpoint -q "${target}/armbian/cache"; then
umount "${target}/armbian/cache" || true
fi
if mountpoint -q "${target}/armbian/cache"; then
umount "${target}/armbian/cache" || true
fi
🤖 Prompt for AI Agents
lib/functions/general/chroot-helpers.sh around lines 53 to 56: remove the unused
variable assignment "cache_src=\"${ARMBIAN_CACHE_DIR:-/armbian/cache}\"" on line
53 since it is never referenced; leave the subsequent mountpoint check and
umount logic intact and ensure no other code in the file expects that variable
before committing the change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ping @benhoff

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@igorpecovnik igorpecovnik added 02 Milestone: First quarter release and removed 11 Milestone: Fourth quarter release labels Nov 22, 2025
@github-actions github-actions bot added size/medium PR with more then 50 and less then 250 lines 11 Milestone: Fourth quarter release Hardware Hardware related like kernel, U-Boot, ... Documentation Documentation changes or additions and removed size/small PR with less then 50 lines labels Nov 23, 2025
@leggewie leggewie removed the 11 Milestone: Fourth quarter release label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

02 Milestone: First quarter release Documentation Documentation changes or additions Framework Framework components Hardware Hardware related like kernel, U-Boot, ... Needs review Seeking for review size/medium PR with more then 50 and less then 250 lines Work in progress Unfinished / work in progress

Development

Successfully merging this pull request may close these issues.

3 participants