Skip to content

Feature/podman#711

Open
carroarmato0 wants to merge 2 commits intoLoveRetro:mainfrom
carroarmato0:feature/podman
Open

Feature/podman#711
carroarmato0 wants to merge 2 commits intoLoveRetro:mainfrom
carroarmato0:feature/podman

Conversation

@carroarmato0
Copy link
Copy Markdown

The build system previously had Docker hardcoded as the only container runtime. This PR adds support for Podman as a drop-in alternative, which is useful on systems where Docker is not available or not preferred (e.g. rootless Linux setups where Podman is the default).

makefile.toolchain:

  • Detects available container runtime at build time: Docker is preferred when both are installed, Podman is used as a fallback when Docker is absent
  • Allows explicitly overriding the runtime via CONTAINER_RUNTIME=podman on the make command line
  • Tracks the last-used runtime in workspace/.container_runtime and automatically cleans workspace artifacts when switching
    between runtimes

Automatic cleanup is needed as Docker containers run as root, so compiled objects and cloned repos (e.g. other/NextCommander) end up root-owned on the host. Rootless Podman cannot write into those directories. When a runtime switch is detected, the cleanup runs inside the previous container using find -depth -user root -delete, which removes only what that runtime created while leaving host-owned source files untouched. If the previous runtime is no longer installed, an actionable manual cleanup command is printed and the build aborts rather than producing a half-broken state.

workspace/tg5040/btmanager/Makefile:

  • Added missing clean target (pre-existing gap, caught during testing when the cleanup path exercised it for the first time)

Examples:

# uses docker if available, podman otherwise
make PLATFORM=tg5040 build
# explicitly use podman
make PLATFORM=tg5040 build CONTAINER_RUNTIME=podman
# switching runtimes is handled automatically - no manual clean needed
make PLATFORM=tg5040 build                           # builds with docker, records runtime
make PLATFORM=tg5040 build CONTAINER_RUNTIME=podman  # detects switch, cleans, rebuilds

Build tests:

Docker (29.4.1) — successful build:
make build -f makefile.toolchain PLATFORM=tg5040 COMPILE_CORES=
docker run --rm -v .../workspace:/root/workspace ...
...
echo "skipping core build"
skipping core build
# ----------------------------------------------------
Artifacts owned by root on the host (expected Docker behaviour).

Podman (5.8.2) — successful build after automatic cleanup:
make build -f makefile.toolchain PLATFORM=tg5040 COMPILE_CORES=
Container runtime changed (docker -> podman), cleaning workspace build artifacts...
podman run --rm -v .../workspace:/root/workspace ...
...
echo "skipping core build"
skipping core build
# ----------------------------------------------------
Artifacts owned by the host user after the build, confirming rootless Podman mapped ownership correctly:
-rwxr-xr-x 1 carroarmato0 carroarmato0 557576 Apr 30 09:04 workspace/all/minarch/build/tg5040/minarch.elf
-rwxr-xr-x 1 carroarmato0 carroarmato0 149728 Apr 30 09:04 workspace/all/nextui/build/tg5040/nextui.elf

Auto-detect docker or podman at build time, preferring docker when
both are present. Override with CONTAINER_RUNTIME=podman (or any
other compatible runtime) on the make command line.

Signed-off-by: Christophe Vanlancker <carroarmato0@gmail.com>
Docker runs as real root inside the container, so build artifacts and
cloned repos (other/) end up root-owned on the host. Rootless podman
can't write into those directories, causing permission errors mid-build.

Keep track of the last-used runtime in workspace/.container_runtime.
When a different runtime is requested, re-run the cleanup inside the
previous container using 'find -depth -user root -delete', which strips
out everything the old runtime created while leaving host-owned source
files untouched. If the previous runtime is gone, print a manual
cleanup command and bail out cleanly.

Also fixes a missing clean target in btmanager/Makefile, which was
caught when the cleanup path exercised it for the first time.

Signed-off-by: Christophe Vanlancker <carroarmato0@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant