scrotwmos

Building scrotwmos

This guide is for a developer who builds scrotwmos from source. At the end you have the programs in build/, or a signed install stick in build/install-media.img. To write the stick and install it, see installing.md. To run the tests, see testing.md.

The build host

Install the packages. Run xbps-install -n first: the dry run must show only installs. If it shows an update, run xbps-install -Su first. A partial upgrade can put libgbm out of step with Mesa.

For Packages
The tree base-devel pkgconf clang mdocml libxkbcommon-devel libseat-devel libinput-devel pixman-devel wayland-devel libdrm-devel wlroots0.20-devel libwebsockets-devel libzstd-devel libyaml-devel Vulkan-Headers iproute2
swm-x11 libxcb-devel libX11-devel xcb-util-wm-devel xcb-util-keysyms-devel xcb-util-devel libXft-devel libXcursor-devel fontconfig-devel freetype-devel libXt-devel
Kernels flex bison bc perl openssl-devel elfutils-devel signify curl xz
Disks and media cryptsetup xfsprogs dosfstools util-linux xbps zstd
Proofs qemu edk2-ovmf ImageMagick
Test legs wlrctl wtype grim xorg-server-xwayland xorg-server-xvfb xdotool xterm xdpyinfo strace wayland-protocols foot gvim

Without wlroots0.20-devel, swm-wl and scrotwmd do not build, and neither do make, make test, or make media. The rest builds:

make libcompat libswm libbus libsession libkeys swm-x11 swm-web \
    scrotwmctl swmtool

The tree builds -O2 -g with -Werror. To change the level, set CFLAGS in the environment (CFLAGS='-O0 -g' make), not on make’s command line, which make refuses. make keeps each target’s command and builds again what a changed flag reaches. make cflags prints the flags.

Keys

Every boot image is signed. You need three signify keys.

RELEASE_KEY names all three:

make install-proof and make check-appliance use the test keys when RELEASE_KEY is unset: the media they make takes its install plan from qemu only when it is TEST media. Every other check goal (make check-all, check-boot, …) takes the TEST kernel key alone for the kernels it builds; its stub and swmtool keep the keys RELEASE_KEY names, none when unset. make release and make stub refuse to build without it.

A machine keeps the release key its stub pins. A new release key reaches a machine only through a new install. Keep the old secret key until every machine installed with it is reinstalled. If a secret key leaks, make a new pair and reinstall every machine that trusts the old one.

Build

Command sudo What it builds
make no the libraries, swm-x11, swm-wl, swm-web, scrotwmd, scrotwmctl, swmtool, into build/
make vmm no swm-vmm (x86_64 only)
make musl-root yes the musl build root in ~/musl-dev and the static libraries the dom0 links
make musl-dom0 yes the static musl swm-wl, swm-vmm, and vmm-gfx
make kernel yes the session agent, swm-ntp, swm-tt, and the signed VM kernels, into build/kernel/
make pkg no the dom0 package, build/pkg/
make kernel-host no the dom0 kernel, the package as its initramfs, swm-wl as /init
make RELEASE_KEY=test release no build/release/: the stub, the signed dom0 image, the VM kernels, the byol tree, the session package repo
make RELEASE_KEY=test install-media yes build/install-media.img, its .sha256, its .manifest and its .SHA256.sig
make RELEASE_KEY=test media yes pkg, release, and install-media in order, each prerequisite first

Run every command as your user. A step marked sudo calls sudo -n itself. A step not marked calls it too when a prerequisite that needs it is out of date: make pkg, make kernel-host, and make release build make musl-dom0 first. make alone does not build the musl root, the kernels, or the media.

A release with your own keys:

make RELEASE_KEY=/abs/keys RELEASE_SEC=/abs/keys/release.sec \
    INSTALLER_SEC=/abs/keys/installer.sec media

Each step is a make rule. After a failure, run the same command again; make continues from the step that failed.

The build is make

No script does build work. A file a step makes is a target, a file it reads a prerequisite, and a recipe is the few commands that make its target. A step that fails leaves no target behind ($@.tmp, then mv), so the next make starts at that step. The build is correct under -j, with no .NOTPARALLEL. A change rebuilds only what depends on it: touch one input and make -n lists only what follows from it. The tools run by hand from the tree and the proofs are make targets by the same rules: a session’s root (make rootfs), a VM’s disk (make volume) and a host kernel’s initramfs (make guestrd); the install proof is a target for each stage (make install-proof, mk/proof.mk), so a run that fails starts again at the stage that failed. The tests in regress/ stay programs and scripts, each run by its rule, as do the media’s own media-init and media-power: they are the product, not the build. The rules for a change are in CONTRIBUTING.md; the scripts still to move are in ROADMAP.md.

