Skip to the text
KDOS
Menu

Developing

This chapter is the working manual for anyone who builds KDOS from source or changes it. It covers what a development machine needs, how to get from a fresh clone to a bootable ISO, how to rebuild one small thing instead of everything, how to boot and inspect the result, what can be checked with no build at all, and how a release is cut. It assumes you know what KDOS is; for the build told as one continuous story from git clone to a bootable image, read How KDOS is built first. The mechanism behind make build is in The build system, the recipe format in Writing ports, and the test harnesses in Testing. Terms such as port, pack and box are defined in the glossary.

The path from a clone to a running system has five steps:

  1. Clone the repository and enable the pre-push check.
  2. Run make fetch to download every upstream source. It is the only step the build needs the network for; apart from building container images, make build downloads nothing.
  3. Run make build to compile everything into build/iso-build/kdos.iso.
  4. Run make run to boot the ISO in a virtual machine.
  5. After a change, rebuild only what changed, using the table in Rebuilding one thing.

What a development machine needs

Need For Notes
Docker make build, make run-hw The build image carries every compiler the build uses
Network access for image builds The first make build, the first make run-hw Building the os-dev image pulls Alpine and its packages, again whenever the Dockerfile changes; the run-hw image is built from Ubuntu on first use
Docker or podman Generating a vendor bundle during make fetch Only when the archive and the cache lack one; see Where sources come from
curl, sha256sum make fetch All ordinary downloading happens on your machine
git, curl, Python 3, and network access to the source archive The pre-push hook The hook reads hashes with git grep and checks each one against the archive with curl, and runs the book checks, which are Python
A C compiler ($CC, default cc) make fetch-check, make snapshots, ports/fetch --tree, ports/publish, testing/preflight.sh, testing/selftest.sh, make updates Optional for make fetch: without one, the whole fetch runs inside the kdos-fetch container. testing/preflight.sh and make updates (ports/update) always run cc and ignore $CC
fuser (from psmisc) check-iso-free, which make build runs first Without it the check is skipped, and nothing stops a build rewriting an ISO a virtual machine is booted from
QEMU, OVMF firmware at /usr/share/ovmf/OVMF.fd, and /dev/kvm make run, make rundisk Only to boot the result. Both pass -enable-kvm -cpu host, so without /dev/kvm they print a warning and QEMU then refuses to start
Docker and /dev/kvm The rig: make quick, make session-probe, make shots, make atspi The rig carries its own QEMU in the kdos-qemu-py image (make rig-image, network once); see The QEMU rig
Docker make plasmatest, through testing/devdeps-image.sh plasmatest The development image kdos-devdeps carries Qt 6, KDE Frameworks 6 and Plasma’s development files, which the Qt suite needs and no bare host has; building it needs the network
Disk space Everything See below

No language toolchain (Rust, Go, Node, Python, Haskell) is needed on your machine. The one step that uses them, generating a vendor bundle, runs them inside a container.

No step needs you to log in as root or use sudo, but two things amount to root access. Permission to use Docker is equivalent to root on that machine, since a container can mount any part of it. And build/fs, the target root filesystem, is owned by root, so reading or deleting it takes root or a container; see Where the build puts things.

Disk. The upstream sources for the current tree take about 43.1 GB (40.2 GiB): the 2,831 distinct files the recipes fetch, which is what ports/.srccache/ holds after a complete make fetch. Each distinct file is held once in the cache and hard-linked into every port directory that names it. A complete build adds about 70 GB under build/, about 52 GB of it the target tree and about 11 GB the compiler cache, which is capped at 20 GB; writing a binary host as well (KDOS_MAKE_BINHOST=1) takes about 18 GB more. Phase snapshots take more again: the first of the eleven phases from 00_cross to 50_desktop archives the target tree compressed, each later one a layer of what it added, changed or rewrote, and 60_kernel and 70_image take none. On a synthetic ten-phase tree the layers came to 23% of what full copies take; a complete set from a real build has not been measured. Snapshots are off unless a run asks for them (--snapshot, or S in the startup picker), and a phase can opt out of its own; see Snapshots.

Getting the source

git clone <this repository> kdos && cd kdos
git config core.hooksPath script/hooks    # the pre-push check; once per clone
make fetch                                # downloads every source

A clone carries recipes, patches and KDOS’s own code. The upstream source archives the recipes name are not in git. make fetch downloads each one, checks it against the sha256 = line in its recipe, and puts it in its port directory. After that, the build itself runs with no network (the orchestrator’s container is started with --network none) for as long as the recipes do not change. Only building the os-dev image, the first time or after the Dockerfile changes, downloads Alpine packages. Run make fetch again after pulling or switching branches; it downloads only what is new. make fetch-check confirms, offline, that nothing is missing or corrupt.

git config core.hooksPath script/hooks points git at script/hooks/. Its pre-push hook refuses a push that breaks the ports layout, adds a patch that does not say what it changes, leaves either book out of step with the tree, or has recipes naming a source the archive does not hold, so that a recipe you publish can be fetched by everyone else. Where each source is kept and how make fetch finds it are described in Where sources come from, and each of the hook’s checks in The pre-push check.

The first build

make build            # compile everything; the orchestrator runs with no network

make build builds the os-dev container image from the repository’s Dockerfile (Alpine 3.23 with GCC, musl, bash and the other tools the orchestrator needs), then runs the orchestrator inside it with --network none, --privileged and --cpu-shares=256, a weight that lets an idle host give the build every thread; KDOS_JOBS=N also caps it with --cpus. The repository is mounted with build/ writable and src/, fs/, script/, ports/, docs/, testing/, the Makefile and the Dockerfile and LICENSE read-only; nothing else in the checkout reaches the build. The current commit and whether the working tree is dirty are passed in and recorded with each snapshot. Your user and group ids are passed in as well, and when the orchestrator exits, whether the build succeeded or failed, it gives ownership of everything under build/ back to you, except build/fs, the image stage’s build/image-upper, build/image-work and build/image-root, and build/podman. The first four hold the shipped system’s own file owners; see Where the build puts things. No step creates build/podman, and a container store there has to stay root’s, because podman refuses a store owned by anyone but the user running it.

The orchestrator is kdosbuild, compiled from src/devtools/kdosbuild/ by script/kdosbuild.sh at the start of a build when its sources, flags or compiler changed. On a terminal it first opens a picker that asks whether to start fresh or restore a snapshot, and whether to write snapshots as it goes, which it does not unless asked; see The startup picker. Without a terminal it prints plain lines instead, so a build can be logged to a file. A full build from scratch takes many hours. The finished ISO is build/iso-build/kdos.iso.

Two things to know before the first run:

These variables change how much of the host the build takes, or how much it rebuilds, and nothing about what it produces:

Variable Effect
KDOS_JOBS=N The job count for every phase: MAKEFLAGS=-jN, CMAKE_BUILD_PARALLEL_LEVEL, CARGO_BUILD_JOBS and -jN on every ninja call that names no job count, and a --cpus cap of N on the build container, no higher than the host’s thread count, so cargo and go follow it. Unset, script/env/common.env takes the host’s thread count clamped to one job per 2 GiB of memory. Under --port-jobs it is the size of the jobserver the ports of a level share. Lower it when a large C++ port is OOM-killed
KDOS_CPU_SHARES=N The build container’s CPU weight, default 256. It is not a cap: an idle host still gives the build every thread, and it only orders the build against other containers and system services
KDOS_CCACHE=0 Turns off the compiler cache, default 1: CMake ports inside the chroot compile through ccache into build/ccache, and a cached object is byte-identical to a compiled one (see The compiler cache). Forwarded into the chroot by script/chroot/exec.sh
KDOS_PKG_STORE=1 Turns on the package store, default 0: a port whose recipe, environment and dependencies’ exact bytes match a package built before is installed from build/pkgstore instead of being built, and every package built is stored. check builds every hit anyway and logs any difference to build/logs/pkgstore-check.log. Use 0 or check for a release. See The package store
KDOS_PKG_STORE_MAX=SIZE The size 70_image evicts the store down to, least recently used first, default 60G

Nine variables change what the build produces. Each is passed by the Makefile and forwarded into the chroot by script/chroot/exec.sh:

Variable Effect
KDOS_IMAGE=full Makes the ISO carry every package build/fs holds instead of the base, the default KDOS_IMAGE=base: the medium for a machine that installs with no network, and for the rig when it needs an application the base leaves out. Under base the 70_image steps from 017_stage.sh on run in an overlay over build/fs that 017_stage.sh trims to the closure of ports/base (see The image stage). Any value but base or full stops make build
KDOS_ISO_SOURCES=1 Copies the tree onto the ISO under /sources, beside system.sfs rather than inside it: src/, script/, fs/, the Makefile, the Dockerfile, and ports/ with every recipe and fetched source but without its dot-directories (the source cache and the compiled helpers), with a SOURCES stamp giving the port count, the size and the build time. A binhost this build wrote with KDOS_MAKE_BINHOST=1 goes beside them as /sources/binhost. It roughly doubles the size of the image
KDOS_PACK_KDOS=1 Also packs the root filesystem as the base pack kdos, in build/kdos-base/kdos.kpack, and puts it on the ISO under /packs. kdos-box create ports base=pack:kdos then gives a running KDOS a clean KDOS to build ports in. build/kdos-base is deleted at the start of every 100_packs.sh run, so the only pack there is one this run made. With the flag set and mkfs.erofs or kdos-pack missing, the step prints a note and makes no pack
KDOS_ISO_COMP=zstd:3 Compresses system.sfs with zstd at level 3 instead of the default level 19: a faster 70_image and a larger image, for the rig, never a release. xz, xz-bcj (xz with the x86 branch filter) and zstd:1 to zstd:22 are accepted; any other value stops 110_iso.sh. The measured sizes and read speeds are in The codec
KDOS_ISO_BLOCK=128K The squashfs block size of system.sfs, 4K to 1M in powers of two; empty is 1M. Any other value stops 110_iso.sh
KDOS_ISO_GATE=0 Lets a base ISO larger than KDOS_ISO_MAX through, as a developer image; the default 1 fails 110_iso.sh on it and prints the image ledger’s top twenty. A KDOS_IMAGE=full ISO is never gated. Any value but 0 or 1 stops make build
KDOS_ISO_MAX=BYTES The release limit the gate enforces, default 1992294400 (1,900 MiB, one GitHub release asset). Anything but a positive number stops make build
KDOS_MAKE_BINHOST=1 Keeps every package the build makes and writes them into a signed binhost in build/binhost/, which kpkg binhost and kdos update install install from. It is the release’s package repository: every package the base ISO leaves out is installed from it. Each run adds what it built, so a complete binhost needs one --fresh build with the flag set
KDOS_GIT_TAG=<tag> The release the image names, empty by default. Empty takes the one release tag on HEAD, a tag named v<digit>… (git tag --points-at HEAD --list 'v[0-9]*'), lightweight or annotated; an archive tag (sources-N, src-*, packs-*) never names a release, a HEAD with several release tags needs this to pick one, and none builds a tagged commit as an unreleased one. On a clean checkout, untracked files included, 70_image/105_ports.sh writes it into /ports/TREE as version <tag>, which is how a machine installed from the image finds the release’s binhost. make build stops before the container starts when HEAD has several release tags and none is picked, when the tag is not a release tag on HEAD, or when it is outside the names ports/publish --release accepts; the messages are in The release tag

For example, make build KDOS_ISO_SOURCES=1.

The phases

The orchestrator runs thirteen phases, each a directory under script/phases/, in sorted order. A phase can be named by its directory or by its short name, the word after the number:

Directory Short name Title
00_cross cross Cross Toolchain
10_bootstrap bootstrap Base Userland
20_selfhost selfhost Self-Hosting Bootstrap
30_foundation foundation Build Foundation
31_compilers compilers Compilers
40_lang lang Languages
41_system system System
42_graphics graphics Graphics Stack
43_toolkits toolkits Toolkits
44_apps apps Applications
50_desktop desktop Desktop
60_kernel kernel Kernel
70_image image Image

00_cross, 10_bootstrap and 70_image are directories of numbered scripts; the other ten install the ports their package list names and the dependencies those need. From 30_foundation on, each list names exactly the ports its phase installs; 20_selfhost’s nine names pull in six more. The numbers leave gaps so that a phase can be added between two others without renaming any. What each phase contains, and how one runs, is in The build system.

Make targets

Everything in this chapter is started from the Makefile at the root of the checkout. make help prints the targets with a one-line description each; this table says what each one does and what it needs on your machine.

Target Does Needs
all The default target; the same as build
build The whole build, in the container. Runs check-iso-free first Docker
fetch Fetch every port’s sources into ports/core, generating vendor bundles the archive lacks. ports/fetch <port> narrows it Network; a container only to generate
fetch-check List, offline, every archived source that is missing or fails its hash A C compiler
updates Check every port for a newer upstream release Network, curl, git, cc
publish Upload every source the archive lacks that a recipe names and the upstream branch’s recipes do not, or that ports/sources.idx does not, each into its shelf’s volume sources-<N> (or the lowest-numbered volume with room when that one is full); PORTS names the ports instead, PUBLISH_ARGS=--all takes every recipe Network, the archive token
publish-dry Print what publish would upload, under which names and into which volumes A C compiler
publish-check List the sources publish would upload, by anonymous requests; PUBLISH_ARGS=--all checks every recipe’s Network
publish-plan Give every shelf in ports/shelves that has no volume one, packing them in sorted order to about 650 assets a volume; never changes an assigned shelf. PUBLISH_ARGS=--dry-run only prints the plan A C compiler
publish-describe Rewrite every archive release’s title and notes from ports/sources.idx Network, the archive token
publish-rehome Move each archived file that is not in its shelf’s volume under its <shelf>-- name there; run it, push the index, and run it again to delete the old copies Network, the archive token
publish-retire Delete every src-<shelf> release of the older one-release-per-shelf layout that holds no asset, and its tag; refuse any that still holds assets Network, the archive token
publish-orphans List index entries no recipe names any more
freeze Attach sources.sha256 for TAG to that system release Network, the archive token
release Create or update TAG’s system release as a draft: the ISO, SHA256SUMS, its signature and sources.sha256 Network, the archive token, a finished build
release-publish Make TAG’s release public and Latest Network, the archive token
snapshots List the phase snapshots, compiling build/.kdosbuild with your machine’s compiler when your compiler did not build it A C compiler
run Boot the ISO in a virtual machine, with build/kdos.qcow2 attached as a disk (created if missing as a sparse qcow2 of KDOS_DISK, 192 GB by default: above the install kinstall checks the disk against and the least the two A/B slots need, about 24.5 GiB with the default 4 GiB swap and 20.5 GiB with none, so an install to it gets both, with room in each slot for native groups) QEMU, OVMF
rundisk Boot build/kdos.qcow2 instead of the ISO QEMU, OVMF, an existing disk image
run-hw Boot the ISO with hardware-accelerated graphics Docker, the NVIDIA Container Toolkit
rundisk-hw The same, from the disk image Docker, the NVIDIA Container Toolkit
debug-boot Boot the built kernel and initramfs directly, with the serial console on your terminal, for early-boot debugging QEMU, a finished build
check-iso-free Refuse to rewrite an ISO a process has open fuser; without it the check is skipped
check-hw Check the accelerated-graphics setup: an error without Docker, warnings without the nvidia runtime or /dev/udmabuf
cleandisk Replace build/kdos.qcow2 with a new, empty, sparse disk image of KDOS_DISK (192 GB by default) QEMU
cleanbuild Delete everything in build/ except snapshots, ccache, pkgstore, keys and binhost-key, and except what only root can remove (see below)
clean Delete everything in build/ except keys and binhost-key, and except what only root can remove
help List every target that carries a one-line description; check-iso-free, check-hw and need-tag (the guard the release targets run first) carry none
check Run preflight, selftest, docscheck, anchorcheck, booknav, kfscheck, sitecheck, phaseclosure, defaultscheck, xdgcheck, lnfcheck, aboutcheck and atspi-selftest in turn
preflight, selftest, docscheck, phaseclosure Run that check alone; see Working without a build at all A C compiler for preflight and selftest; Python 3 for preflight, docscheck and phaseclosure
defaultscheck, xdgcheck Read every KDOS default for a KDE program back through the XDG configuration cascade against testing/fixtures/defaultscheck/defaults.tsv; check that KDOS’s defaults stay in /usr/share/kdos/xdg and out of /etc/xdg. See Testing Python 3; bash
lnfcheck, aboutcheck Hold the KDOS global themes and desks to what Plasma reads, and prove each of that check’s verdicts can fail; prove each verdict of the About-page check can fail, the check itself needing a booted tree. See Testing Python 3; bash
plasmatest The Qt half of the checks: build every KDOS Qt port with its QtTest suites, load its plugins, install its Plasma packages into a scratch root and lint its QML (PLASMATEST_ARGS reaches it, e.g. --selftest). Not part of check; it refuses on a host without the tools. See Testing The development image: testing/devdeps-image.sh plasmatest
anchorcheck, booknav, kfscheck Check every #fragment link in both books and the port notes; every chapter footer and KDOS from Scratch’s contents; that book’s port notes, includes, patch headers, kernel option table and recipe stamp against the tree, and that its whole source generates without a warning (KFSCHECK_ARGS reaches it, e.g. --strict). See Testing Python 3
booknav-write Rewrite every chapter footer of both books, and KDOS from Scratch’s contents Python 3
selftest-asan selftest compiled with SELFTEST_CC, by default AddressSanitizer and UBSan A compiler with the sanitizers
depdrift Read build/fs for undeclared same-phase link dependencies; advisory Read access to build/fs: a container or root; Python 3
debuginfo Fail when build/fs ships more than 1 MiB of DWARF outside the allowlist (ghc’s -debug runtimes); lists it by package Read access to build/fs; Python 3
unowned List the files in build/fs no package and no fs/ path provides Read access to build/fs; Python 3
linkcheck, entrycheck Fail on an undeclared DT_NEEDED owner, an interpreter that does not resolve or OpenSSL 3 and 4 in one process; or on a dangling link, a dead desktop or D-Bus Exec=, a missing Icon= or udev program. 70_image runs both and stops on a failure Read access to build/fs; Python 3
book Render KDOS from Scratch into build/kfs: the HTML book under html/, kfs.pdf and kfs-html.tar.zst. Every package page is generated from its recipe on each run. About two minutes Python 3; pandoc and typst, by default the ones in BUILDFS
book-data Rewrite the book’s committed snapshot, docs/kfs/data, from BUILDFS’s package database and build/snapshots/timings.json, with the recipe stamp beside it Python 3; read access to a built tree’s var/lib/kpkg/db
book-stamp Rewrite the book’s recipe stamp, docs/kfs/data/recipes.stamp, alone, from the checkout Python 3
site Write README.md and kdos.dev’s pages, into SITE_OUT (build/site), from site/; see Rebuilding one thing Python 3
sitecheck Fail, printing the difference, when README.md is not what site would write. See Testing Python 3
quick The fast loop: rebuild the ports named by QUICK and patch them into a booted ISO; QUICK_ARGS reaches the rig Docker, /dev/kvm, the rig image, a finished ISO
session-probe Boot the ISO on the rig, measure the time to the Plasma panel and the idle memory (testing/session-cost.sh, given SESSION_ARGS), then check the session is whole (testing/plasma-probe.sh, given PROBE_ARGS) Docker, /dev/kvm, the rig image, a finished ISO
shots Boot the ISO and photograph the desktop, Kickoff, KRunner and the Overview into build/shots The same
atspi, atspi-selftest Dump every KDOS surface’s accessibility tree on the booted ISO and compare it with its golden (ATSPI_ARGS=--update writes the goldens); the dump format and the gate on fixtures, with no ISO. See Testing The same for atspi; Python 3 for atspi-selftest
rig-image, devdeps-image Build the rig container, or the development container and run testing/selftest.sh in it (testing/devdeps-image.sh plasmatest runs the Qt suite there instead) Docker, network once

Every archive target except publish-retire, and also freeze, release and release-publish, compiles the recipe reader first, so each needs a C compiler as well.

Both cleans run on your machine as your user. build/fs is owned by root, so they cannot remove it, and the target ignores the failure: after make clean the old root filesystem is still there, and the next build runs on it. Remove it from a container, or as root:

docker run --rm -v "$PWD/build:/b" os-dev rm -rf /b/fs

The os-dev image exists once make build has run.

Arguments reach the orchestrator through BUILD_ARGS and the version checker through PORTUP_ARGS:

make build BUILD_ARGS="--continue-from 41_system"
make updates PORTUP_ARGS="--check curl"

The archive targets take PORTS (a space-separated port list), PUBLISH_ARGS (passed to ports/publish unchanged) and TAG (the system tag freeze and the release targets act on):

make publish PORTS="zstd lz4"
make release TAG=v0.2 PUBLISH_ARGS=--dry-run

The two book targets take BUILDFS, the built tree they read, build/fs by default. book-data reads its package database; book reads the same database for the full file list of each installed package, and by default renders with the pandoc and typst that tree carries, run through its own loader ($(BUILDFS)/usr/lib/libc.so --library-path $(BUILDFS)/usr/lib), so the book is made by KDOS’s own binaries on any Linux host. KFS_PANDOC and KFS_TYPST replace either with any command, such as a host’s own. KFSGEN_ARGS is passed to kfsgen.py: kdos.dev’s render gives it --kdos-book https://kdos.dev/book/, which sends the book’s links into the KDOS book to the site’s copy instead of GitHub. KFSRENDER_ARGS is passed to kfsrender.py, and kdos.dev’s render gives it --home https://kdos.dev/, a link to the homepage in every page’s top bar:

make book BUILDFS=../kdos/build/fs
make book KFS_PANDOC=pandoc KFS_TYPST=typst
make book KFSGEN_ARGS="--kdos-book https://kdos.dev/book/" \
    KFSRENDER_ARGS="--home https://kdos.dev/"
make book-data                     # after a build
make book-stamp                    # after any change that stales the stamp; no built tree

docs/kfs/data/recipes.stamp holds one hash over every port’s recipe hash and kfs.md, the phase lists and environments, the 00_cross and 10_bootstrap step scripts, ports/shelves, ports/sources.idx, testing/optdeps.py, fs/etc/os-release (whose VERSION is on the title page) and every file a page of the book includes, and kfscheck.py fails while it is not this tree’s. The two ports that link a book under docs/, kdos-doc and kdos-kfs, are left out: their own hashes cover those books, and kdos-kfs’s covers the stamp itself. A change to any of these files therefore needs book-stamp even when no port was built, and that includes every ports/publish that adds a line to ports/sources.idx. The rewritten stamp is what rebuilds kdos-kfs, since none of those files is in its own recipe hash. A port whose snapshot version is not its recipe’s renders with a note naming the version the snapshot was taken from.

The orchestrator options used most often are these; the full list is in The build system:

Option Effect
--fresh Skip the startup picker and run every phase on the existing tree
--restore PHASE Restore a snapshot and continue after it (PHASE is a name, a directory, a 1-based index or latest)
--continue-from PHASE Resume at PHASE on the existing tree, restoring nothing
--phases LIST Run only these phases
--steps LIST Run only these scripts, each written PHASE:script.sh
--rebuild LIST Rebuild these ports even though they are installed
--snapshot Write a snapshot of each phase as it completes; off by default
--full-snapshots Write every snapshot as a whole tree, never as a layer on the one before
--port-jobs N Build up to N ports of a package phase at once, by dependency level; 1, the default, builds one at a time
--plain, --json No interface: plain lines, or one JSON object per event

Building ports side by side. make build BUILD_ARGS="--port-jobs 3" runs each package phase level by level: the ports whose dependencies are all installed build together, taking their jobs from one jobserver of KDOS_JOBS slots, so a port left building alone uses them all, and one commit step then installs the level in the serial order. What each port builds against is decided by the tree, not by timing, so the result matches a serial build as long as every recipe declares its dependencies. It pays where a phase has many ports too small to use every CPU, the configure, install and packaging time of a userland phase above all; a phase ruled by one large port gains little. 2 or 3 is the useful range: each running port has its own compilers and linkers, and a new port starts beside running ones only while a quarter of the memory is free, so on a machine with little memory to spare lower KDOS_JOBS as well or leave it at 1. How a level is built, and what a failure in one does, is in Building a package phase by level.

ports/update --check exits 1 when it finds an update, so make updates treats status 1 as success and fails only on status 2 or higher.

Running the result

make run          # plain graphics: KWin on software GL, Phosphor mode refused
make run-hw       # accelerated: KWin on the host GPU, Phosphor mode available

make run uses a plain virtual display (virtio-vga with QEMU’s GTK window), on which KWin composites with OpenGL on llvmpipe, Mesa’s software rasteriser. Everything in the session works there except an effect that refuses software rendering, which Phosphor mode’s full-screen CRT effect, kdos_crt, does: a pass over every pixel of every frame would be the whole budget of a software renderer. Turning Phosphor mode on there is refused before anything is changed, with phosphor mode needs GPU rendering (this session renders in software). make run-hw runs a containerised QEMU 10 with GPU-accelerated graphics (virgl) through testing/qemu-hw/run.sh, on which KWin composites on the host’s GPU and the effect loads. Phosphor mode is the look the effect belongs to.

make run and make rundisk give the guest 4 GB of memory and as many CPUs as your machine has, put the serial console on your terminal, and use QEMU’s user-mode networking. make run also attaches a USB tablet, so the pointer tracks the window without being grabbed. Every run target asks testing/qemu-audio.sh for a sound card: it probes which audio backend the local QEMU can use and adds an Intel HDA controller when there is one, or nothing when the host cannot play sound.

All run targets come up at 1920x1080. KDOS_RES changes that:

make run KDOS_RES=2560x1440

KDOS never asks for a display mode; KWin and the login screen take the one the virtual screen says it prefers. For QEMU’s virtio GPU that is whatever its xres and yres properties say, and left unset they default to 1280x800, at which Plasma sizes its panel, Kickoff and its windows for a screen no 1080p machine has. KDOS_RES sets those two properties, the Makefile passes it to testing/qemu-hw/run.sh, and testing/vnc-shot.py sets the same properties from its own --size (whose default is 1280x800).

The accelerated run scales the picture to fit its window instead of resizing the guest (zoom-to-fit=on). Otherwise QEMU’s window would report its own size to the guest, and the session would follow whatever size the window happened to open at. KDOS_QEMU_DISPLAY overrides the display option: KDOS_QEMU_DISPLAY=gtk,gl=es makes the guest follow the window, and KDOS_QEMU_DISPLAY=egl-headless runs with no window at all.

make debug-boot boots build/fs/boot/vmlinuz-kdos and build/fs/boot/initramfs.cpio.gz directly, with the ISO attached and the kernel’s console on both the screen and the serial port (-serial stdio), so the serial console prints in your terminal. The kernel command line carries quiet loglevel=3, the same as the default Limine entry, so only kernel messages at error level or above appear there. For every kernel message, boot the KDOS Live (verbose) entry from the Limine menu under make run, or edit the -append line of the debug-boot target. The target uses no KVM and no firmware.

Where the build puts things

Path Holds Notes
build/fs The target root filesystem Owned by root on purpose; see below
build/iso-build/kdos.iso The ISO
build/logs/<phase>/ One log per step The first thing to read when a build fails
build/logs/chroot.log Warnings from script/chroot/exec.sh: a cgroup tree it could not bind read-only, an open-files limit it could not raise
build/snapshots/<phase>/ Phase snapshots Kept by cleanbuild
build/snapshots/.held/<phase>@<id>/ Snapshots replaced or deleted while later snapshots still layer on them Deleted by the orchestrator once nothing needs them
build/snapshots/timings.json The seconds each step and phase last took when it did its work, and the machine that measured each Merged on every step, so a partial run keeps the figures it did not measure. Kept by cleanbuild. See Step timings
build/.snap-lineage/ One index per snapshot path, describing the tree as the last snapshot or restore left it; the next snapshot is a layer of the difference Removed by cleanbuild, which makes the next snapshot full
build/ccache/ The compiler cache CMake ports compile through, up to 20 GB Kept by cleanbuild, removed by clean. Root’s while a build runs and after a killed one, when it is removed from a container; a build that exits hands it back
build/jobserver The job-slot FIFO the ports of a level share under --port-jobs, holding KDOS_JOBS − 1 tokens Made when the first package phase under --port-jobs starts, replacing one a killed run left
build/pkgstore/ The package store, <key[0:2]>/<key>/ holding one package and its META, up to KDOS_PKG_STORE_MAX Written only with KDOS_PKG_STORE on. Kept by cleanbuild, removed by clean
build/kfs/ KDOS from Scratch as make book renders it: src/ the generated Markdown, html/, kfs.pdf, kfs-html.tar.zst Rewritten on every make book; nothing in it is committed
build/logs/pkgstore-check.log What KDOS_PKG_STORE=check found: one line per port whose rebuild differed from its stored package, then the members that differ See Testing
build/mark/ The early phases’ “already done” markers See Building from scratch
build/cross/ The cross toolchain (binutils and GCC for x86_64-kdos-linux-musl) that the first two phases compile with
build/tmp/ Scratch space for the early phases Emptied at the start of every step of those phases
build/keys/ Signing keys: kdos-release.key and kdos-release.pub, which ports/publish --release signs a release’s SHA256SUMS with, and linux-module-signing.pem, which signs every kernel module Kept by both cleans. kpkg keygen build/keys/kdos-release writes the release key, once; the linux port writes the module-signing key the first time it builds without one
build/kdos.qcow2 The virtual machine’s disk Created by make run
build/.kdosbuild The compiled orchestrator, with build/.kdosbuild.sum beside it Recompiled at the start of a build when its sources, flags or compiler changed
build/.devplan.json The build plan in force
build/kdos-base/ The base pack, with KDOS_PACK_KDOS=1
build/binhost/ The signed binhost, with KDOS_MAKE_BINHOST=1 Each run adds what it built and keeps the current packages earlier runs added; superseded ones are moved to build/binhost-superseded/
build/binhost-superseded/ The package files, with their .sig, that 70_image/010_binhost.sh moves out of build/binhost/ because their index stanza has an empty E: (a superseded release, or a port the tree has no recipe for); the step names each in its log, and one moved back into build/binhost/ is indexed again on the next run Each binhost run adds to it; nothing reads it
build/binhost-key/ kdos-binhost.key, which signs the binhost’s index, made on the first KDOS_MAKE_BINHOST=1 run, and its .pub Kept by both cleans, so every later binhost is signed with the same key
build/image-ports/ The recipe-only ports tree 70_image/105_ports.sh stages, which 110_iso.sh appends to system.sfs as /ports and script/release-image.sh --upper lays over the stage Rewritten by every image build
build/image-upper/ The image stage’s upper layer over build/fs: every change the 70_image steps from 017_stage.sh on made, the whiteouts of the packages the base leaves out among them Emptied each time 017_stage.sh starts. Root’s, like build/fs, and never handed back. See The image stage
build/image-work/ The overlay’s work directory Emptied with build/image-upper
build/image-root/ The mount point of the stage, the root each step from 017_stage.sh on is chrooted in and 110_iso.sh squashes Mounted only inside a build’s own chroot entries; empty from your machine
build/image-stage.ok Written when 017_stage.sh has trimmed the stage Deleted when 017_stage.sh starts; a later 70_image step refuses to run without it
build/fetch-home The fetch container’s home and toolchain caches Written as your user
build/freeze/ sources-<tag>.sha256, written by ports/publish --freeze
build/release/<tag>/ What ports/publish --release uploads besides the ISO: SHA256SUMS, SHA256SUMS.sig, kdos-release.pub, sources.sha256, kdos-ports.tar.xz, kdos-update.idx and their signatures, and the notes; and image/, the slot image script/release-image.sh writes The ISO’s parts are cut here and deleted when the run ends; each run clears the files and keeps image/

build/ is ignored by git in its entirety.

Some tools keep compiled helpers and data under ports/, all ignored by git:

Path Holds
ports/.srccache/ The source cache. Plain data; survives both cleans
ports/.kpkgbin/ The recipe reader ports/fetch and ports/publish compile, recompiled whenever its sources are newer than the binary
ports/.portup The version checker ports/update compiles, recompiled when a .c or .h file under src/devtools/kdos-portup/ or the three libraries it links (libkbase, libkpkg, libkbuild) is newer than the binary
ports/.portup-tools/ The version checker’s own copy of the recipe reader, compiled when missing or when it cannot run; a change to its sources does not trigger it
ports/.update-cache.json The version checker’s results, kept for 24 hours

Those helpers are compiled against whichever C library ran them last: musl in an Alpine container, usually glibc on your machine. A binary built against one cannot run under the other, and the failure does not say so: ports/fetch and ports/publish report every recipe as unreadable (cannot read its kpkgbuild, kpkg cannot read its recipe), and ports/update fails to start its checker with the shell’s No such file or directory. The version checker’s own recipe reader under ports/.portup-tools is tested before each use and rebuilt when it exits with status 127, so it recovers from a C-library switch by itself; the other two do not. make build mounts ports/ read-only and make fetch’s container keeps its own recipe reader under build/fetch-home, so neither touches them. Running ports/update, ports/fetch or ports/publish yourself inside a container that mounts the repository read-write does, for example any Alpine-based development container. Delete ports/.portup, ports/.portup-tools and ports/.kpkgbin afterwards and let the next run recompile them. A container that runs as root leaves those paths owned by root, so remove them from a container rather than with sudo. The source cache, ports/.srccache, is plain data and does not need clearing.

build/fs is deliberately not handed back to your user, and neither are the image stage’s layers, which hold the same files. Changing ownership across that tree would clear every setuid bit (pam_unix’s password checker unix_chkpwd, without which the lock screen and the login refuse every password, and the two user-namespace mapping helpers without which no container can start), and would leave the account and privilege files owned by an ordinary user. Reading it from your machine needs a container or root.

Where sources come from

Every source file that git does not carry is stored in the repository kunaldawn/kdos as a release asset. The archive is a run of numbered volumes, releases tagged sources-1, sources-2 and on, each titled Sources N: <first shelf> … <last shelf> after the shelves it holds. The second field of a shelf’s line in ports/shelves is its volume, and a volume holds the files of its shelves as <shelf>--<file>; a file only old history names is attic--<file> in the highest volume. These releases are pre-releases and never the latest release, so the repository’s latest release is always a KDOS system release. The committed file ports/sources.idx says which release and which asset hold each hash, one line per file, sorted by hash, after a header whose first line is # kdos-sources-index 2. A line looks like this:

8dadd7d2536a314f982ad05a651b713f426bf7d02cc2c76cffb9796f2218e6c5 sources-3 net-libs--curl-8.23.0.tar.xz curl/curl-8.23.0.tar.xz

so that file’s address is

https://github.com/kunaldawn/kdos/releases/download/sources-3/net-libs--curl-8.23.0.tar.xz

The second field is the volume, which is the shelf’s own unless that volume was full when the file was stored; the file then went to the lowest-numbered volume with room, or opened the next one. A line whose tag is src-<shelf> names a file still in the older layout of one release per shelf; it fetches the same way until ports/publish --rehome moves it. The third field is the name GitHub stored, which is what the address uses; the fourth is the file’s own name. The asset name is <shelf>--<file>, and differs further when GitHub rewrote a character outside [A-Za-z0-9._-] (each becomes . and a run of dots one, so libsigc++2 is stored as libsigc.2), or when that name was already taken in the volume and the file was stored as <shelf>--<port>--<file> or <shelf>--<port>--<hash12>--<file>. A file larger than 1900 MiB is stored in parts, <asset>.part01 … <asset>.partNN, each under GitHub’s 2 GiB limit per asset, and its line ends in parts=<N>:<h1>,…,<hN>, the hash of each part in order.

A name is only an address. The recipe hash and the digest GitHub computes for the asset are the same string, so a file that verifies is the file the recipe meant, whichever route it came by. The archive is append-only by default: an asset whose digest matches its index line is never replaced or deleted, so an old checkout can still find the exact bytes it was written against after upstream has moved on or gone. The two deliberate exceptions are ports/publish --rehome, which moves a file to the volume and name of the shelf its port now sits on and deletes the old copy only after an index naming the new one is pushed, and ports/publish --orphans --prune=yes-delete, which deletes files no current recipe and no recipe at any v* tag names. Each volume’s notes on GitHub hold a section per shelf, its description and then every file of it the volume holds in a table, with links, so a file can also be found by browsing the Releases page. ports/srclib.sh holds this addressing, and ports/fetch, ports/publish and the pre-push hook all read it from there, so the three cannot disagree about where a hash lives. An index whose first line is not the format-2 header is not read at all: ports/fetch warns once and goes upstream for everything.

ports/fetch resolves each file a sha256 = line names, other than files git tracks itself (such as patches), by trying these locations in order and stopping at the first copy that verifies:

Location
1 The port directory: a file already there
2 The cache, ports/.srccache/sha256-XX/<hash> (XX is the hash’s first two hex digits)
3 The archive, $KDOS_SOURCES_BASE/<tag>/<asset> from the hash’s line in ports/sources.idx; for a file in parts, every part, each checked against its own hash and then joined and checked as a whole. A hash the index does not name skips this step
4 The recipe’s source = URL for that file
5 Generation, only for the port’s own <name>-vendor-<version>.tar.xz

A copy that fails its hash, or is empty, is removed and the next location is tried. If the archive cannot be reached, the fetch falls through to upstream. The archive is asked before upstream because it does not disappear when an upstream host does.

The cache. Every copy that verifies is entered into the cache, and the port directory holds the same file. Both are hard links when the cache and the checkout share a filesystem, so the cache costs no extra space; otherwise each is a copy, so a cache on another disk holds a second copy of every source. Either way, switching branches downloads nothing already fetched. A cache entry whose bytes do not hash to its name is deleted rather than served. The cache holds each file under its hash, split into sha256-XX/ directories by the first two hex digits only to keep each directory small. It is ignored by git and survives make clean; deleting it costs a full re-download and nothing else. It belongs to one checkout. A second checkout or a fresh clone starts with an empty cache unless KDOS_SRCCACHE points both at a shared path, or unless it is fetched with ports/fetch --tree <dir> from a checkout that already has the cache.

Unhashed files. A file named by a recipe with no hash yet (for example, just after bumping version =) is downloaded from upstream only, with a warning, and never from the archive or the cache. KDOS_ALLOW_UNVERIFIED=1 silences the warning. A vendor bundle with no hash is generated.

Leftover archives. Source files are not tracked by git, so a pull or branch switch that moves a port to another version leaves the old file in the port directory. No build reads it, but the recipe hash covers every file beside a recipe that no sha256 = line names, so it would rebuild the port. The next make fetch removes it when it is a hard link to its own entry in ports/.srccache, and the cache keeps the bytes; make fetch-check lists it. A copy with no link into the cache is left where it is, and testing/preflight.sh lists it as a stale fetched archive; it may be the only copy on the machine. See Archives preflight accepts.

Interrupted downloads. A download goes to <file>.part and is renamed into place only once it verifies. The next run resumes the partial file. If a resumed download fails its hash, it is fetched once more from the beginning from the same URL before the next location is tried, because the partial file may have held the start of different bytes.

Vendor bundles. Ports written in Rust, Go, Node, Python and Haskell build offline from a vendor bundle: a tarball of their dependencies, generated by the language’s own package manager. For Rust, Go, Node and Haskell that toolchain is the version this tree compiles with; Python bundles are resolved by the python3 and pip of the fetch image’s Debian release, not by the tree’s own Python. A recipe asks for one with vendoring = (rust, go, node, haskell or python) or with pypackages =. In the current tree 80 recipes use rust, 39 go, 43 python, 4 haskell and 2 node, and one more asks for a Python bundle with pypackages = alone. A default make fetch runs in two passes. Your machine resolves everything it can from the first four locations with curl and sha256sum. Only a port whose vendor bundle is still missing is handed to the kdos-fetch container, which generates it; a clone whose archive is complete never builds that image. A port missing any other file is not handed over, because its bundle cannot be generated without its source, and fails on your machine.

The kdos-fetch image is built from ports/Containerfile.fetch on Debian trixie, with the Rust, Go, Node, GHC and cabal versions read from the rust, go, nodejs, ghc and cabal-install recipes. It runs with host networking and as your own user and group, so everything it writes is yours; its home directory and each toolchain’s cache live in build/fetch-home. A generated bundle is held to its recipe hash like a download. Bundles are built reproducibly (sorted names, a fixed timestamp, owner 0, xz -9 -T1), so the same inputs give the same bytes.

Command Does
ports/fetch [port…] Fetch every port, or only the named ones
ports/fetch --check [port…] Offline: list each archived file that is missing or fails its hash, and each recipe that cannot be read; exit 1 if any. make fetch-check runs it over every port
ports/fetch --tree <dir> [port…] Fetch for the ports/core of another checkout <dir>, using this tree’s archive logic, recipe reader, cache and index. Never generates a vendor bundle

A port is always named by its bare name, never by its shelf: ports/fetch pv fetches ports/core/cli/pv. A named port that does not exist fails the run, in every mode, so a typo is not mistaken for a port whose sources are all in place; ports/publish <port> behaves the same way.

A checkout with no ports/srclib.sh cannot fetch from the archive by itself, and this tree’s ports/fetch cannot be copied into it, because it needs srclib.sh beside it. Fetch for it from a checkout that has one instead:

