From 4b8023c1cb4c053437193202f141926bd6578107 Mon Sep 17 00:00:00 2001 From: Michael Chus Date: Sat, 28 Mar 2026 10:11:31 +0300 Subject: [PATCH] feat(iso): add --clean-cache option to build-in-container.sh Removes all cached build artifacts: Go cache, NVIDIA/NCCL/cuBLAS downloads, lb package cache, and live-build work dir. Use before a clean rebuild or when switching Debian/kernel versions. Co-Authored-By: Claude Sonnet 4.6 --- iso/builder/build-in-container.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/iso/builder/build-in-container.sh b/iso/builder/build-in-container.sh index 2b2ef70..66183b3 100755 --- a/iso/builder/build-in-container.sh +++ b/iso/builder/build-in-container.sh @@ -11,6 +11,7 @@ BUILDER_PLATFORM="${BEE_BUILDER_PLATFORM:-linux/amd64}" CACHE_DIR="${BEE_BUILDER_CACHE_DIR:-${REPO_ROOT}/dist/container-cache}" AUTH_KEYS="" REBUILD_IMAGE=0 +CLEAN_CACHE=0 . "${BUILDER_DIR}/VERSIONS" @@ -28,14 +29,31 @@ while [ $# -gt 0 ]; do AUTH_KEYS="$2" shift 2 ;; + --clean-cache) + CLEAN_CACHE=1 + shift + ;; *) echo "unknown arg: $1" >&2 - echo "usage: $0 [--cache-dir /path] [--rebuild-image] [--authorized-keys /path/to/authorized_keys]" >&2 + echo "usage: $0 [--cache-dir /path] [--rebuild-image] [--authorized-keys /path/to/authorized_keys] [--clean-cache]" >&2 exit 1 ;; esac done +if [ "$CLEAN_CACHE" = "1" ]; then + echo "=== cleaning build cache: ${CACHE_DIR} ===" + rm -rf "${CACHE_DIR:?}/go-build" \ + "${CACHE_DIR:?}/go-mod" \ + "${CACHE_DIR:?}/tmp" \ + "${CACHE_DIR:?}/bee" \ + "${CACHE_DIR:?}/lb-packages" + echo "=== cleaning live-build work dir: ${REPO_ROOT}/dist/live-build-work ===" + rm -rf "${REPO_ROOT}/dist/live-build-work" + echo "=== done, caches cleared ===" + exit 0 +fi + if ! command -v "$CONTAINER_TOOL" >/dev/null 2>&1; then echo "container tool not found: $CONTAINER_TOOL" >&2 exit 1