mirror of https://github.com/armbian/build.git
Merge a51e9fdf2a into ede82dbfe2
This commit is contained in:
commit
21d5215e6f
|
|
@ -0,0 +1,5 @@
|
|||
# Configuration Directory
|
||||
|
||||
This directory contains the build-time configuration files, templates, and data consumed by the Armbian build framework.
|
||||
|
||||
- `ARMBIAN_CACHE_DIR` (default `/armbian/cache`): Host path that, when present, is bind-mounted into the chroot at `/armbian/cache` to share downloaded artifacts (keyrings, packages, etc.) between builds. Override this if your cache lives elsewhere or needs to be relocated for containerized builds.
|
||||
|
|
@ -13,19 +13,59 @@ 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"
|
||||
if ! mkdir -p "${target}/run/user/0"; then
|
||||
display_alert "Failed to prepare chroot runtime directory" "${target}/run/user/0" "err"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# tmpfs size=50% is the Linux default, but we need more.
|
||||
mount -t tmpfs -o "size=99%" tmpfs "${target}/tmp"
|
||||
mount -t tmpfs -o "size=99%" tmpfs "${target}/var/tmp"
|
||||
mount -t tmpfs -o "size=99%" tmpfs "${target}/run/user/0"
|
||||
mount -t proc chproc "${target}"/proc
|
||||
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
|
||||
if ! mountpoint -q "${target}/tmp" && ! mount -t tmpfs -o "size=99%" tmpfs "${target}/tmp"; then
|
||||
display_alert "Failed to mount tmpfs inside chroot" "${target}/tmp" "err"
|
||||
return 1
|
||||
fi
|
||||
if ! mountpoint -q "${target}/var/tmp" && ! mount -t tmpfs -o "size=99%" tmpfs "${target}/var/tmp"; then
|
||||
display_alert "Failed to mount tmpfs inside chroot" "${target}/var/tmp" "err"
|
||||
return 1
|
||||
fi
|
||||
if ! mountpoint -q "${target}/run/user/0" && ! mount -t tmpfs -o "size=99%" tmpfs "${target}/run/user/0"; then
|
||||
display_alert "Failed to mount tmpfs inside chroot" "${target}/run/user/0" "err"
|
||||
return 1
|
||||
fi
|
||||
if ! mountpoint -q "${target}/proc" && ! mount -t proc chproc "${target}/proc"; then
|
||||
display_alert "Failed to mount proc inside chroot" "${target}/proc" "err"
|
||||
return 1
|
||||
fi
|
||||
if ! mountpoint -q "${target}/sys" && ! mount -t sysfs chsys "${target}/sys"; then
|
||||
display_alert "Failed to mount sysfs inside chroot" "${target}/sys" "err"
|
||||
return 1
|
||||
fi
|
||||
if ! mountpoint -q "${target}/dev" && ! mount --bind /dev "${target}/dev"; then
|
||||
display_alert "Failed to bind /dev into chroot" "${target}/dev" "err"
|
||||
return 1
|
||||
fi
|
||||
if ! mountpoint -q "${target}/dev/pts" && ! mount -t devpts chpts "${target}/dev/pts" && ! mount --bind /dev/pts "${target}/dev/pts"; then
|
||||
display_alert "Failed to mount devpts inside chroot" "${target}/dev/pts" "err"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Bind host cache into chroot if present (configurable via ARMBIAN_CACHE_DIR)
|
||||
cache_src="${ARMBIAN_CACHE_DIR:-/armbian/cache}"
|
||||
if [[ -d "${cache_src}" ]]; then
|
||||
if ! mkdir -p "${target}/armbian/cache"; then
|
||||
display_alert "Failed to create cache mountpoint" "${target}/armbian/cache" "warn"
|
||||
elif mountpoint -q "${target}/armbian/cache"; then
|
||||
display_alert "Cache already mounted — skipping cache bind" "${target}/armbian/cache" "debug"
|
||||
else
|
||||
if ! mount --bind "${cache_src}" "${target}/armbian/cache"; then
|
||||
display_alert "Cache bind failed" "${cache_src} -> ${target}/armbian/cache" "warn"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
display_alert "Host cache not found — skipping cache mount" "${cache_src}" "warn"
|
||||
fi
|
||||
}
|
||||
|
||||
# umount_chroot <target>
|
||||
|
|
@ -36,6 +76,11 @@ function umount_chroot() {
|
|||
local target
|
||||
target="$(realpath "$1")" # normalize, remove last slash if dir
|
||||
display_alert "Unmounting" "$target" "info"
|
||||
|
||||
if mountpoint -q "${target}/armbian/cache"; then
|
||||
umount "${target}/armbian/cache" || true
|
||||
fi
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue