[PATCH 1/1] kas-container: detect build system on clean commands

43 views
Skip to first unread message

Felix Moessbauer

unread,
Jul 30, 2023, 9:17:06 PM7/30/23
to kas-...@googlegroups.com, jan.k...@siemens.com, Felix Moessbauer
This patch reworks the kas-container clean* logic to support passing a
kas configuration file. In case this file is passed, the build system is
read from the file and the clean command is called accordingly.

Signed-off-by: Felix Moessbauer <felix.mo...@siemens.com>
---
kas-container | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/kas-container b/kas-container
index 36784cb..056d49b 100755
--- a/kas-container
+++ b/kas-container
@@ -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"
@@ -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 \
@@ -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"
@@ -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')"
--
2.39.2

Jan Kiszka

unread,
Aug 8, 2023, 3:31:53 AM8/8/23
to Felix Moessbauer, kas-...@googlegroups.com
On 31.07.23 03:16, Felix Moessbauer wrote:
> This patch reworks the kas-container clean* logic to support passing a
> kas configuration file. In case this file is passed, the build system is
> read from the file and the clean command is called accordingly.
>
> Signed-off-by: Felix Moessbauer <felix.mo...@siemens.com>
> ---
> kas-container | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/kas-container b/kas-container
> index 36784cb..056d49b 100755
> --- a/kas-container
> +++ b/kas-container
> @@ -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"

Was considering this in the past, but what is the advantage? Yocto users
will never use this extended format, and for isar users it's about
adding --isar vs. <what-was-the-kas-file-again?>.

Jan
Siemens AG, Technology
Linux Expert Center

MOESSBAUER, Felix

unread,
Aug 31, 2023, 3:26:53 AM8/31/23
to Kiszka, Jan, kas-...@googlegroups.com

It is just a convenience thing. With the proposed patch, the
build/shell command can just be replaced with clean. In addition, the
default .config.yaml is now correctly detected, enabling the following
pattern for both ISAR and Yocto:

- kas menu
- kas build
- kas clean

Best regards,
Felix

Jan Kiszka

unread,
Aug 31, 2023, 3:28:40 AM8/31/23
to MOESSBAUER, Felix (T CED INW-CN), kas-...@googlegroups.com
As I wrote above: We are only replacing one less convenient command
pattern with another, we are not simplifying the usage. And Yocto does
not need it anyway. I still don't see any value.

Jan

Jan Kiszka

unread,
Aug 31, 2023, 3:34:03 AM8/31/23
to MOESSBAUER, Felix (T CED INW-CN), kas-...@googlegroups.com
Wait... The actual value is in that .config.yaml parsing. That obsoletes
--isar, true. For explicit config specification, there is no added
value. Let's make that clear in the commit log, and I may look at this
differently.

Felix Moessbauer

unread,
Aug 31, 2023, 5:55:28 AM8/31/23
to kas-...@googlegroups.com, jan.k...@siemens.com, Felix Moessbauer
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 clean" on an ISAR build that was configured
with "kas menu". Previously, "kas --isar clean" needed to be executed in
this situation.

Signed-off-by: Felix Moessbauer <felix.mo...@siemens.com>
---
Changes since v1:

- update commit message to cover default config use-case

kas-container | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/kas-container b/kas-container
index 36784cb..056d49b 100755
--- a/kas-container
+++ b/kas-container
@@ -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"
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')"
--
2.39.2

Jan Kiszka

unread,
Aug 31, 2023, 7:48:24 AM8/31/23
to Felix Moessbauer, kas-...@googlegroups.com
On 31.08.23 11:55, 'Felix Moessbauer' via kas-devel wrote:
> 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 clean" on an ISAR build that was configured
> with "kas menu". Previously, "kas --isar clean" needed to be executed in
> this situation.

I'm replacing the occurrences of "kas" with "kas-container" while merging.

Thanks,
Jan

Jan Kiszka

unread,
Aug 31, 2023, 7:57:18 AM8/31/23
to Felix Moessbauer, kas-...@googlegroups.com
On 31.08.23 13:48, Jan Kiszka wrote:
> On 31.08.23 11:55, 'Felix Moessbauer' via kas-devel wrote:
>> 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 clean" on an ISAR build that was configured
>> with "kas menu". Previously, "kas --isar clean" needed to be executed in
>> this situation.
>
> I'm replacing the occurrences of "kas" with "kas-container" while merging.
>

And I fixed a shellcheck error.

Jan
Reply all
Reply to author
Forward
0 new messages