[PATCH] scripts: container.sh: explicitly pass build dir as volume

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Jan 5 07:13:14 PST 2026


For cases, where KBUILD_OUTPUT/LG_BUILDDIR may be a symlink, processes
running inside the container may not have the necessary permissions to
follow it.

Fix this by calling realpath on it and explicitly registering it as
volume.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 scripts/container.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/scripts/container.sh b/scripts/container.sh
index 90c3a1d0accd..5375fdd91d39 100755
--- a/scripts/container.sh
+++ b/scripts/container.sh
@@ -41,6 +41,15 @@ if [ "$(realpath --no-symlinks $PWD)" != "$pwd_real" ]; then
 	volumes="$volumes -v $pwd_real:$pwd_real:z"
 fi
 
+if [ -n "$KBUILD_OUTPUT" ]; then
+	KBUILD_OUTPUT=$(realpath $KBUILD_OUTPUT)
+	volumes="$volumes -v $KBUILD_OUTPUT:$KBUILD_OUTPUT:z"
+fi
+if [ -n "$LG_BUILDDIR" ] && [ "$KBUILD_OUTPUT" != "$LG_BUILDDIR" ]; then
+	LG_BUILDDIR=$(realpath $LG_BUILDDIR)
+	volumes="$volumes -v $LG_BUILDDIR:$LG_BUILDDIR:z"
+fi
+
 exec podman run -it $volumes --rm \
 	-e TERM -e ARCH -e CONFIG -e JOBS -e LOGDIR -e REGEX \
 	-e KBUILD_OUTPUT -e LG_BUILDDIR $env \
-- 
2.47.3




More information about the barebox mailing list