ports/fetch --tree ../other-checkout

This works because the newest ports/sources.idx names every file an older checkout’s recipes can ask for, wherever it now sits, except a file pruned as an orphan, which comes from upstream. In this mode, a file the other checkout tracks through a Git LFS filter counts as an archive to fetch, because without LFS its working copy is only a pointer.

Variable Default Effect
KDOS_SOURCES_REPO kunaldawn/kdos The archive repository
KDOS_SOURCES_BASE https://github.com/$KDOS_SOURCES_REPO/releases/download The archive’s download base. Set it empty to use upstream only. A path with no scheme is a directory laid out as <dir>/<tag>/<asset>, such as a copy of the archive on a disk; ports/fetch reads it, and ports/publish and the pre-push hook refuse it, since it cannot show what is published
KDOS_SOURCES_INDEX ports/sources.idx The index to read
KDOS_SRCCACHE ports/.srccache The cache. A path outside the repository is mounted into the fetch container
KDOS_FETCH_HOST unset 1: one pass on your machine, generating vendor bundles with its own toolchains
FETCH_JOBS 1 How many ports ports/fetch works on at once, --check included; make fetch and make fetch-check pass it through. Above 1, each port’s lines print together when it finishes, and a run that generates vendor bundles still generates them one at a time
KDOS_ALLOW_UNVERIFIED unset 1: no warning for a file its recipe gives no hash
ENGINE_OUT docker if installed, else podman The container engine for generating vendor bundles
CC cc The compiler for the recipe reader, ports/.kpkgbin/kpkg

The pre-push check

The pre-push hook makes four checks, in this order, and stops at the first that fails. Each prints the variable that skips it.

The ports layout. At the tip of each pushed ref that no remote already holds, read from git’s own tree rather than your working copy, the hook requires every kpkgbuild under ports/core to be exactly at ports/core/<shelf>/<name>/kpkgbuild, with <shelf> listed in that commit’s ports/shelves; every bare port name to be unique across ports/core and the src/ areas; and no listed shelf to be named libs or core, to share its name with a port, or to use anything but lowercase letters, digits and -. It needs no network. Only the tip is checked, because only the tip is built: an intermediate commit whose breach a later commit repairs passes. A refusal starts pre-push: the ports layout is broken at <commit>: and lists each breach. testing/preflight.sh checks the same and more; the hook holds when preflight was not run. Set KDOS_SKIP_LAYOUT_CHECK=1 to skip it.

Patch headers. Every .patch or .diff under ports/ or src/ that a pushed commit no remote holds adds or changes must carry a Subject: line in its mail header, before its first diff, --- or Index: line, because KDOS from Scratch prints that line on the port’s page. A [PATCH] tag alone is not a subject. A patch moved without a change is not new. Set KDOS_SKIP_PATCH_CHECK=1 to skip it.

The books. testing/docscheck.sh, testing/kfscheck.py and script/site/mksite.py --check run over the working copy, not the pushed commit, so push from a checkout of what you are pushing. A stale recipe stamp fails here until make book-stamp has run, and a README.md that is not what the pages under site/ make until make site has; see Make targets. Set KDOS_SKIP_BOOK_CHECK=1 to skip it.

The archive. The hook then enforces the archive’s side of fetching. For each ref pushed, it takes the hashes the pushed commit’s recipes name and the remote’s current commit does not, and requires each to be listed in ports/sources.idx as of the pushed commit and present at the archive address that line gives, every part of a file stored in parts. For a new branch the comparison is against every remote-tracking ref. A file git itself carries, such as a patch, is not checked; a Git LFS pointer is not the file, so the file it stands for is. The hook also refuses the push when it cannot reach the archive, or the archive answers anything other than 200 or 404, since it then cannot prove the sources are there, and when KDOS_SOURCES_BASE is empty or a local directory. Set KDOS_SKIP_PUBLISH_CHECK=1 for a push you know is safe; it skips this check only. Setting core.hooksPath replaces .git/hooks entirely, including any hooks git-lfs installed. How a new source reaches the archive is in Publishing sources.

Rebuilding one thing

A full build takes hours, and almost no change needs one. Find what you changed in this table:

Changed Run
Something under fs/ make build BUILD_ARGS="--phases 10_bootstrap,70_image --steps 10_bootstrap:000_file_system.sh"
One port’s recipe make build BUILD_ARGS="--phases <its phase>,70_image --rebuild <port>", for example --phases 41_system,70_image --rebuild pv
A Plasma module, or a KDOS desktop component (src/desktop, src/daemons, or src/art’s login theme and add-ons) make build BUILD_ARGS="--phases 50_desktop,70_image --rebuild <port>"; leave 70_image out to look at it with testing/quick.sh instead
A KDE Frameworks, Plasma or Gear release Every recipe of that family in one change, then make build BUILD_ARGS="--continue-from 41_system" for Frameworks or --continue-from 43_toolkits for Plasma or Gear; see below
The book under docs/ make build BUILD_ARGS="--phases 41_system,70_image"; see below
kdos.dev or README.md (site/) make site; no build. See below
A library under src/libs/ make build BUILD_ARGS="--phases 10_bootstrap,41_system,42_graphics,43_toolkits,50_desktop,70_image --steps 10_bootstrap:120_kpkg.sh,10_bootstrap:130_kinstall.sh"; see below
The installer (src/system/kdos-installer, src/system/kinstall-core, or kdos-appbox’s catalogue.c) make build BUILD_ARGS="--phases 41_system,70_image --rebuild kdos-installer"; see below
Only packaging make build BUILD_ARGS="--phases 70_image"
Only packaging, for the rig make build KDOS_ISO_COMP=zstd:3 BUILD_ARGS="--phases 70_image"
Nothing; a step failed and the fix is in the tree R in the failure panel, without quitting; see When a build fails
Nothing; resuming a run after quitting it make build BUILD_ARGS="--continue-from <the phase it stopped in>"
Every phase, on the existing tree, skipping the startup picker make build BUILD_ARGS=--fresh

Use the phase that installs the port. Add 70_image whenever you want a new ISO from the change. A new port is built only once a phase list names it. In 40_lang to 44_apps the list is a directory, packages.d/, whose files are each named for a shelf (<shelf>.txt) or a src/ area (src-<area>.txt) and name only ports filed there. A packages.d/ may also hold 00-order.txt, which sorts first and installs its ports ahead of every shelf in the order written; it is for a run whose order a comment pins, and the one file there that may name a port an earlier phase installs. 41_system carries one that names no port. Every other package phase has a single packages.txt. Which phase lists a port says which phase a new port belongs to. The ports catalogue lists every port by shelf with its phase. To find the phase from the tree:

grep -lx '<port>' script/phases/*/packages.txt script/phases/*/packages.d/*.txt   # the lists that name it
ls build/logs/*/*_<port>.install.log                                            # the phase whose logs hold its install

From 30_foundation on, every port a phase installs is named in that phase’s list, so for almost every port the first command prints one file, and the phase is the directory in its path. 9 ports are named in more than one list: 20_selfhost’s fortify-headers, musl, gcc, binutils, m4, tar, diffutils, gawk and zlib are named again in 30_foundation’s pinned run. A later list names a port again so that it is rebuilt there when its recipe has changed, before the ports after it use it. For these the first command prints several files. Pass only one of those phases: --rebuild forces the port in every selected phase whose resolved install order contains it, as a listed port or as a dependency, so selecting two such phases compiles it twice. The latest phase that names it is the usual choice, because a port rebuilt under a phase is built with that phase’s environment, and the latest one is the environment it was last built with. The environments differ: 20_selfhost names no compiler, while every later phase sets CC=gcc and CXX=g++. PORT_REPO differs too: src/system and src/art are on it from 40_lang on, and src/desktop and src/daemons only in 50_desktop.

Four ports in ports/core are named in no list. They are dependencies of 20_selfhost’s list (gmp, mpfr, mpc and xxhash), so that phase installs them, and the second command finds it. Every other recipe is named by a phase list. ports/unbuilt is the list of recipes no phase builds on purpose, kept for kpkg install on a machine that wants one, and it names none; testing/bookcounts.py fails on a recipe no phase installs that ports/unbuilt does not name.

Editing a library rebuilds every port of KDOS’s own, not only the ones that use it. KDOS’s own programs are recipes under src/system/, src/art/, src/desktop/ and src/daemons/. Such a recipe has no upstream tarball, so its recipe hash covers its own directory and the whole of src/libs; working out which libraries a build.sh actually compiles would need a shell parser inside the package manager. Each of these ports takes seconds to compile. Upstream ports are unaffected. The phase lists install every one, in 41_system, 42_graphics, 43_toolkits and 50_desktop, and their changed hash is enough to rebuild them, so they need no --rebuild. The Qt ports of src/desktop compile in minutes rather than seconds; a change to a library none of them links still rebuilds them. The installer is the exception to “no --rebuild”: kdos-installer, at the end of 41_system’s src-system.txt, also compiles src/system/kinstall-core and catalogue.c from src/system/kdos-appbox, and its recipe hash covers neither, so an edit to either alone rebuilds it only when --rebuild kdos-installer names it, as in the installer row above. Its package adopts the /usr/bin/kinstall that the 10_bootstrap step 130_kinstall.sh compiled from the same sources for the trees before 41_system, so the package’s copy is the one on the image and on the binhost; that step runs again only when its mark is gone or --steps 10_bootstrap:130_kinstall.sh names it.

