Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions lib/functions/general/chroot-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function mount_chroot() {
display_alert "mount_chroot called outside of logging section..." "mount_chroot '$1'\n$(stack_color="${magenta_color:-}" show_caller_full)" "warn"
fi

local target
local target cache_src
target="$(realpath "$1")" # normalize, remove last slash if dir
display_alert "mount_chroot" "$target" "debug"
mkdir -p "${target}/run/user/0"
Expand All @@ -26,16 +26,35 @@ function mount_chroot() {
mount -t sysfs chsys "${target}"/sys
mount --bind /dev "${target}"/dev
mount -t devpts chpts "${target}"/dev/pts || mount --bind /dev/pts "${target}"/dev/pts

# Bind host cache into chroot if present (configurable via ARMBIAN_CACHE_DIR)
cache_src="${ARMBIAN_CACHE_DIR:-/armbian/cache}"
if [[ -d "${cache_src}" ]]; then
mkdir -p "${target}/armbian/cache"
if ! mountpoint -q "${target}/armbian/cache" && mount --bind "${cache_src}" "${target}/armbian/cache"; then
:
else
display_alert "cache bind failed or already bound" "${cache_src} -> ${target}/armbian/cache" "warn"
fi
else
display_alert "Host cache not found — skipping cache mount" "${cache_src}" "warn"
fi
}

# umount_chroot <target>
function umount_chroot() {
if [[ "x${LOG_SECTION}x" == "xx" ]]; then
display_alert "umount_chroot called outside of logging section..." "umount_chroot '$1'\n$(stack_color="${magenta_color:-}" show_caller_full)" "warn"
fi
local target
local target cache_src
target="$(realpath "$1")" # normalize, remove last slash if dir
display_alert "Unmounting" "$target" "info"

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!


while grep -Eq "${target}\/(dev|proc|sys|tmp|var\/tmp|run\/user\/0)" /proc/mounts; do
display_alert "Unmounting..." "target: ${target}" "debug"
umount "${target}"/dev/pts || true
Expand Down