Bind-mounting /etc/timezone into the container overwrites the symlinks
target, as both docker and podman mount without the AT_SYMLINK_NOFOLLOW
flag. This breaks yocto builds which rely on correct information in
/usr/share/zoneinfo/*. To fix this, we pass the host timezone via an
environment variable to the container and patch the timezone in the
entrypoint. By that, we also preserve the difference between the TZ
variable and the /etc/timezone, /etc/localtime data.
Fixes: 378366395 ("kas-container: propagate timezone information ...")
Signed-off-by: Felix Moessbauer <
felix.mo...@siemens.com>
---
container-entrypoint | 5 +++++
kas-container | 9 ++-------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/container-entrypoint b/container-entrypoint
index 927248db7..d62aa9c0a 100755
--- a/container-entrypoint
+++ b/container-entrypoint
@@ -67,6 +67,11 @@ else
if [ -d /var/kas/userdata/.ssh ]; then
cp -a /var/kas/userdata/.ssh /builder/
fi
+ # adjust timezone to host
+ if [ -n "${KAS_HOST_TZ}" ] && [ -f "/usr/share/zoneinfo/${KAS_HOST_TZ}" ]; then
+ echo "${KAS_HOST_TZ}" > /etc/timezone
+ ln -sf "/usr/share/zoneinfo/${KAS_HOST_TZ}" /etc/localtime
+ fi
GOSU="gosu builder"
fi
diff --git a/kas-container b/kas-container
index e8735884d..a768cfe32 100755
--- a/kas-container
+++ b/kas-container
@@ -687,13 +687,8 @@ 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
+# propagate timezone information to entrypoint
+set -- "$@" -e "KAS_HOST_TZ=$(cat /etc/timezone)"
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 \
--
2.50.0