Skip to content

Commit

Permalink
kas-container: detect build system on clean commands
Browse files Browse the repository at this point in the history
This patch reworks the kas-container clean* logic to support passing a
kas configuration file. By that, also the default kas file
(.config.yaml) is processed in case no kas file is provided. This makes
it possible to run "kas-container clean" on an ISAR build that was
configured with "kas-container menu". Previously, "kas-container --isar
clean" needed to be executed in this situation.

Signed-off-by: Felix Moessbauer <[email protected]>
[Jan: fixed shellcheck error and massaged commit message]
Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
fmoessbauer authored and jan-kiszka committed Aug 31, 2023
1 parent 595d949 commit fa6cdaa
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions kas-container
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ usage()
printf "%b" "Usage: $0 [OPTIONS] { build | shell } [KASOPTIONS] [KASFILE]\n"
printf "%b" " $0 [OPTIONS] { checkout | dump } [KASOPTIONS] [KASFILE]\n"
printf "%b" " $0 [OPTIONS] for-all-repos [KASOPTIONS] [KASFILE] COMMAND\n"
printf "%b" " $0 [OPTIONS] { clean | cleansstate | cleanall}\n"
printf "%b" " $0 [OPTIONS] { clean | cleansstate | cleanall} [KASFILE]\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"
Expand Down Expand Up @@ -113,7 +113,6 @@ enable_oe_mode() {

run_clean() {
if [ -n "${KAS_ISAR_ARGS}" ]; then
set_container_image_var
# SC2086: Double quote to prevent globbing and word splitting.
# shellcheck disable=2086
trace ${KAS_CONTAINER_COMMAND} run -v "${KAS_BUILD_DIR}":/build:rw \
Expand Down Expand Up @@ -285,9 +284,9 @@ while [ $# -gt 0 ]; do
usage
;;
clean|cleansstate|cleanall)
[ $# -eq 1 ] || usage
run_clean "$1"
exit 0
KAS_CMD=$1
shift 1
break
;;
shell)
KAS_REPO_MOUNT_OPT_DEFAULT="rw"
Expand Down Expand Up @@ -420,6 +419,13 @@ fi

set_container_image_var

# short circuit for clean* commands. We just need
# the build-system information, but no repo mounts, etc...
if echo "${KAS_CMD}" | grep -qe "^clean"; then
run_clean "${KAS_CMD}"
exit 0
fi

KAS_REPO_MOUNT_OPT="${KAS_REPO_MOUNT_OPT:-${KAS_REPO_MOUNT_OPT_DEFAULT}}"

KAS_FILES="$(echo "${KAS_FILES}" | sed 's|'"${KAS_REPO_DIR}"'/|/repo/|g')"
Expand Down

0 comments on commit fa6cdaa

Please sign in to comment.