Currently the timezone inside the container is UTC. By that, the logs
have timestamps in UTC but not in the local time of the caller.
We fix this by forwarding the timezone information into the container.
Closes: #157
Signed-off-by: Felix Moessbauer <
felix.mo...@siemens.com>
---
Changes since RFC:
- remove trailing spaces (we really need a check for that...)
- document forwarding of TZ variable
- remove erronous comment about not expanding the TZ variable
Best regards,
Felix
docs/command-line/environment-variables.inc | 2 ++
kas-container | 11 ++++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/docs/command-line/environment-variables.inc b/docs/command-line/environment-variables.inc
index aa22894b0..10c720435 100644
--- a/docs/command-line/environment-variables.inc
+++ b/docs/command-line/environment-variables.inc
@@ -137,6 +137,8 @@ overwritten using the ``env`` section of the config file.
| ``TERM`` | The terminal options used in the `shell` plugin. |
| (C,K,E) | |
+--------------------------+--------------------------------------------------+
+| ``TZ`` (C) | Timezone settings. |
++--------------------------+--------------------------------------------------+
| ``AWS_CONFIG_FILE`` | Path to the awscli configuration and credentials |
| |aws_cred| | files that are copied to the kas home dir. |
| (K,C) | |
diff --git a/kas-container b/kas-container
index 8a044c0e8..48bbfa11e 100755
--- a/kas-container
+++ b/kas-container
@@ -686,9 +686,18 @@ if [ -n "${SSTATE_MIRRORS}" ]; then
set -- "$@" -e "SSTATE_MIRRORS=${SSTATE_MIRRORS}"
fi
+# propagate timezone information
+if [ -f "/etc/localtime" ]; then
+ set -- "$@" -v "$(realpath -e "/etc/localtime")":/etc/localtime:ro
+fi
+if [ -f "/etc/timezone" ]; then
+ set -- "$@" -v "$(realpath -e "/etc/timezone")":/etc/timezone:ro
+fi
+
for var in TERM KAS_DISTRO KAS_MACHINE KAS_TARGET KAS_TASK KAS_CLONE_DEPTH \
KAS_PREMIRRORS DISTRO_APT_PREMIRRORS BB_NUMBER_THREADS PARALLEL_MAKE \
- GIT_CREDENTIAL_USEHTTPPATH; do
+ GIT_CREDENTIAL_USEHTTPPATH \
+ TZ; do
if [ -n "$(eval echo \$${var})" ]; then
set -- "$@" -e "${var}=$(eval echo \"\$${var}\")"
fi
--
2.49.0