From 484a3dda970de6500ec41e862bb81ea06ddba0a3 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Sat, 8 Jan 2022 08:51:33 +0100 Subject: [PATCH] kas-container: Add cleansstate and cleanall To complete the set of clean tasks that OE and Isar offer, add cleansstate to purge SSTATE_DIR and cleanall also delete DL_DIR. Signed-off-by: Jan Kiszka --- kas-container | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/kas-container b/kas-container index 8311d1d..fd07fd0 100755 --- a/kas-container +++ b/kas-container @@ -31,14 +31,19 @@ usage() { printf "%b" "Usage: $0 [OPTIONS] { build | checkout | shell } [KASOPTIONS] [KASFILE]\n" printf "%b" " $0 [OPTIONS] for-all-repos [KASOPTIONS] [KASFILE] COMMAND\n" - printf "%b" " $0 [OPTIONS] clean\n" + printf "%b" " $0 [OPTIONS] { clean | cleansstate | cleanall}\n" printf "%b" " $0 [OPTIONS] menu [KCONFIG]\n" printf "%b" "\nPositional arguments:\n" printf "%b" "build\t\t\tCheck out repositories and build target.\n" printf "%b" "checkout\t\tCheck out repositories but do not build.\n" printf "%b" "shell\t\t\tRun a shell in the build environment.\n" printf "%b" "for-all-repos\t\tRun specified command in each repository.\n" - printf "%b" "clean\t\t\tClean build artifacts, keep downloads.\n" + printf "%b" "clean\t\t\tClean build artifacts, keep sstate cache and " \ + "downloads.\n" + printf "%b" "cleanstate\t\tClean build artifacts and sstate cache, " \ + "keep downloads.\n" + printf "%b" "cleanall\t\tClean build artifacts, sstate cache and " \ + "downloads.\n" printf "%b" "menu\t\t\tProvide configuration menu and trigger " \ "configured build.\n" printf "%b" "\nOptional arguments:\n" @@ -99,6 +104,16 @@ run_clean() { else trace rm -rf "${KAS_BUILD_DIR}/tmp" fi + + if [ "$1" != "clean" ]; then + SSTATE_DIR=${SSTATE_DIR:-${KAS_BUILD_DIR}/sstate-cache} + trace rm -rf "${SSTATE_DIR}" + + if [ "$1" = "cleanall" ]; then + DL_DIR=${DL_DIR:-${KAS_BUILD_DIR}/downloads} + trace rm -rf "${DL_DIR}" + fi + fi } KAS_IMAGE_VERSION_DEFAULT="2.6.3" @@ -220,7 +235,7 @@ while [ $# -gt 0 ]; do --*) usage ;; - clean) + clean|cleansstate|cleanall) [ $# -eq 1 ] || usage run_clean "$1" exit 0