The book is a port too. src/system/kdos-doc renders docs/kdos to HTML under /usr/share/doc/kdos, writes kdos(7), which says where the book is and lists its chapters, and writes one manual page for every kdos-* command in the command index, and for the commands of ours named without the prefix (kpkg, kpkgadd, kpkgdel, kpkgbuild, kpkgdepends, ksvc, service, kinstall, xdg-terminal-exec, listed in mkbook.py), whose DESCRIPTION is the book section that command’s row links to, with the section’s “this chapter” read as “this page” and each link to another page of the book printed as its text and the kdos-doc command that opens it, Installation (kdos-doc 02-user-guide/installation). A preformatted line of a section a manual page is made from stays within 72 columns, because man sets it 7 columns in and never wraps it; selftest fails one that does not. A page’s NAME line, which whatis and apropos print, is that row’s description cell as plain ASCII text: lowdown renders every manual page with smart typography off (--out-no-smarty), the markdown specials in the cell are escaped, and typographic dashes, quotes and ellipses become their ASCII forms, so --json and $XDG_RUNTIME_DIR read as typed, and each description cell has to make sense read alone, with no neighbouring row. Its directory holds two symbolic links, kdos to docs/kdos and screenshots to docs/screenshots, and the recipe hash follows them, so an edit anywhere in the book or its pictures changes kdos-doc’s hash and the next 41_system run rebuilds it with no --rebuild. An edit elsewhere under docs/ does not. The build container mounts docs/ read-only, and script/chroot/exec.sh binds it read-only at /kdos/docs. The generator, mkbook.py, fails the build when a row of the index links a section the book does not have, and leaves out a command whose own port ships its manual page (kdos-bb.1). mkbook.py --html DOCS DEST writes the HTML book alone, into DEST, from any directory holding kdos/ and screenshots/; the published site is made that way from docs/, with --site https://kdos.dev/, which gives each page its canonical address, sends a link into docs/kfs to that page of the site’s KDOS from Scratch, and sends a link to the repository’s README.md to the homepage, which is written from the same source. The site’s bar along the top of each published page is mksite.py’s, not mkbook.py’s, so the book on a machine has none.

KDOS from Scratch is a port the same way. src/system/kdos-kfs, also in 41_system, renders docs/kfs with pandoc and typst and installs the HTML under /usr/share/doc/kfs with kfs.pdf beside it. ports/base names kdos-doc and not kdos-kfs, so the image carries the KDOS book alone, and a machine adds the second with sudo kdos update install kdos-kfs. Its directory holds docs, a link to docs/kfs, and book, a link to script/book, so an edit to either book’s pages rebuilds only its own port, and an edit to the renderer rebuilds kdos-kfs. A package page is generated from its recipe, its kfs.md and the phase lists, which no link reaches, and Parts I to IV show lines of the step scripts, the Makefile and the Dockerfile, so an edit to any of those reaches kdos-kfs through docs/kfs/data/recipes.stamp once make book-stamp or make book-data has rewritten it. The port renders from /kdos, the checkout as the chroot sees it, and reads the recipes at /kdos/ports; it takes about two minutes. The full file list on each package page comes from the chroot’s package database, so it names only what is installed before kdos-kfs builds.

Both books are also published, at kdos.dev. .github/workflows/books.yml builds the site on every push to main and deploys it to GitHub Pages: the site’s pages from site/, the KDOS book under book/, KDOS from Scratch under kfs/ with kfs/kfs.pdf, and, at the root, a stub for every page of the KDOS book that sends the reader on to the same page under book/, #fragment and all. It renders docs/kdos with mkbook.py --html and Ubuntu’s lowdown, and docs/kfs with make book and upstream’s pandoc and typst release binaries at the ports’ versions, each checked against a sha256 written in the workflow; a version bump in either recipe is a bump there too. The site comes last, from script/site/mksite.py --check, which puts the site’s bar at the top of every page of both rendered books, writes the stubs and sitemap.xml from them, and stops the run before anything is deployed when README.md is stale or a link from the KDOS book into KDOS from Scratch lands on no page or heading of it. When a v* release is published the workflow renders the book from its tag and attaches kfs.pdf and kfs-html.tar.zst to it. The repository’s Pages source must be GitHub Actions: the tree carries no Jekyll configuration, and a branch-built site would try to render all of it. The custom domain, kdos.dev, is set in the repository’s Pages settings.

kdos.dev and README.md are one source. The website and the repository’s front page say the same things, so they are written once, as Markdown pages under site/, and script/site/mksite.py makes both from them. A page’s address is its file name:

make site runs mksite.py, which writes two things. The site goes into build/site (SITE_OUT names another directory), each page as NAME/index.html made from site/template.html and dressed by site/style.css and site/site.js, with 404.html, robots.txt, a sitemap.xml of every page, and the pictures and fonts of site/assets. README.md goes at the root of the checkout, as GitHub-flavoured Markdown made from the pages whose front matter gives a readme: position: the homepage first, then the Get KDOS page, whose headings drop one level there. Edit the pages and run make site; an edit to README.md alone is undone by the next run, and make sitecheck, which make check and the pre-push hook run, fails until the two agree.

A link to another page of the site is written page:NAME#id; the README turns it into #id when that page is in the README and into the page’s kdos.dev address otherwise. book:PAGE.md#id is a page of the KDOS book, kfs:PAGE.md a page of KDOS from Scratch, kfs: that book’s rendered contents and kfs:kfs.pdf its PDF, both on kdos.dev from either output, repo:PATH a file of the checkout and asset:PATH a file under site/assets, and every one is checked; a kfs: link is always to a whole page, with no #fragment. A page is a small subset of Markdown with block directives (::: hero, ::: tiles, ::: books, ::: facts, ::: gallery, ::: accents, ::: include, ::: news and the rest), each described in the comment at the top of mksite.py. Every number on a page is a {{NAME}} the script reads from the tree: the release from fs/etc/os-release, the port count from ports/core and KDOS’s own recipes under src/, the boxed applications from the catalogue, the Plasma, Frameworks, Gear, kernel and musl versions from their recipes, the accents from KCOL_SCHEMES, the licences of KDOS’s own packages from their recipes and of kpkg from the bootstrap step that compiles it, the developer from LICENSE, the disk two system slots need from kinstall-core’s own sizes, which ports/RELEASE must state as well, and the smallest disk one slot takes from ports/RELEASE, the release key’s id from Getting started, each book’s parts and chapters from its contents, and the disk a first build needs from What a development machine needs; a name it does not know, or a fact it cannot find, stops it. So does a link to a page of the site or of the book whose page or heading is missing, a screenshot shots.tsv lists that no page shows, an accent whose colours would set text below WCAG AA contrast, and artwork drawn from inputs that have changed since. The pages’ colours are custom properties written from KCOL_SCHEMES, one rule per accent, and their scripts and stylesheets request nothing from another host, which the script checks in what it writes. It needs only Python 3’s standard library.

To look at the site, serve build/site (python3 -m http.server -d build/site) and open it; ?accent=amber picks an accent and ?phosphor=1 turns Phosphor mode on for one visit, without remembering either. The deployed site adds the two books: mksite.py --out DIR gives every page of DIR/book and DIR/kfs the site’s bar, with a link past it to the page’s first heading that has an id (or to its <main> when none has), and the description and Open Graph card the site’s own pages carry; a page of the KDOS book also gets the book’s name after its own in its title, as every page of KDOS from Scratch has already. It writes the stubs (the root README.html sends the reader to book/, that page’s canonical address) and lists the books in sitemap.xml when it finds them there, as the workflow puts them. --check --out DIR writes the site all the same while README.md is stale, and exits 1.

The site’s pictures and fonts are generated, and committed. No picture under site/assets/art/ is drawn by hand: site/art/genart.py draws every one of them from the tree. In each of the eight accents it draws the block wordmark banner, the boot splash’s penguin, a swatch card of the accent’s colours, and the covers of both books, the KDOS book (cover-book-<accent>.png) and KDOS from Scratch (cover-kfs-<accent>.png), which the Books page and the homepage show. Once each, it draws the 88x31 buttons (the small badges the homepage lines up, in the style of an old web page), a CRT bezel to lay a screenshot under, the social card a link preview shows, the README’s banner, a dithered rule, a bullet, the favicons, and the pixel icons that head the site’s cards and tiles: pixel-book, pixel-books, pixel-code, pixel-compare, pixel-faq, pixel-floppy, pixel-news, pixel-package, pixel-press, pixel-shield, pixel-slots, pixel-terminal and pixel-window. Beside them it writes art.tsv, one line per file with its size, its purpose and its alt text, empty for a decorative one, and inputs.tsv, the SHA-256 of each input below but the fonts, which mksite.py recomputes on every run and stops on when one differs. It reads the accents from KCOL_SCHEMES in src/libs/libkcolor/kcolor.h, the wordmark from fs/usr/share/kdos/logo.txt, the penguin from src/art/kdos-splash/penguin.h, kdos.png and the kdos-icons marks, and sets its captions in the Terminus and misc-fixed bitmap strikes of a built tree’s build/fs/usr/share/fonts (--fontdir names another), so a change to any of them is a re-run, never an edit of a picture. Any Python 3 with Pillow runs it from the checkout, python3 site/art/genart.py; --check draws in memory instead and exits 1 when a committed picture’s pixels differ from what the inputs give, or when site/assets/art/ holds a file it does not draw. --fonts also writes the page’s web fonts to site/assets/fonts/ with their licences: Terminus as a whole WOFF2, since its licence reserves the name for an unmodified font, and JetBrains Mono subset to Latin, box drawing and blocks, without hinting or ligatures. That needs fontTools and brotli, which the built tree’s own Python carries:

PYTHONHOME=$PWD/build/fs/usr build/fs/usr/lib/libc.so --library-path build/fs/usr/lib \
    build/fs/usr/bin/python3 -I site/art/genart.py --fonts

Three programs link the libraries outside any recipe. The orchestrator is recompiled at the start of every build. The package manager kpkg and the installer kinstall are compiled by the 10_bootstrap steps 120_kpkg.sh and 130_kinstall.sh, which is why the command above names them. 120_kpkg.sh recompiles whenever its sources’ hash differs from the one it recorded; 130_kinstall.sh exits at once when its completion marker under build/mark/ exists, unless the build plan names it; that section also explains what a plan suppresses and why only the named ports are forced. Leave the 10_bootstrap part out when your change touches neither program’s libraries.

A KDE release is bumped as a family. KDE Frameworks, Plasma and KDE Gear are each released as one set built and tested together, and preflight refuses a tree holding two releases of one family (preflight.sh). A bump therefore changes every recipe of the family in one change, each with its new sha256 = line published, and rebuilds from the earliest phase that holds one of its ports. For Frameworks that is 41_system, which installs extra-cmake-modules; Plasma’s and Gear’s first ports are in 43_toolkits (Plasma’s libraries, Breeze, its sound themes and wallpapers; Gear’s libraries, kdeedu-data and the first applications). A port whose recipe did not change is skipped as installed and current, and every one that did is rebuilt where its list names it. grep -rlx <port> script/phases/*/packages* names the phase of any one of them.

KDOS’s version-locked components follow their family, and a bump is not done until each of them builds and passes its tests against the new release:

Family Component Locked to
Plasma kdos-discover: the backend, the update notifier’s plugin and the model The exact Discover release; its CMake refuses any other
Plasma ksystemstats-kdos libksysguard’s sensor plugin interface, which is not stable
Plasma plasmoid-kdos-privacy Plasma’s applet interface (find_package(Plasma 6.8))
Plasma The patches to Plasma’s modules: kwin (Phosphor mode’s kdos-crt, sandbox-policy, sandbox-badge), kdecoration, plasma-desktop, plasma-workspace, libksysguard, discover, kde-gtk-config, plasma-setup, plasma-welcome, systemsettings, breeze, kdeplasma-addons, krdp, ksystemstats, plasma-systemmonitor, xdg-desktop-portal-kde and kup (restic-backend), and kdos-sddm-theme’s kdos-sddm.patch to plasma-desktop’s Breeze greeter The sources of that release; each is rebased
Frameworks The patches to kio, kcmutils, kguiaddons, kwidgetsaddons and qqc2-desktop-style The same
Gear The patches to the Gear applications that carry one, about thirty of them, dolphin, ark and kio-extras among them The same

ls ports/core/*/*/*.patch src/*/*/*.patch lists every patch the tree carries, and a port’s kfs.md says what each of its patches does. testing/plasmatest.sh builds and tests every Qt port of KDOS’s own against the Frameworks and Plasma in the development image.

For a desktop component there is a faster loop still: testing/quick.sh builds only the named ports into build/fs, with no packaging, patches the files they own into the RAM overlay of a booted ISO and restarts what reads them, KWin or plasmashell or nothing. It cannot carry anything under fs/, a new port, an SDDM theme, or a program that owns a D-Bus name, and what it shows is not evidence about the shipped image. See Testing.

Building from scratch

--fresh, and start fresh in the picker, run every phase on the tree already in build/. They do not empty it: each 00_cross and 10_bootstrap script exits at once when its marker under build/mark/ exists, and the build skips every port already installed from the same recipe. To build from nothing, empty the three trees that record that progress first. build/fs belongs to root, so do it from a container:

docker run --rm -v "$PWD/build:/b" os-dev rm -rf /b/fs /b/mark /b/cross
make build BUILD_ARGS=--fresh

Budget a day or more for the build that follows. It writes no snapshots unless given --snapshot (make build BUILD_ARGS="--fresh --snapshot") or S in the picker; with them, budget the disk as well: 00_cross archives build/cross, build/fs and build/mark compressed, and each later phase to 50_desktop a layer of what it changed. A complete set has not been measured; see Snapshots, which also says how a phase opts out of its snapshot.

Things to avoid while a build runs

Working without a build at all

Much of the system can be checked on your development machine, with no container and no virtual machine:

testing/preflight.sh                              # the wiring: a few minutes
testing/selftest.sh                               # libraries, daemons and their consumers: a few minutes
testing/devdeps-image.sh plasmatest               # the Qt code, in the development image
make snapshots                                    # compiles build/.kdosbuild for this machine if needed
build/.kdosbuild --preview build 132x43 vt        # a build screen, drawn as text

testing/preflight.sh checks the wiring a full build would otherwise fail on: that the ports tree is shelved and every name is one port, that every package phase from 30_foundation on installs exactly the ports its list names, that every recipe parses, that the phase scripts are valid shell, and similar. testing/selftest.sh compiles kdosbuild, kinstall and the other C programs it tests into a temporary directory, which it deletes when it exits, and runs their assertions. Among other things it resolves the installer’s plan over the shipped catalogue (kinstall --dump plan), and runs the root daemons against recorded /proc trees and on a private bus with stand-ins for their peers. Its Unix sockets and pack store live in a short directory of their own under /tmp, so a TMPDIR of up to 172 characters serves; see TMPDIR. On one development machine each script took about two and a half minutes. testing/plasmatest.sh is the Qt half: no bare host has Qt 6, KDE Frameworks 6 and Plasma’s development files, so it runs in the development image and refuses anywhere else. What each harness proves is in Testing.

build/.kdosbuild runs on your machine only when your machine’s compiler built it, which make snapshots does. make build replaces it with a musl binary compiled in the build image, which a glibc machine cannot run; the shell then reports No such file or directory without mentioning the missing musl loader. build/.kdosbuild.sum names the compiler as well as the sources, so each side recompiles when the other built the binary last. Run make snapshots again after a build, or keep a separate copy with KDOSBUILD_BIN=build/.kdosbuild-host script/kdosbuild.sh --list. --preview draws one of the screens build, activity, failure, pinned, complete, startup, plan or packages at the given size, in one of the glyph tiers rich, vt or ascii (which set of drawing characters the screen may use).

When a build fails

Work through these in order:

  1. The failing step’s log, under build/logs/<phase>/. The orchestrator names it; in the panel it opens when a step fails, O opens the log and C copies its path (see Keys).
  2. Build troubleshooting, which lists the failures that recur, by symptom. Check it before debugging from scratch.
  3. The port’s own config.log, if a configure script failed. kpkg leaves a failed port’s unpacked source in place at build/fs/var/cache/kpkg/work/<name>/<name>-<version>/. build/fs is owned by root, so read it from a container or as root. C compiler cannot create executables rarely means what it says; the real error is in the log, next to the test program that failed.
  4. testing/preflight.sh, which catches wiring mistakes (a missing dependency, an unlisted port) before a build that runs for hours finds them.

Fix and retry without quitting. Leave the failure panel up, fix the recipe, the phase list, a depends = line or kpkg itself in another terminal, and press R. For a phase after 10_bootstrap the orchestrator runs 10_bootstrap/120_kpkg.sh first, which does nothing unless a source kpkg is compiled from has changed and then compiles it into the tree again, and then runs the failed step’s phase again from its list as it reads now: a package phase is resolved again with kpkgdepends, and its ports already installed and current are skipped as on any pass; a script phase runs again from the step that failed. The run then carries on through the rest of the phases it was started with. See Retrying a failed phase. --continue-from is for the other cases: a run that was quit, a change that needs an earlier phase run again, or a build with no terminal.

Cutting a release

A KDOS release is a git tag and the GitHub release of that tag on kunaldawn/kdos, which carries the base ISO, the binhost every other package is installed from, a list of every source hash the tag’s recipes name, the tag’s recipe tree signed for kdos update fetch, and a signed checksum list over all of them. The source list says what the release needs to build; the hashes themselves are pinned by the tag, whose recipes git cannot change without changing the tag.

The release key is made before the build, because the build copies its public half into the image’s /etc/kdos/keys/tree: that is how an installed machine knows which trees to accept. An image built with no key takes no tree.

kpkg keygen build/keys/kdos-release          # once; build/keys survives both cleans
$EDITOR ports/RELEASE fs/etc/os-release     # this version's notes, at most 16 KiB; VERSION and VERSION_ID = <tag> without its v
git add ports/RELEASE fs/etc/os-release && git commit -m "RELEASE: <tag>"
git tag <tag> && git push origin <tag>        # exactly one release tag (v<digit>…) on the commit
git switch --detach <tag>                     # build from the tag, not the working tree
git status --porcelain                        # must print nothing: untracked files count
make fetch && make build KDOS_MAKE_BINHOST=1   # the base ISO, and the binhost in build/binhost with its index;
                                               # fails when the ISO passes 1,900 MiB
grep 'names release' build/logs/70_image/*_ports.sh.log    # /ports/TREE names release <tag>
script/release-image.sh --root build/fs --upper build/image-upper --out build/release/<tag>/image \
    --key build/keys/kdos-release.key --version <tag> --prev <an earlier image directory>   # as root
make release TAG=<tag> PUBLISH_ARGS=--dry-run   # the plan and build/release/<tag>/notes.md: no network, no token
make release TAG=<tag>                          # a DRAFT release with every asset
make release-publish TAG=<tag>                  # make it public and Latest

Six conditions make the build a release:

  1. ports/RELEASE holds the notes of the version being built, in Markdown with no top-level title, at most 16 KiB, committed in the tagged commit. 105_ports.sh copies it to /ports/RELEASE, where kdos update notes and What’s New read it, and stops the build with FATAL: /ports/RELEASE is missing without it or FATAL: ports/RELEASE is over 16 KiB; kdos update notes shows only the first 16 KiB when it is larger, since nothing reads past 16 KiB.
  2. The commit carries exactly one release tag (v<digit>…), or KDOS_GIT_TAG=<tag> names the one that is the release.
  3. The checkout is clean, untracked files included: only then does the image’s /ports/TREE name the release, as version <tag>, and a machine find the release’s binhost with no binhost = (see The release tag).
  4. The 70_image log says /ports/TREE names release <tag>.
  5. ports/publish --release is given the same tag; it refuses an ISO that does not name it.
  6. fs/etc/os-release says VERSION and VERSION_ID are the tag without its v (0.2.1 for v0.2.1), committed in the tagged commit. About this System, kdos version, the boot menus, What’s New and /etc/kdos-release all name the release from that file. 045_identity.sh stops a release build with FATAL: release <tag> but /etc/os-release says VERSION_ID=<v> — bump fs/etc/os-release, or run 10_bootstrap:000_file_system.sh again if it is bumped, and ports/publish --release refuses an ISO whose /etc/os-release says another VERSION_ID. The build root takes the file from fs/ in 10_bootstrap’s 000_file_system.sh, so a tree built before the bump needs that step run again (--phases 10_bootstrap,70_image --steps 10_bootstrap:000_file_system.sh).

The three are ports/publish --release <tag> with --dry-run, with nothing, and with --publish. A tag that is also a branch name on origin is refused: GitHub creates its draft untagged, so a rerun cannot find it and the release would go public with no tag. Release from a tag no branch is named after. GitHub may still list a draft as untagged-<hex>, so a draft of that form named KDOS <tag> is taken as the tag’s when no release carries the tag itself; --publish then sets its tag.

A release ISO is one asset. The build itself fails a base ISO larger than 1,900 MiB (KDOS_ISO_MAX): 110_iso.sh stops after writing it and prints the size, the limit and the top twenty of build/image-ledger, every package on the image with its bytes and the dependency path that put it there (see The image ledger and the size gate). The cure is a cut to ports/base, which the ledger names, not KDOS_ISO_GATE=0, which makes a developer image. script/lib/imageset.py --why <port> answers why one port is on the medium.

The ISO and the binhost of one tag are one unit. The default KDOS_IMAGE=base makes the ISO carry the base alone, and a machine installed from it takes everything else from the binhost of the release its /ports/TREE names, built against exactly that base. So a release is the base ISO and the KDOS_MAKE_BINHOST=1 binhost of the same build; an ISO without its binhost leaves every package outside the base uninstallable prebuilt. The slot image is made from the root the ISO was squashed from, which under KDOS_IMAGE=base is the image stage, build/image-upper over build/fs; the build mounts it only inside its own chroot entries, so it is mounted again read-only for script/release-image.sh, as above. Under KDOS_IMAGE=full that root is build/fs.

ports/publish --release <tag>:

  1. Requires the tag to exist locally and, by an anonymous git ls-remote, on origin at the same commit, and exits 1 otherwise: a release names a tree everyone else must be able to check out.
  2. Runs the --freeze list below for the tag, and stops unless every source it names is archived.
  3. Takes the ISO from --iso <path>, by default build/iso-build/kdos.iso, as the asset kdos-<tag>.iso. An ISO larger than $KDOS_PART_SIZE bytes (1,900 MiB) is cut into kdos-<tag>.iso.part01, .part02, … under build/release/<tag>/, since GitHub refuses an asset of 2 GiB. The parts are deleted when the run ends and cut again on the next.
  4. Checks the ISO and the tag against each other before anything is hashed or sent. It reads the ISO’s /ports/TREE, /ports/RELEASE and /etc/os-release from system.sfs in place, with xorriso and unsquashfs, and needs those two and xxd. It refuses an ISO whose TREE names another commit, names no release or names another one, since a machine installed from it would never find this release’s prebuilt packages; an ISO with no /ports/RELEASE; an ISO whose /etc/os-release says a VERSION_ID other than the tag without its v (<iso>'s /etc/os-release says VERSION_ID=<v>, not <tag without v> for <tag>: bump fs/etc/os-release in the release commit); and a tag with no ports/RELEASE, or one over 16 KiB. It also works out the disk two slots need for the notes (step 9). Each refusal is a FAILED line, and the real run then stops with ports/publish: <iso> is not a release image of <tag>; build the ISO from a clean checkout of the tag, then run again; --dry-run prints them, goes on, and exits 1.
  5. Makes build/release/<tag>/kdos-ports.tar.xz, the tag’s recipe tree as an image’s /ports holds it, from git archive: ports/core, ports/shelves, ports/sources.idx, ports/groups, ports/RELEASE, src/, docs/ and script/book, placed at script/book so that kdos-kfs’s book link resolves, and a TREE stamp naming the commit, its time and version <tag>, as a reproducible tar compressed with xz -9 -T1. It signs the tree with the release key as kdos-ports.tar.xz.sig and checks that signature against the public key. A tag outside letters, digits and . _ + ~ -, one that starts with . or -, or one longer than 40 characters is refused before anything else: it names the update releases and is read back from a machine’s /ports/TREE.
  6. Publishes the updates, when their directories carry a kdos-update.idx: the binhost from --binhost <dir> (default build/binhost) into public pre-releases binhost-<tag>-01, binhost-<tag>-02, … of at most 1,000 assets each, its files sorted by path, and the slot image from --image <dir> (default build/release/<tag>/image, which must be version <tag>) into the pre-release image-<tag>. Every file is hashed against its directory’s index before anything is sent, every name is flat, and every upload is append-only and resumable. It then writes build/release/<tag>/kdos-update.idx, naming each file by path with the release and asset name GitHub stored, its size and its SHA-256, and signs it with the release key and, when build/binhost-key/kdos-binhost.key is there, the binhost key as well. kdos update finds every update file through it; see Publishing a release.
  7. Writes build/release/<tag>/SHA256SUMS in sha256sum format. It names the whole ISO even when only its parts are uploaded, each part, sources.sha256, the tree, its signature, the release index and its signature, and kdos-release.pub.
  8. Signs it with kpkg sign, which writes SHA256SUMS.sig. The key is --key <path>, else $KDOS_RELEASE_KEY, else build/keys/kdos-release.key, and its public half is the .pub beside it, uploaded as kdos-release.pub. The signature is checked against that public key before anything is uploaded. A missing key stops the run; --unsigned releases without the signatures and the key, and no machine then takes its tree.
  9. Finds the release among all of the repository’s releases, drafts included, and creates it as a draft named KDOS <tag> when there is none. While it is a draft its notes are rewritten on every run, the same text --dry-run writes to build/release/<tag>/notes.md, in this order: About this release, the tag’s ports/RELEASE with each of its headings one level down; the live ISO kdos-<tag>.iso, which starts logged in as kdos (password kdos, also root’s), and the joining of its parts when there are several; what a machine needs: x86-64, UEFI or BIOS, 4 GB of memory and Secure Boot off; what the image carries, left out when the tag has a ports/RELEASE, whose opening paragraph says it; the medium the ISO fits; the disk two slots need, worked out from the ISO’s system.sfs and the tag’s src/system/kinstall-core (the limits, KI_DISK_MARGIN and KI_ROOT_FREE_MB of kinstall-core.h, and KI_VOLUME_META_MB and the default cfg.swap_mb of conf.c), for the current base about 24.5 GiB with the default 4 GiB swap, 20.5 GiB with none and 7.5 GiB for one root, and left out, with a FAILED line, when a figure cannot be read. When ports/RELEASE has a What it needs section of its own, that section is the release’s requirements and names the live account: the machine sentence, the disk sentence and the live account clause are left out, and only the medium line stays, under Download; links to the tag’s Getting started and Installation guides; the check; and the signature check with OpenSSL 3, below.
  10. Uploads the ISO or its parts, sources.sha256, kdos-ports.tar.xz and its .sig, kdos-update.idx and its .sig, SHA256SUMS, SHA256SUMS.sig and kdos-release.pub, hashing each again immediately before its upload. An asset already there with the same bytes is kept, so an interrupted run is resumed by running it again. One with other bytes stops the run with exit 2; delete it by hand, and only while the release is still a draft.
  11. With --publish, makes the release public and Latest, then asks GitHub anonymously which release is the latest, and exits 1 with a warning unless the answer is <tag>.

The draft is visible only to the repository’s writers, so the assets go out together when you publish it. Once it is Latest, an installed machine takes its tree the next time someone asks for updates: Refresh on Discover’s Updates page, or kdos update fetch at a shell. The nightly update check reads only what is already on the machine and fetches nothing. The archive’s sources-<N> volumes are pre-releases created with make_latest false, so none of them ever takes Latest from a system release.

The slot image. A release can also carry the signed whole-slot image an installed machine writes into its inactive A/B slot, with a delta from each earlier release it may still run. script/release-image.sh makes it from the root the ISO’s system.sfs is made from, as root, because that root holds files only root can read. For a KDOS_IMAGE=base build that root is the image stage: --upper build/image-upper has the script mount that layer read-only over --root build/fs in a mount namespace of its own run, so the image holds the base and nothing else. Without --upper the root is build/fs itself, which is right for a KDOS_IMAGE=full build and makes an image of every package for a base one. A layer of the run’s own goes on top with /mnt, /media and an empty /boot/efi, so the manifest names the ESP mount point that a v0.2 machine’s apply, which makes no fstab mount points, would otherwise delete.

script/release-image.sh --root build/fs --upper build/image-upper --out build/release/<tag>/image \
    --key build/keys/kdos-release.key --prev <an earlier release's image directory> [--prev-root <its root>]

It writes kdos-image.manifest and its signature, the full bundle cut into parts under 2 GiB, one .delta per --prev, and the directory’s kdos-update.idx with its signature, which names each of them; with --prev-root a changed file travels as a zstd patch against the earlier copy, without it whole. --version <tag> makes the image the release’s, which ports/publish --release requires. It compiles the image code from this checkout’s src/system/kdos-tools, the code every machine runs to read the image, and verifies the result against the key’s public half before it ends. ports/publish --release publishes the directory as image-<tag> (step 6), and the files at the top of build/release/<tag>/ are cleared on each run while image/ is kept, as the next release’s --prev. What a machine does with them is in Packaging.

Someone who downloads the release checks it, in the directory holding the ISO and SHA256SUMS, with:

sha256sum -c SHA256SUMS --ignore-missing

A release whose ISO is stored as kdos-<tag>.iso.part01, .part02, … is joined first, in a command of its own, and only then; on a single-file download the shell would empty the ISO before cat found no part:

cat kdos-<tag>.iso.part?? > kdos-<tag>.iso

The signature over SHA256SUMS is checked with OpenSSL 3 and xxd, on any system, before KDOS runs; <keyid> is the release’s key id, which the notes name:

{ printf 302a300506032b6570032100; cut -d' ' -f2 kdos-release.pub; } | xxd -r -p > kdos-release.der
awk '$2=="<keyid>"{print $3}' SHA256SUMS.sig | xxd -r -p > SHA256SUMS.sig.bin
openssl pkeyutl -verify -pubin -keyform DER -inkey kdos-release.der -rawin -in SHA256SUMS -sigfile SHA256SUMS.sig.bin

It prints Signature Verified Successfully. The key id is the first 16 hex digits of the public key’s SHA-256, which cut -d' ' -f2 kdos-release.pub | xxd -r -p | sha256sum | cut -c1-16 prints. On a running KDOS the same check is:

KPKG_KEYRING=<dir holding kdos-release.pub> kpkg verify-pkg SHA256SUMS

A public key downloaded beside the list it signs proves only that the two agree; the key id that kpkg keygen and kpkg sign print, and the release notes repeat, is what to compare against a copy obtained another way.

ports/publish --freeze <tag>, which --release runs as its step 2:

  1. Extracts the tag’s recipes with git archive, so the list reflects the tag and not your working tree.
  2. Writes build/freeze/sources-<tag>.sha256 in sha256sum format, one <hash> <port>/<file> line per source, sorted.
  3. Checks every hash against the archive, and exits 1 listing any that are missing. Publish those with ports/publish first.
  4. On its own, attaches the list as sources.sha256 to the release <tag> on $KDOS_REPO (default kunaldawn/kdos), creating a draft release pointing at the tag when none exists.

It never replaces an existing sources.sha256 with different contents; it exits 2 instead. With --check it stops after step 3 and says what it would attach; with --dry-run, as with --release --dry-run, it stops after step 2, since it uses no network. Uploading needs a token in $KDOS_SOURCES_TOKEN or ~/.config/kdos/sources-token, which is refused when anyone but you can read it; see Publishing sources.

Leave GitHub’s immutable releases off on kunaldawn/kdos: the source archive’s sources-<N> volumes live in the same repository, the setting applies to all of them, and it would freeze each at its first publication, after which no new source could be added to it.

See also


Part V — Building and developing, chapter 31. Previous: 30. How KDOS is built · Contents · Next: 32. The build system