357.6. kdos-packd-0.1.0
Mounts packs, composes box root filesystems, verifies signatures
| Version | 0.1.0, release 1 |
| Source tree | src/daemons/kdos-packd/ |
| Phase | 50_desktop (Desktop), 80 of 92 in build order |
| Licence | MIT AND (BSD-2-Clause OR CC0-1.0) |
| Homepage | https://github.com/kunaldawn/kdos |
| Build time | 0.2 SBU |
| Installed size | 257.3 KiB in 2 files |
| Recipe | src/daemons/kdos-packd/kpkgbuild |
About
kdos-packd is the only program on a KDOS machine that mounts an application pack: a signed, read-only EROFS image holding an application, a runtime it needs, or data. It verifies a pack’s signature before it mounts it, composes a box’s root filesystem as an overlay of the packs that box is made of, installs and rolls back packs in the store under /var/lib/kdos/packs, and places data packs where their consumers look. A client names a pack by an id out of the list the daemon published, never by a path. Mounting as root is what makes the overlay’s whiteouts real, so a box’s root is composed from the packs as they are, with no flattening step. Its clients are kdos-appbox and kdos doctor. The pack format is in Packs and boxes, and the daemon’s verbs, paths and configuration in kdos-packd.
The port is KDOS’s own C, with no upstream source. build.sh compiles the daemon’s files with the sources of libkbase, libksig (and the Monocypher code inside it, which is where the recipe’s BSD-2-Clause OR CC0-1.0 licence comes from), libkpkg and libkpack, and nothing else, because every library a root daemon links is code running as root; see How the libraries are built.
Why it is in KDOS
The comment above it in script/phases/50_desktop/packages.txt:
Packs. An application is one signed EROFS image with a KDOS footer on the end, and this is the only thing on the machine that mounts one: it verifies where it mounts, composes a box's root filesystem out of an overlay of them, and takes an id out of the list it published rather than a path. Mounting as ROOT is what makes overlay whiteouts real: a box's root is composed from the packs as they are, with no flatten step.
Sources
None: the port builds from its own directory, /kdos/src/daemons/kdos-packd.
Dependencies
Depends on: erofs-utils.
Required by (1): kde-plasma.
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/50_desktop/phase.env && kpkg install kdos-packd'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/daemons/kdos-packd.
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.
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/kdos-packd
SRC=$SRC_ROOT/kdos-packd-0.1.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
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:
LIBS="$PORT_SRC/../../libs"
gcc $CFLAGS -O2 -std=gnu11 -D_GNU_SOURCE -Wall -Wextra \
-I"$LIBS/libkbase" -I"$LIBS/libksig" -I"$LIBS/libkpkg" \
-I"$LIBS/libkpack" -I"$PORT_SRC" \
-o kdos-packd "$PORT_SRC"/*.c \
"$LIBS"/libkbase/*.c "$LIBS"/libksig/*.c \
"$LIBS"/libksig/monocypher/*.c "$LIBS"/libkpkg/*.c \
"$LIBS"/libkpack/*.c $LDFLAGS
install -Dm755 kdos-packd "$PKG/usr/sbin/kdos-packd"
install -d "$PKG/var/lib/kdos/packs/staging" "$PKG/var/lib/kdos/packs/mnt"
install -Dm644 "$LIBS/libksig/monocypher/LICENCE.md" \
"$PKG/usr/share/licenses/$name/monocypher-LICENCE.md"
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/kdos-packd, 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 kdos-packd-0.1.0-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/kdos-packd, and runs the triggers its paths call for.
Other files in the port directory, read by build.sh: graft.c, main.c, mount.c, packd.h, store.c.
Contents
Installed programs: kdos-packd.
Installed directories: /usr/share/licenses/kdos-packd, /var/lib/kdos.
Notes
The package installs /var/lib/kdos/packs/staging and /var/lib/kdos/packs/mnt as ordinary directories. The daemon sets the staging directory to mode 01777 itself when it starts, which is where an unprivileged client copies a pack before asking for install; until the daemon has run once, nobody but root can write there.
The daemon mounts with the kernel’s erofs driver and runs no program of erofs-utils, which the recipe depends on. /etc/init.d/59_packd.sh skips the daemon at boot when erofs is missing from /proc/filesystems after modprobe erofs, so a kernel without EROFS boots with no pack support at all.