From 26a906f72fe117344c5dc9c0fe33b0e9701895f3 Mon Sep 17 00:00:00 2001 From: Luke Craig Date: Fri, 10 Jul 2026 11:27:22 -0400 Subject: [PATCH] build.sh: translate workspace bind mounts for a shared Docker daemon The rehosting CI shared-docker runners run one dockerd per node, so the daemon cannot see a runner's per-pod checkout under /home/runner/_work. The raw '-v $PWD:/app' (and the kernel-devel / output binds, all rooted in that checkout) then mount empty dirs, and the build dies with '/app/_in_container_build.sh: No such file'. Add rewrite_mount(), mirroring the fix in linux_builder, which rewrites a bind source via PENGUIN_HOST_MOUNT_FROM/TO (exported by the runner, the same mechanism penguin's wrapper uses) only when both vars are set and the path is under _FROM. Local and GitHub-hosted builds leave them unset, so paths pass through unchanged and behaviour is identical to before. --- build.sh | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 586b9e2..0929a51 100755 --- a/build.sh +++ b/build.sh @@ -142,12 +142,41 @@ BUILD_OUTPUT_DIR="$(pwd)/cache/build" mkdir -p "$BUILD_OUTPUT_DIR/kernels" mkdir -p "$BUILD_OUTPUT_DIR/logs" +# Normally dockerd shares this script's mount namespace, so a bind-mount source +# path means the same thing to the daemon as to us. Under a shared per-node +# daemon (e.g. rehosting CI's shared-docker runners) it does NOT: the daemon +# can't see this runner's per-pod workspace under /home/runner/_work, so +# "-v $PWD:/app" would mount an empty dir and the build would fail with +# "/app/_in_container_build.sh: No such file". The runner exports +# PENGUIN_HOST_MOUNT_FROM / PENGUIN_HOST_MOUNT_TO (the same mechanism penguin's +# wrapper uses) giving the daemon-visible location of that workspace. +# +# rewrite_mount() rewrites a bind source ONLY when BOTH env vars are set and the +# path is under _FROM. When they're unset — every local build and every +# GitHub-hosted runner — it returns the path unchanged, so behaviour is +# identical to before. All three mounts here (kernel-devel extract, $PWD, and +# the build output) live under this workspace, so all three are rewritten; an +# absolute --kernel-devel-path outside _FROM is left as-is. +rewrite_mount() { + local path="$1" + if [[ -n "$PENGUIN_HOST_MOUNT_FROM" && -n "$PENGUIN_HOST_MOUNT_TO" \ + && "$path" == "$PENGUIN_HOST_MOUNT_FROM"* ]]; then + printf '%s' "${PENGUIN_HOST_MOUNT_TO}${path#"$PENGUIN_HOST_MOUNT_FROM"}" + else + printf '%s' "$path" + fi +} + +KERNEL_DEVEL_MOUNT_SRC="$(rewrite_mount "$KERNEL_DEVEL_MOUNT_DIR")" +APP_MOUNT_SRC="$(rewrite_mount "$PWD")" +BUILD_OUTPUT_MOUNT_SRC="$(rewrite_mount "$BUILD_OUTPUT_DIR")" + # Run the container with proper environment variables and mounts docker run ${INTERACTIVE} --rm \ -e RELEASE="${RELEASE}" \ -e HOST_UID="$(id -u)" -e HOST_GID="$(id -g)" \ - -v $KERNEL_DEVEL_MOUNT_DIR:/kernel-devel:ro \ - -v $PWD:/app \ - -v $BUILD_OUTPUT_DIR:/output \ + -v "$KERNEL_DEVEL_MOUNT_SRC":/kernel-devel:ro \ + -v "$APP_MOUNT_SRC":/app \ + -v "$BUILD_OUTPUT_MOUNT_SRC":/output \ $DOCKER_IMAGE \ bash -c "/app/_in_container_build.sh \"${TARGETS}\" \"${VERSIONS}\" /kernel-devel /app/src /output"