Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

98.6. caligula-0.5.0

Writes an image to a removable disk, with a progress display and a verify pass

Version 0.5.0, release 1
Shelf disk — Block devices: partitioning, RAID, LVM, block encryption, SMART, NVMe, recovery, image writing and async I/O
Phase 41_system (System), 387 of 1047 in build order
Licence GPL-3.0-only
Homepage https://github.com/ifd3f/caligula
Build time 3.6 SBU
Installed size 3.6 MiB in 2 files
Recipe ports/core/disk/caligula/kpkgbuild

About

caligula writes a disk image to a removable drive from the terminal. It offers only removable devices to choose from unless given --show-all-disks, decompresses a gzip, bzip2, xz, LZ4 or Zstandard image as it writes, shows the progress, and reads the drive back afterwards to verify what it wrote: a way to put the KDOS ISO, or any other image, on a USB stick from a shell. It is a Rust program built from a vendored crate bundle, linked against the system’s xz.

Why it is in KDOS

The comment above it in script/phases/41_system/packages.d/disk.txt:

Writing an image OUT to a stick, which is the other direction and the one a person does with a mistyped dd and a lost disk. caligula picks the target from the removable devices only, shows a progress bar and verifies what it wrote. Its privilege path is sudo, doas, run0 or su in that order — never pkexec, which matters here because this system has no authentication agent and a pkexec path would be a control that could never succeed.

Sources

Dependencies

Depends on: rust, xz.

Required by: no port names it.

Patches

build.sh applies these; kpkg applies nothing by itself.

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 caligula'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/disk/caligula.

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/disk/caligula
echo 'f4118f0f4a4c90432ba3b1637dd66b8d7f4abd797d63b527baaa6c2595f1552f  caligula-0.5.0.tar.gz' | sha256sum -c -
echo '0a76a3dbe8de237523758fa8dda977c1ff9c003ef0799f7f699c295ecdfb99fd  caligula-vendor-0.5.0.tar.xz' | 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/caligula
SRC=$SRC_ROOT/caligula-0.5.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf caligula-0.5.0.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:

tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz
patch -p1 -i "$PORT_SRC/xz2-shared-liblzma.patch"
export CARGO_HOME="$SRC_ROOT/.cargo"
export RUSTFLAGS="-C target-feature=-crt-static"
cargo build --release --frozen --offline
readelf -d target/release/caligula | grep -q 'NEEDED.*\[liblzma\.so\.5\]'
install -Dm755 target/release/caligula "$PKG/usr/bin/caligula"

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/caligula, 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 caligula-0.5.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/caligula, and runs the triggers its paths call for.

Contents

Installed programs: caligula.

Installed directories: /usr/share/licenses/caligula.

Notes

The readelf -d line after cargo build stops the build unless the binary NEEDs liblzma.so.5, so a vendored crate that falls back to its own copy of the library fails the build instead of shipping a private liblzma that no update to the xz port reaches. The patch is applied after the vendor bundle is unpacked; Cargo.lock lists crates and not their features, so the bundle serves the patched manifest unchanged.