103.6. crun-1.29.1
OCI container runtime written in C, with a small memory footprint
| Version | 1.29.1, release 1 |
| Shelf | containers — Container runtimes, image tools, container networking and sandbox primitives |
| Phase | 41_system (System), 306 of 1047 in build order |
| Licence | GPL-2.0-or-later AND LGPL-2.1-or-later |
| Homepage | https://github.com/containers/crun |
| Build time | 0.7 SBU |
| Installed size | 2.5 MiB in 5 files |
| Recipe | ports/core/containers/crun/kpkgbuild |
About
crun is an OCI runtime: the program that takes a container’s configuration and root filesystem and starts its processes in new namespaces and cgroups, with the capabilities, seccomp filter and mounts the configuration asks for. podman and buildah depend on it, and the shipped /etc/containers/containers.conf names it as the runtime, with cgroupfs as the cgroup manager because there is no systemd to delegate one (see Containers). A KDOS box is a rootless Podman container (see kdos-appbox), so every boxed application starts through crun.
The package is the crun program and its manual page, with libcrun.a, the static library the program is linked from. No shared libcrun is built.
Sources
crun-1.29.1.tar.gz(1.5 MiB)
sha256b6be9fd9613efe5df414c568ddfaf09857c72ec17a00999f15c132a3d9e120fd
upstream: https://github.com/containers/crun/releases/download/1.29.1/crun-1.29.1.tar.gz
archive copy: sources-1/containers--crun-1.29.1.tar.gz
Dependencies
Depends on: json-c, libcap, libseccomp, argp-standalone.
Required by (2): buildah, podman.
Patches
build.sh applies these; kpkg applies nothing by itself.
kill-all-without-cgroup.patch— signal the container process and its descendants on kill --all and delete --force when it has no cgroupA rootless container under the cgroupfs manager gets no cgroup, and one that shares the host pid namespace (podman --pid host, as every distrobox does) is stopped through `kill --all`. Upstream walks the empty cgroup path, signals nothing and returns success, so podman waits for a pid that never dies and leaves the container Stopping until reboot. Without a cgroup or a pid namespace the container's processes are found through the parent links in /proc: the container's own process and every process descended from it are signalled, the tree collected before the first signal. A descendant left alive is reparented to conmon and keeps the root filesystem's overlay mounted, so the next start fails with EBUSY until it exits.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install crun'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/containers/crun.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/containers/crun
echo 'b6be9fd9613efe5df414c568ddfaf09857c72ec17a00999f15c132a3d9e120fd crun-1.29.1.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/crun
SRC=$SRC_ROOT/crun-1.29.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf crun-1.29.1.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/kill-all-without-cgroup.patch"
./autogen.sh
./configure \
--prefix=/usr \
--disable-systemd \
--enable-embedded-blake3 \
--disable-criu \
--disable-shared \
--enable-static
make
make DESTDIR=$PKG install
The switches, and why each is set:
./autogen.sh— Regenerates the build system withautoreconf -fibefore configure runs. The release tarball ships aconfigureof its own; the recipe replaces it. The script’sgit submodule updatefinds no repository in an unpacked tarball, fails, and is ignored; the vendoredlibocispecis already in the tarball.--disable-systemd— Builds no systemd support: crun cannot then create the cgroup through systemd’s D-Bus API and needs no libsystemd. Support is on unless this is given, and configure stops withMissing libsystemd headerswhen the headers are absent, as they are on KDOS. Containers use thecgroupfsmanager instead.--enable-embedded-blake3— Compiles the BLAKE3 hash from the copy inside crun’s source instead of linking libblake3, which is not a port. Onautoconfigure would choose the same, but only after looking for the library.--disable-criu— Builds no checkpoint and restore. That needs CRIU, which is not a port; see Features whose library has no port.--disable-shared,--enable-static— Buildlibcrunas a static library only and link it intocrun. This is the default of crun’s configure (LT_INIT([disable-shared])), named here.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/crun, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf crun-1.29.1-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/crun, and runs the triggers its paths call for.
Contents
Installed programs: crun.
Installed libraries: libcrun.a.
Installed directories: /usr/share/licenses/crun.
Short descriptions
crun |
a fast and lightweight OCI runtime |
Notes
crun parses its command line with argp, which glibc provides and musl does not; configure stops with argp functions not found unless a library supplies argp_parse, which is why argp-standalone is in depends.
kill-all-without-cgroup.patch makes crun kill --all, and the kill inside crun delete --force, signal the container’s own process and every process descended from it when the container has no cgroup. Without it, a container that shares the host’s process namespace cannot be stopped on KDOS.
Why such a container has no cgroup, and why it needs kill --all:
- A rootless container under the
cgroupfsmanager gets no cgroup. Podman passes no cgroup path, crun cannot create one inside a session cgroup that root owns, and it records an empty path. - A container that shares the host pid namespace, as every distrobox box does (
--pid host), is stopped throughkill --all. Podman sends the stop signal itself with--allwhenever the container has no pid namespace of its own and was not created with--cgroups disabled, so the container’s first process is still alive when the patch collects the tree.
Unpatched, kill --all walks the empty cgroup path, signals nothing and reports success. Podman then waits for a process that never exits: podman stop, distrobox rm --force and distrobox stop fail with given PID did not die within timeout, and the container stays Stopping until the machine restarts.
What the patch does, when there is neither a cgroup nor a pid namespace:
- It finds the container’s processes through the parent links in
/proc/<pid>/stat, breadth first from the container’s process, up to 4,096 of them. - It collects the whole tree before sending the first signal, because a child whose parent dies is reparented to
conmonand could then no longer be found. - It signals every process in the tree, not only the first. A descendant left alive, such as distrobox-init’s
sleeploop, keeps the root filesystem’s overlay mounted, and the nextpodman startordistrobox enterfails withdevice or resource busyuntil it exits. - A
kill --allthat finds the process already gone succeeds, as the walk of an empty cgroup does, so a stop that races the container’s own exit is not reported as a failure.
A process that podman exec or distrobox enter started descends from its own conmon, not from the container’s process, so it outlives the stop, as it does on any host without a delegated cgroup.
The patch is to be offered upstream to crun.