[PATCH] Introduce KAS_BUILD_DIR environment variable

211 views
Skip to first unread message

Peter Hatina

unread,
Feb 27, 2021, 10:19:48 AM2/27/21
to kas-...@googlegroups.com, Peter Hatina
This variable can override default build path `${KAS_WORK_DIR}/build`.

Signed-off-by: Peter Hatina <pe...@hatina.eu>
---
docs/command-line.rst | 2 ++
kas/context.py | 5 +++-
tests/test_environment_variables.py | 30 +++++++++++++++++++
.../oe-init-build-env | 3 ++
tests/test_environment_variables/test.yml | 5 ++++
5 files changed, 44 insertions(+), 1 deletion(-)
create mode 100644 tests/test_environment_variables.py
create mode 100755 tests/test_environment_variables/oe-init-build-env
create mode 100644 tests/test_environment_variables/test.yml

diff --git a/docs/command-line.rst b/docs/command-line.rst
index a39eb87..2919001 100644
--- a/docs/command-line.rst
+++ b/docs/command-line.rst
@@ -15,6 +15,8 @@ Environment variables
+=======================+=====================================================+
| ``KAS_WORK_DIR`` | The path of the kas work directory, current work |
| | directory is the default. |
+| ``KAS_BUILD_DIR`` | The path build directory, ``KAS_WORK_DIR/build`` is |
+| | the default. |
+-----------------------+-----------------------------------------------------+
| ``KAS_REPO_REF_DIR`` | The path to the repository reference directory. |
| | Repositories in this directory are used as |
diff --git a/kas/context.py b/kas/context.py
index 36ab017..161fcd9 100644
--- a/kas/context.py
+++ b/kas/context.py
@@ -72,6 +72,9 @@ class Context:
"""
def __init__(self, args):
self.__kas_work_dir = os.environ.get('KAS_WORK_DIR', os.getcwd())
+ self.__kas_build_dir = os.environ.get('KAS_BUILD_DIR',
+ os.path.join(self.__kas_work_dir,
+ 'build'))
self.__kas_repo_ref_dir = os.environ.get('KAS_REPO_REF_DIR', None)
self.setup_initial_environ()
self.config = None
@@ -110,7 +113,7 @@ class Context:
"""
The path to the build directory
"""
- return os.path.join(self.__kas_work_dir, 'build')
+ return self.__kas_build_dir

@property
def kas_work_dir(self):
diff --git a/tests/test_environment_variables.py b/tests/test_environment_variables.py
new file mode 100644
index 0000000..d15e9b2
--- /dev/null
+++ b/tests/test_environment_variables.py
@@ -0,0 +1,30 @@
+import os
+import stat
+import shutil
+from kas import kas
+
+
+def test_build_dir_is_placed_inside_work_dir_by_default(changedir, tmpdir):
+ conf_dir = str(tmpdir.mkdir('test_env_variables'))
+ shutil.rmtree(conf_dir, ignore_errors=True)
+ shutil.copytree('tests/test_environment_variables', conf_dir)
+
+ os.chdir(conf_dir)
+
+ kas.kas(['checkout', 'test.yml'])
+
+ assert(os.path.exists(os.path.join(os.getcwd(), 'build', 'conf')))
+
+
+def test_build_dir_can_be_specified_by_environment_variable(changedir, tmpdir):
+ conf_dir = str(tmpdir.mkdir('test_env_variables'))
+ build_dir = str(tmpdir.mkdir('test_build_dir'))
+ shutil.rmtree(conf_dir, ignore_errors=True)
+ shutil.copytree('tests/test_environment_variables', conf_dir)
+ shutil.rmtree(build_dir, ignore_errors=True)
+ os.chdir(conf_dir)
+
+ os.environ['KAS_BUILD_DIR'] = build_dir
+ kas.kas(['checkout', 'test.yml'])
+
+ assert(os.path.exists(os.path.join(build_dir, 'conf')))
diff --git a/tests/test_environment_variables/oe-init-build-env b/tests/test_environment_variables/oe-init-build-env
new file mode 100755
index 0000000..296ef78
--- /dev/null
+++ b/tests/test_environment_variables/oe-init-build-env
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+true
diff --git a/tests/test_environment_variables/test.yml b/tests/test_environment_variables/test.yml
new file mode 100644
index 0000000..187fc96
--- /dev/null
+++ b/tests/test_environment_variables/test.yml
@@ -0,0 +1,5 @@
+header:
+ version: 10
+
+repos:
+ this:
--
Peter Hatina

PGP: 12DC 9BD0 69E9 EB13

Jan Kiszka

unread,
Mar 1, 2021, 5:19:59 AM3/1/21
to Peter Hatina, kas-...@googlegroups.com
On 27.02.21 16:19, Peter Hatina wrote:
> This variable can override default build path `${KAS_WORK_DIR}/build`.
>
> Signed-off-by: Peter Hatina <pe...@hatina.eu>
> ---
> docs/command-line.rst | 2 ++
> kas/context.py | 5 +++-
> tests/test_environment_variables.py | 30 +++++++++++++++++++
> .../oe-init-build-env | 3 ++
> tests/test_environment_variables/test.yml | 5 ++++
> 5 files changed, 44 insertions(+), 1 deletion(-)
> create mode 100644 tests/test_environment_variables.py
> create mode 100755 tests/test_environment_variables/oe-init-build-env
> create mode 100644 tests/test_environment_variables/test.yml
>
> diff --git a/docs/command-line.rst b/docs/command-line.rst
> index a39eb87..2919001 100644
> --- a/docs/command-line.rst
> +++ b/docs/command-line.rst
> @@ -15,6 +15,8 @@ Environment variables
> +=======================+=====================================================+
> | ``KAS_WORK_DIR`` | The path of the kas work directory, current work |
> | | directory is the default. |
> +| ``KAS_BUILD_DIR`` | The path build directory, ``KAS_WORK_DIR/build`` is |
> +| | the default. |

Maybe better ``${KAS_WORK_DIR}/build``?
Looks good to me otherwise.

Jan

--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

Peto Hatina

unread,
Mar 1, 2021, 5:54:26 AM3/1/21
to kas-devel
Done.

Peter Hatina

unread,
Mar 1, 2021, 7:14:27 AM3/1/21
to kas-...@googlegroups.com, Peter Hatina
This variable can override default build path `${KAS_WORK_DIR}/build`.

Signed-off-by: Peter Hatina <pe...@hatina.eu>
---
docs/command-line.rst | 2 ++
kas/context.py | 5 +++-
tests/test_environment_variables.py | 30 +++++++++++++++++++
.../oe-init-build-env | 3 ++
tests/test_environment_variables/test.yml | 5 ++++
5 files changed, 44 insertions(+), 1 deletion(-)
create mode 100644 tests/test_environment_variables.py
create mode 100755 tests/test_environment_variables/oe-init-build-env
create mode 100644 tests/test_environment_variables/test.yml

diff --git a/docs/command-line.rst b/docs/command-line.rst
index a39eb87..c2e44c6 100644
--- a/docs/command-line.rst
+++ b/docs/command-line.rst
@@ -15,6 +15,8 @@ Environment variables
+=======================+=====================================================+
| ``KAS_WORK_DIR`` | The path of the kas work directory, current work |
| | directory is the default. |
+| ``KAS_BUILD_DIR`` | The path build directory, ``${KAS_WORK_DIR}/build`` |
+| | is the default. |
--
Peter Hatina

PGP: D332 6896 105C 5638

Henning Schild

unread,
Mar 2, 2021, 5:10:48 AM3/2/21
to Peter Hatina, kas-...@googlegroups.com
This looks like "kas-container clean" might need updating as well.

Henning

Am Mon, 1 Mar 2021 13:14:06 +0100
schrieb Peter Hatina <pe...@hatina.eu>:

Jan Kiszka

unread,
Mar 2, 2021, 5:58:31 AM3/2/21
to [ext] Henning Schild, Peter Hatina, kas-...@googlegroups.com
On 02.03.21 11:00, [ext] Henning Schild wrote:
> This looks like "kas-container clean" might need updating as well.
>

Good point (that's why I was not rushing the merge)!

Effectively, KAS_BUILD_DIR on the host needs to be mounted to
/work/build in the container.

Jan

Peter Hatina

unread,
Mar 6, 2021, 1:51:10 PM3/6/21
to kas-...@googlegroups.com, Peter Hatina
This variable can override default build path `${KAS_WORK_DIR}/build`.

Signed-off-by: Peter Hatina <pe...@hatina.eu>
---
docs/command-line.rst | 2 ++
kas-container | 10 +++----
kas/context.py | 5 +++-
tests/test_environment_variables.py | 30 +++++++++++++++++++
.../oe-init-build-env | 3 ++
tests/test_environment_variables/test.yml | 5 ++++
6 files changed, 49 insertions(+), 6 deletions(-)
create mode 100644 tests/test_environment_variables.py
create mode 100755 tests/test_environment_variables/oe-init-build-env
create mode 100644 tests/test_environment_variables/test.yml

diff --git a/docs/command-line.rst b/docs/command-line.rst
index a39eb87..c2e44c6 100644
--- a/docs/command-line.rst
+++ b/docs/command-line.rst
@@ -15,6 +15,8 @@ Environment variables
+=======================+=====================================================+
| ``KAS_WORK_DIR`` | The path of the kas work directory, current work |
| | directory is the default. |
+| ``KAS_BUILD_DIR`` | The path build directory, ``${KAS_WORK_DIR}/build`` |
+| | is the default. |
+-----------------------+-----------------------------------------------------+
| ``KAS_REPO_REF_DIR`` | The path to the repository reference directory. |
| | Repositories in this directory are used as |
diff --git a/kas-container b/kas-container
index b149c1c..7054cbe 100755
--- a/kas-container
+++ b/kas-container
@@ -178,17 +178,17 @@ while [ $# -gt 0 ]; do
;;
clean)
[ $# -eq 1 ] || usage
- KAS_CLEAN_DIR=build/tmp
+ BUILD_DIR=${KAS_BUILD_DIR:-${KAS_WORK_DIR}/build}
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_WORK_DIR}":/work:rw \
- --workdir=/work --rm ${KAS_ISAR_ARGS} \
+ trace ${KAS_CONTAINER_COMMAND} run -v "${BUILD_DIR}":/build:rw \
+ --workdir=/build --rm ${KAS_ISAR_ARGS} \
${KAS_CONTAINER_IMAGE} \
- sudo rm -rf ${KAS_CLEAN_DIR}
+ sudo rm -rf tmp
else
- trace rm -rf "${KAS_WORK_DIR}/${KAS_CLEAN_DIR}"
+ trace rm -rf "${BUILD_DIR}/tmp"
fi
exit 0
;;

Jan Kiszka

unread,
Mar 7, 2021, 7:45:33 AM3/7/21
to Peter Hatina, kas-...@googlegroups.com
This won't be enough. You also need to mount the build dir separately
into the container, for the case it deviates from KAS_WORK_DIR/build.

The mapping so far is KAS_WORK_DIR -> /work, cd'ing to /work in the
container so that kas uses that dir inside. Now you also need to map
KAS_BUILD_DIR, maybe to /build in order to keep work and build separated
in case this was requested by the user. Then you need to set
KAS_BUILD_DIR inside the container to /build.

Jan

Peter Hatina

unread,
Mar 7, 2021, 9:05:46 AM3/7/21
to Jan Kiszka, kas-...@googlegroups.com
I think I do not follow.

If I do not set `KAS_BUILD_DIR`, then I remove `${KAS_WORK_DIR}/build/tmp`.
If I set `KAS_BUILD_DIR`, then I remove `${KAS_BUILD_DIR}/tmp`.

I have tested both cases and it worked just fine.

I thought `kas-container clean` is supposed to remove `tmp` directory. Do I
miss anything?

Thanks.

--
s pozdravom/regards,
Peter Hatina


Jan Kiszka

unread,
Mar 7, 2021, 11:21:25 AM3/7/21
to Peter Hatina, kas-...@googlegroups.com
Yes, the build. If you build with /host/work and /host/build, this will
cause the container to do everything in /host/work (i.e.
/host/work/build). That's because KAS_BUILD_DIR is not propagated as
variable, thus unset in the container. And even if it were: Host paths
may not make sense inside the container.

Peter Hatina

unread,
Mar 7, 2021, 3:32:51 PM3/7/21
to kas-...@googlegroups.com, Peter Hatina
This variable can override default build path `${KAS_WORK_DIR}/build`.

Signed-off-by: Peter Hatina <pe...@hatina.eu>
---
docs/command-line.rst | 2 ++
kas-container | 16 ++++++----
kas/context.py | 5 +++-
tests/test_environment_variables.py | 30 +++++++++++++++++++
.../oe-init-build-env | 3 ++
tests/test_environment_variables/test.yml | 5 ++++
6 files changed, 55 insertions(+), 6 deletions(-)
create mode 100644 tests/test_environment_variables.py
create mode 100755 tests/test_environment_variables/oe-init-build-env
create mode 100644 tests/test_environment_variables/test.yml

diff --git a/docs/command-line.rst b/docs/command-line.rst
index a39eb87..c2e44c6 100644
--- a/docs/command-line.rst
+++ b/docs/command-line.rst
@@ -15,6 +15,8 @@ Environment variables
+=======================+=====================================================+
| ``KAS_WORK_DIR`` | The path of the kas work directory, current work |
| | directory is the default. |
+| ``KAS_BUILD_DIR`` | The path build directory, ``${KAS_WORK_DIR}/build`` |
+| | is the default. |
+-----------------------+-----------------------------------------------------+
| ``KAS_REPO_REF_DIR`` | The path to the repository reference directory. |
| | Repositories in this directory are used as |
diff --git a/kas-container b/kas-container
index b149c1c..d15cdb8 100755
--- a/kas-container
+++ b/kas-container
@@ -178,17 +178,17 @@ while [ $# -gt 0 ]; do
;;
clean)
[ $# -eq 1 ] || usage
- KAS_CLEAN_DIR=build/tmp
+ BUILD_DIR=${KAS_BUILD_DIR:-${KAS_WORK_DIR}/build}
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_WORK_DIR}":/work:rw \
- --workdir=/work --rm ${KAS_ISAR_ARGS} \
+ trace ${KAS_CONTAINER_COMMAND} run -v "${BUILD_DIR}":/build:rw \
+ --workdir=/build --rm ${KAS_ISAR_ARGS} \
${KAS_CONTAINER_IMAGE} \
- sudo rm -rf ${KAS_CLEAN_DIR}
+ sudo rm -rf tmp
else
- trace rm -rf "${KAS_WORK_DIR}/${KAS_CLEAN_DIR}"
+ trace rm -rf "${BUILD_DIR}/tmp"
fi
exit 0
;;
@@ -325,6 +325,12 @@ if [ -n "${KAS_REPO_REF_DIR}" ]; then
-e KAS_REPO_REF_DIR="${KAS_REPO_REF_DIR}"
fi

+if [ -n "${KAS_BUILD_DIR}" ]; then
+ set -- "$@" \
+ -v "${KAS_BUILD_DIR:-${KAS_WORK_DIR}/build}:/build:rw" \
+ -e KAS_BUILD_DIR=/build
+fi
+
for var in TERM KAS_DISTRO KAS_MACHINE KAS_TARGET KAS_TASK \
KAS_PREMIRRORS; do
if [ -n "$(eval echo \$${var})" ]; then

Jan Kiszka

unread,
Mar 8, 2021, 2:30:22 AM3/8/21
to Peter Hatina, kas-...@googlegroups.com
Let's do this unconditionally so that the container looks the same from
inside, irrespective of the host configuration.

Also, we should carefully align KAS_BUILD_DIR with what is done for
KAS_WORK_DIR, namely:

- initialize early, before parsing the options, and by canonicalizing
the path; then you can also use KAS_BUILD_DIR directly for clean
- mkdir -p, or you may run into troubles mounting a not yet existing
directory

Jan

Peter Hatina

unread,
Mar 8, 2021, 2:45:59 PM3/8/21
to kas-...@googlegroups.com, Peter Hatina
This variable can override default build path `${KAS_WORK_DIR}/build`.

Signed-off-by: Peter Hatina <pe...@hatina.eu>
---
docs/command-line.rst | 2 ++
kas-container | 18 +++++++----
kas/context.py | 5 +++-
tests/test_environment_variables.py | 30 +++++++++++++++++++
.../oe-init-build-env | 3 ++
tests/test_environment_variables/test.yml | 5 ++++
6 files changed, 57 insertions(+), 6 deletions(-)
create mode 100644 tests/test_environment_variables.py
create mode 100755 tests/test_environment_variables/oe-init-build-env
create mode 100644 tests/test_environment_variables/test.yml

diff --git a/docs/command-line.rst b/docs/command-line.rst
index a39eb87..c2e44c6 100644
--- a/docs/command-line.rst
+++ b/docs/command-line.rst
@@ -15,6 +15,8 @@ Environment variables
+=======================+=====================================================+
| ``KAS_WORK_DIR`` | The path of the kas work directory, current work |
| | directory is the default. |
+| ``KAS_BUILD_DIR`` | The path build directory, ``${KAS_WORK_DIR}/build`` |
+| | is the default. |
+-----------------------+-----------------------------------------------------+
| ``KAS_REPO_REF_DIR`` | The path to the repository reference directory. |
| | Repositories in this directory are used as |
diff --git a/kas-container b/kas-container
index b149c1c..1f6bf73 100755
--- a/kas-container
+++ b/kas-container
@@ -92,6 +92,12 @@ else
KAS_WORK_DIR="$(pwd)"
fi

+if [ -n "${KAS_BUILD_DIR}" ]; then
+ KAS_BUILD_DIR=$(readlink -f "${KAS_BUILD_DIR}")
+else
+ KAS_BUILD_DIR="${KAS_WORK_DIR}/build"
+fi
+
KAS_CONTAINER_ENGINE="${KAS_CONTAINER_ENGINE:-${KAS_DOCKER_ENGINE}}"
if [ -z "${KAS_CONTAINER_ENGINE}" ]; then
# Try to auto-detect a container engine
@@ -178,17 +184,16 @@ while [ $# -gt 0 ]; do
;;
clean)
[ $# -eq 1 ] || usage
- KAS_CLEAN_DIR=build/tmp
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_WORK_DIR}":/work:rw \
- --workdir=/work --rm ${KAS_ISAR_ARGS} \
+ trace ${KAS_CONTAINER_COMMAND} run -v "${KAS_BUILD_DIR}":/build:rw \
+ --workdir=/build --rm ${KAS_ISAR_ARGS} \
${KAS_CONTAINER_IMAGE} \
- sudo rm -rf ${KAS_CLEAN_DIR}
+ sudo rm -rf tmp
else
- trace rm -rf "${KAS_WORK_DIR}/${KAS_CLEAN_DIR}"
+ trace rm -rf "${KAS_BUILD_DIR}/tmp"
fi
exit 0
;;
@@ -271,6 +276,7 @@ KAS_REPO_DIR=$(git -C "${KAS_FILE_DIR}" rev-parse --show-toplevel 2>/dev/null) \
KAS_FILES=/repo/"$(echo "${KAS_FILES}" | sed 's|'"${KAS_REPO_DIR}"'/||g;s|:|:/repo/|g')"

trace mkdir -p "${KAS_WORK_DIR}"
+trace mkdir -p "${KAS_BUILD_DIR}"

if [ "$(id -u)" -eq 0 ] && [ "${KAS_ALLOW_ROOT}" != "yes" ] ; then
echo "Error: Running as root - may break certain recipes."
@@ -281,6 +287,8 @@ fi

set -- "$@" -v "${KAS_REPO_DIR}":/repo:ro \
-v "${KAS_WORK_DIR}":/work:rw --workdir=/work \
+ -v "${KAS_BUILD_DIR}":/build:rw \
+ -e KAS_BUILD_DIR=/build \
-e USER_ID="$(id -u)" -e GROUP_ID="$(id -g)" --rm

if [ -n "${KAS_SSH_DIR}" ] ; then

Jan Kiszka

unread,
Mar 9, 2021, 6:33:02 AM3/9/21
to Peter Hatina, kas-...@googlegroups.com
Thanks, that looks good to me now. I will give it a try while waiting
for potential further comments.

Jan

Peter Hatina

unread,
Mar 9, 2021, 7:52:50 AM3/9/21
to Jan Kiszka, kas-...@googlegroups.com
Hi Jan,

thanks for the time and patience ;)

> Thanks, that looks good to me now. I will give it a try while waiting
> for potential further comments.

Jan Kiszka

unread,
Mar 9, 2021, 9:12:53 AM3/9/21
to Peter Hatina, kas-...@googlegroups.com
On 09.03.21 13:52, Peter Hatina wrote:
> Hi Jan,
>
> thanks for the time and patience ;)
>
>> Thanks, that looks good to me now. I will give it a try while waiting
>> for potential further comments.
>

Unfortunately, it will take one more round:

checkcode.sh:
...
Checking with flake8
./tests/test_environment_variables.py:2:1: F401 'stat' imported but unused

pytest:
...
def test_layers_exclude(dokas):
> with open('build/conf/bblayers.conf', 'r') as f:
E FileNotFoundError: [Errno 2] No such file or directory: 'build/conf/bblayers.conf'

Peter Hatina

unread,
Mar 9, 2021, 3:40:56 PM3/9/21
to kas-...@googlegroups.com, Peter Hatina
This variable can override default build path `${KAS_WORK_DIR}/build`.

Signed-off-by: Peter Hatina <pe...@hatina.eu>
---
docs/command-line.rst | 2 ++
kas-container | 18 +++++++----
kas/context.py | 5 +++-
tests/test_environment_variables.py | 30 +++++++++++++++++++
.../oe-init-build-env | 3 ++
tests/test_environment_variables/test.yml | 5 ++++
6 files changed, 57 insertions(+), 6 deletions(-)
create mode 100644 tests/test_environment_variables.py
create mode 100755 tests/test_environment_variables/oe-init-build-env
create mode 100644 tests/test_environment_variables/test.yml

diff --git a/docs/command-line.rst b/docs/command-line.rst
index a39eb87..c2e44c6 100644
--- a/docs/command-line.rst
+++ b/docs/command-line.rst
@@ -15,6 +15,8 @@ Environment variables
+=======================+=====================================================+
| ``KAS_WORK_DIR`` | The path of the kas work directory, current work |
| | directory is the default. |
+| ``KAS_BUILD_DIR`` | The path build directory, ``${KAS_WORK_DIR}/build`` |
+| | is the default. |
+-----------------------+-----------------------------------------------------+
| ``KAS_REPO_REF_DIR`` | The path to the repository reference directory. |
| | Repositories in this directory are used as |
diff --git a/kas-container b/kas-container
index b149c1c..1f6bf73 100755
--- a/kas-container
+++ b/kas-container
@@ -92,6 +92,12 @@ else
KAS_WORK_DIR="$(pwd)"
fi

+if [ -n "${KAS_BUILD_DIR}" ]; then
+ KAS_BUILD_DIR=$(readlink -f "${KAS_BUILD_DIR}")
+else
+ KAS_BUILD_DIR="${KAS_WORK_DIR}/build"
+fi
+
KAS_CONTAINER_ENGINE="${KAS_CONTAINER_ENGINE:-${KAS_DOCKER_ENGINE}}"
if [ -z "${KAS_CONTAINER_ENGINE}" ]; then
# Try to auto-detect a container engine
@@ -178,17 +184,16 @@ while [ $# -gt 0 ]; do
;;
clean)
[ $# -eq 1 ] || usage
- KAS_CLEAN_DIR=build/tmp
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_WORK_DIR}":/work:rw \
- --workdir=/work --rm ${KAS_ISAR_ARGS} \
+ trace ${KAS_CONTAINER_COMMAND} run -v "${KAS_BUILD_DIR}":/build:rw \
+ --workdir=/build --rm ${KAS_ISAR_ARGS} \
${KAS_CONTAINER_IMAGE} \
- sudo rm -rf ${KAS_CLEAN_DIR}
+ sudo rm -rf tmp
else
- trace rm -rf "${KAS_WORK_DIR}/${KAS_CLEAN_DIR}"
+ trace rm -rf "${KAS_BUILD_DIR}/tmp"
fi
exit 0
;;
@@ -271,6 +276,7 @@ KAS_REPO_DIR=$(git -C "${KAS_FILE_DIR}" rev-parse --show-toplevel 2>/dev/null) \
KAS_FILES=/repo/"$(echo "${KAS_FILES}" | sed 's|'"${KAS_REPO_DIR}"'/||g;s|:|:/repo/|g')"

trace mkdir -p "${KAS_WORK_DIR}"
+trace mkdir -p "${KAS_BUILD_DIR}"

if [ "$(id -u)" -eq 0 ] && [ "${KAS_ALLOW_ROOT}" != "yes" ] ; then
echo "Error: Running as root - may break certain recipes."
@@ -281,6 +287,8 @@ fi

set -- "$@" -v "${KAS_REPO_DIR}":/repo:ro \
-v "${KAS_WORK_DIR}":/work:rw --workdir=/work \
+ -v "${KAS_BUILD_DIR}":/build:rw \
+ -e KAS_BUILD_DIR=/build \
-e USER_ID="$(id -u)" -e GROUP_ID="$(id -g)" --rm

if [ -n "${KAS_SSH_DIR}" ] ; then
diff --git a/kas/context.py b/kas/context.py
index 36ab017..161fcd9 100644
--- a/kas/context.py
+++ b/kas/context.py
@@ -72,6 +72,9 @@ class Context:
"""
def __init__(self, args):
self.__kas_work_dir = os.environ.get('KAS_WORK_DIR', os.getcwd())
+ self.__kas_build_dir = os.environ.get('KAS_BUILD_DIR',
+ os.path.join(self.__kas_work_dir,
+ 'build'))
self.__kas_repo_ref_dir = os.environ.get('KAS_REPO_REF_DIR', None)
self.setup_initial_environ()
self.config = None
@@ -110,7 +113,7 @@ class Context:
"""
The path to the build directory
"""
- return os.path.join(self.__kas_work_dir, 'build')
+ return self.__kas_build_dir

@property
def kas_work_dir(self):
diff --git a/tests/test_environment_variables.py b/tests/test_environment_variables.py
new file mode 100644
index 0000000..ad418f2
--- /dev/null
+++ b/tests/test_environment_variables.py
@@ -0,0 +1,30 @@
+import os
+ del os.environ['KAS_BUILD_DIR']
+
+ assert(os.path.exists(os.path.join(build_dir, 'conf')))
diff --git a/tests/test_environment_variables/oe-init-build-env b/tests/test_environment_variables/oe-init-build-env
new file mode 100755
index 0000000..296ef78
--- /dev/null
+++ b/tests/test_environment_variables/oe-init-build-env
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+true
diff --git a/tests/test_environment_variables/test.yml b/tests/test_environment_variables/test.yml
new file mode 100644
index 0000000..187fc96
--- /dev/null
+++ b/tests/test_environment_variables/test.yml
@@ -0,0 +1,5 @@
+header:
+ version: 10
+
+repos:
+ this:
--

Jan Kiszka

unread,
Mar 10, 2021, 6:31:10 AM3/10/21
to Peter Hatina, kas-...@googlegroups.com
Thank, applied to next.

Was briefly confused that my test with kas-container still used
/work/build inside, but that was because of the old kas in the
container. Need to test with :next...