Variables

Variable Default What it sets
MIRROR https://repo-fastly.voidlinux.org/current the Void mirror the build roots and the proofs fetch from
MUSLROOT ~/musl-dev the musl build root; give each parallel build its own
RELEASE_OUT build/release where make release writes
MEDIA_OUT build/install-media.img where make install-media writes
SWM_KEYMAP_LAYOUT us the keymap built into the dom0 image

Mirrors differ a lot in speed. Pick a fast one before a long build.

Versions

release/VERSION holds the version. A commit tagged v<release/VERSION> with a clean tree builds that version. Any other build is <version>+g<hash>, with .dirty if the tree has changes. swmtool update refuses a release older than the installed one, unless --force.

To cut a release:

  1. Bump release/VERSION.
  2. Commit.
  3. Tag the commit v<version>.
  4. Build it with the release keys.

Manifest

The media build writes two files beside the image:

The same inputs give the same manifest. The build stops if a list of packages is not whole, if the commit cannot be read, or if a release key directory (one with no not-a-release) builds media from a dirty tree. The image depends on the build host’s packages, so a host update makes the image again. An official build starts from an empty build directory, so each object in it is made on the host that the manifest names.

To check media you fetched:

  1. Get installer.pub from a place you trust that is not the mirror. The key lines in the manifest name the keys; they do not make a key trusted. The nightly’s key is release/keys/nightly/installer.pub in the tree.

  2. In the directory of the media, run:

    signify -C -p installer.pub -x install-media.img.SHA256.sig

    This command checks the signature, the image and the manifest. If one of them changed, it fails.

  3. Read the version line of the manifest. An old media keeps a valid signature, so make sure that the version is the one you expect.

A signer

A release can be built on a machine that has no secret key. Set SCROTWMOS_SIGNER to a command that signs on another machine, and give the build only the public keys:

make RELEASE_KEY=/abs/keys \
    SCROTWMOS_SIGNER='ssh -i /abs/signer.key signer@release-sign' media

The build then runs the command for each signature, with the data on standard input and the result on standard output:

$SCROTWMOS_SIGNER signify kernel < message > signature
$SCROTWMOS_SIGNER signify installer -e < list > signature
$SCROTWMOS_SIGNER image r|b|i VERSION DATE < kernel > signed

The build checks each result as it checks a local signature:

A signer that signs another kernel, another version or another list, or with another key, is refused, and nothing is written. SCROTWMOS_SIGNER needs a key directory: a signing with the TEST keys is refused. With SCROTWMOS_SIGNER empty, the build signs locally.

release/signer.sh is the program the signer runs. On the signer, make it the forced command of the build’s ssh key, with restrict, so that the key cannot get a terminal or forward a port:

command="SIGNER_KEYS=/srv/keys SIGNER_SWMTOOL=/usr/local/libexec/signer/swmtool sh /usr/local/libexec/signer/signer.sh",restrict ssh-ed25519 AAAA... release-build

It takes only the requests above, from SSH_ORIGINAL_COMMAND, and at most SIGNER_MAX bytes (1 GiB). It logs each request on the signer (logger -t signer) with its size and sha256. It reads the secret keys from SIGNER_KEYS and signs images with SIGNER_SWMTOOL, a swmtool built once from a reviewed commit with the same public keys. It runs no code from the tree it signs for.

The signer signs what it is sent. It keeps the keys off the build machine, but a build machine that is not under your control can get anything signed, at any version and date. Build only tags you signed, on a builder that runs nothing else. The keys’ lifecycle (their disk, its passphrase, the backup, the rotation) is the signer’s setup, outside the tree.

CI

.github/workflows/ci.yml runs make, make test, and make check-fuzz on each pull request and each push to main. .github/workflows/nightly.yml runs make musl-root, make kernel, make pkg, make release, and make install-media each night that main changed, and publishes the result as the nightly prerelease. A pull request that changes what the nightly builds builds it too, and publishes nothing. On main, it signs the nightly with the keys in release/keys/nightly. These keys are marked not-a-release, so the nightly’s loaders say NIGHTLY on screen. A nightly is for testing, not for a real machine.

gitea and GitHub read the same .github/workflows. The tree has no .gitea directory, because gitea reads .gitea/workflows in place of .github/workflows when it exists.

mk/ci.mk holds the CI’s own steps: debounce, dist, publish, and check-workflows. make test runs check-workflows, which checks that media.yml and GitHub’s workflows call the same make targets.

The runner of ci.yml is a VM like GitHub’s ubuntu-latest: Ubuntu 24.04, its HWE kernel, and Docker. The runner has the label ubuntu-latest and container.privileged set. The VM gives each job two things that GitHub’s runner gives: