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