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
- Void Linux, x86_64, glibc.
- Linux 6.16 or newer.
make testneedsSO_PASSRIGHTS. /dev/kvmfor the proofs that boot the stick in qemu. Each proof VM takes 4 CPUs and 6 GiB of RAM. Its disk is a sparse file in/var/tmpofDISK_GBGiB (default 24).- Room for
build/and the musl root (~/musl-dev). To measure it after a build:du -sh build ~/musl-dev. sudowith no password prompt, for the steps that need root.- Network access to a Void mirror and to the pinned upstream sources.
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.
- The kernel key signs the kernels the build makes and the VM
kernels’ index. The build copies its public half to
kernel/keys/kernel.pub, the file the launcher pins, and refuses a secret key that is not its half. - The release key signs the dom0 image. The boot stub and
swmtoolpin it. - The installer key signs the installer on the stick, and the
signature over the media and its manifest (“Manifest”, below).
swminstallpins it. A new installer key needs a new stick, not a reinstall.
RELEASE_KEY names all three:
RELEASE_KEY=testuses the public RFC 8032 test keys and the TEST kernel key,regress/signify/test-kernel.pub, whose secret is in the tree beside it. What it builds says TEST on screen. Use it for development only.RELEASE_KEY=/abs/pathnames a directory withrelease.pub,installer.pubandkernel.pub.RELEASE_SECandINSTALLER_SECname the first two secret halves; the kernel key’s iskernel.secinSCROTWMOS_KEYDIR(default~/.scrotwmos/signify). The release and installer keys must differ, andkernel.pubis never the TEST kernel key. Make each pair withsignify -G -p release.pub -s release.sec; the kernel key’s pair is made the same way,kernel.pubinto the key directory andkernel.secintoSCROTWMOS_KEYDIR. The tree holds no release’s public halves: the key directory is the release builder’s.release/keys/nightlyholds the nightly’s.- With no
RELEASE_KEYnothing is signed: the stub does not build,swmtoollays down no appliance and no kernels, andmake kernel,kernel-host,kernel-installer,nctx-mesa,gpu-fw,pkg,release,install-mediaandmediastop.make RELEASE_KEY=test kernelbuilds the kernels with the TEST kernel key.
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:
- Bump
release/VERSION. - Commit.
- Tag the commit
v<version>. - Build it with the release keys.
Manifest
The media build writes two files beside the image:
install-media.img.manifestlists each input of the build that the commit does not hold:- the version, the commit, and
tree cleanortree dirty; - the Void mirror;
- the sha256 of the release, installer and kernel public keys;
- the upstream pins:
kernel/upstream,kernel/nvidia/upstreamandbin/swm-wl/upstream; - each package of the build host, the musl root, the glibc root and
the live system, with its pkgver and the sha256 of its
.xbps; - the sha256 of the release’s files.
- the version, the commit, and
install-media.img.SHA256.sigis a signify signature by the installer key over the sha256 of the image and of the manifest. The installer key is the stick’s own key:swminstallpins it. TEST media signs with the TEST installer key,regress/signify/test-installer.sec.
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:
Get
installer.pubfrom 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 isrelease/keys/nightly/installer.pubin the tree.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.
Read the
versionline 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
signify kernelsigns a kernel or the kernels’ index.signify installer -esigns the media’s list, and nothing else. The installer key also signs installer kernels, whose signature is over a 64-byte digest, so the signer refuses a message of 64 bytes or fewer, and one without-e.imagesigns withswmtool release sign:ra dom0 kernel andbthe stub with the release key,ithe installer kernel with the installer key.
The build checks each result as it checks a local signature:
- a signify signature under its public key;
- the media’s signature, and that the list in it is the list it sent;
- an image with
swmtool release verify, which holds it to the kernel that was sent, the version and the date.
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.
- gitea runs
ci.ymlon each pull request and each push tomain. You see the result of GitHub’s CI before you push to GitHub. - gitea has
nightly.ymlturned off. media.ymlis gitea’s own. It runs the nightly’s make targets on a push tomainorgpu-dev, then publishes the build to a mirror withmake -f mk/ci.mk publish. It does not run on pull requests. GitHub has noMIRROR_DEST, so it skips the job. No runner runs it yet.
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:
- a
nodefor the JavaScript actions, at/usr/local/bin/node; - trust of gitea’s certificate, through
GIT_SSL_CAINFOandNODE_EXTRA_CA_CERTS.