Jan

Henning Schild

unread,
Mar 11, 2021, 1:58:16 PM3/11/21
to Peter Hatina, Jan Kiszka, kas-...@googlegroups.com
Am Tue, 09 Mar 2021 13:52:39 +0100
schrieb Peter Hatina <pe...@hatina.eu>:

> Hi Jan,
>
> thanks for the time and patience ;)

I just followed all that without looking at the content too much. Thank
you Peter for your dedication.

Great to see how you moved from a "drive-by" github issue to go all
they way to the list. The process is not much different from a PR but
many people find it harder to use and eventually give up.

Henning

Peter Hatina

unread,
Mar 11, 2021, 2:09:21 PM3/11/21
to Henning Schild, Jan Kiszka, kas-...@googlegroups.com
At first, I was a bit surprised; Github not being used for a change tracking.
It's a pitty, I'd say.

And yes, during the years I developed some habits and missed one important
feature. Was not that hard to implement.With Jan's help I got to know all
other bits and pieces.

Thanks.

Henning Schild

unread,
Mar 12, 2021, 1:16:15 AM3/12/21
to Peter Hatina, Jan Kiszka, kas-...@googlegroups.com
Am Thu, 11 Mar 2021 20:09:14 +0100
schrieb Peter Hatina <pe...@hatina.eu>:

> At first, I was a bit surprised; Github not being used for a change
> tracking. It's a pitty, I'd say.

That has its reasons. Mailing list based means a project is independent
of the git hosting, which basically just serves as storage and will be
easier to replace when need be.
And mailing lists are archived by several services, what they contain
will bu readable for eternity. If one archive goes down, there is
another. So a switch to i.e. gitlab/bitbucket or a project-specific
gitweb will not have to deal with how to export and import MRs and
issues. Something that is close to impossible.

Nobody is planning to leave github, we are just carefull to which
degree to commit to it. In fact a pattern most serious OSS projects are
choosing.
Issues and MR are an addition to take new contributers/users by the
hand and hope they will take it. A pattern only used by some
mailinglist-projects, many choose list-only.

regards,
Henning
Reply all
Reply to author
Forward
0 new messages