Files
makronix/tools/AGENTS.md
T
lotherk c8cc69aac5 tools: dtlogin-check.sh, the installed package through dtlogin
The dev tree has mcde-desktop.sh; the .deb path (/usr/mdt, /etc/mdt) had
no test that logs in.  This one starts dtlogin on :94 against the
installed package, logs in with pam_permit, and requires the front
panel's Applications menu in the window tree.

Three things it learned in the runs, each a real failure first:

- -ac on the Xvfb line: dtlogin starts the server as nobody and nothing
  can look at it otherwise (xwininfo, xdotool, import all refused).
- Roll dtlogin.log before the run: a previous run's "Greeter started"
  satisfied the wait loop and the test measured a display that never
  came up.
- Kill the display's dtlogin and its Xvfb BEFORE restoring $HOME/.dt:
  dtsession writes sessions/current and errorlog on its way out, and a
  copy put back while it still ran was written over again.

Also: dtsession restores the last session, so without an empty $HOME/.dt
the screenshot showed the user's own Firefox and xterm, not the package
(a 682k-pixel white block).  $HOME/.dt is backed up and restored, and
the session's copy is kept in build/dtlogin-check/home.dt.session.

Test: sh tools/dtlogin-check.sh -> rc=0, clients dtwm, dtlaunch,
dtterm, mcdesoundd; screenshot is the MCDE desktop (no Firefox);
diff of $HOME/.dt against the pre-run copy: IDENTISCH.
2026-11-22 18:32:01 +00:00

9.8 KiB

tools/ -- scripts around the build

What it is for

The scripts the root Makefile targets call, and the helpers for tests, media, the source sets and MCDE. Building is cross and native, never in a VM; a VM is only for testing installs and upgrades (root AGENTS.md).

What is in it

All scripts are POSIX sh; each one's header says usage and purpose, read it before running it.

Build and release (called by make):

  • build-stamp.sh -- content key of the sources; make iso runs it with -c (check only), make build|release without (removes the derived artefacts when the key changed, so after a source change make release is needed). It writes build/obj and refuses to run outside the build lock.
  • build-lock.sh 'command' -- one build at a time in the tree. The root Makefile's build, release, stamp, iso, usb, sourcesets, tools, kernel, userland, clean-sanity, cdtest, compress, test, install, isosrc, mcde-linux and mcde-host take it. A second build is refused with the holder's pid; a stale lock (dead pid, or a pid reused after reboot, detected by the stored start time) is taken over. The lock is re-entrant (BUILD_LOCK_HELD), so make cdtest holds it across release, iso and the VM test. --held is the guard for tools that write build/obj or releasedir: build-stamp.sh, cd2.sh, cd3.sh, cd-source.sh, images.sh, srctree-stage.sh, userland.sh, mcde-linux.sh and mcde-host.sh refuse to run outside the lock; start them through make or tools/build-lock.sh '...'. Tests (test.sh, mediacheck.sh, install-simple.sh, install-cgd.sh, mcde-tests.sh) call build-lock.sh --check: they refuse to start beside a build, and --check passes when the caller is inside the lock (make test/make cdtest). The reason is t0286: clean_METALOG moves METALOG.sanitised to METALOG while a concurrent build's copy-releasedir still needs it, and the error looks like a missing file in the CD staging.
  • pkgsrc-cross.mk.conf -- the pkgsrc cross configuration (root AGENTS.md).
  • makronix-set.sh -- the makronix set list and METALOG records from the installed /usr/pkg.
  • userland.sh (make userland) -- builds packages.list, cross or native as the host is; pkglist.sh is the one reader of that list (kinds: set, repo, fetch, games; @ARCH).
  • ext-dist.sh, mcde-dist.sh, ext-sync.sh -- the distfile and distinfo of a fork in ext/, and its recipe copied into pkgsrc.
  • ext-resync.sh -- a new archive of a fork changes only the files that differ in the work directory (.pristine is the archive pkgsrc extracted); userland.sh calls it, and falls back to bmake clean when it says no (a file pkgsrc changed, no work directory). .pristine is kept after a failed build too, so an error does not mean a build from nothing; a changed recipe drops pkgsrc's cookies from depends on (fork_reconfigure) and keeps sources and objects. Never delete a fork's work directory by hand: that is hours of MCDE.
  • check-buildtools.sh -- after a cross build, checks that the programs a fork builds and runs while building (tradcpp, makestrs, wml ...) are host binaries; userland.sh runs it before the set is written (t0197).
  • mcde-plist.sh LOG -- puts the files that the PLIST check of wm/mcde reports into ext/src/mcde/pkgsrc/PLIST.
  • keep-images.sh [-n N] NAME -- copies the install images to build/keep-NAME/ before the next make release removes the release directory; keeps NAME and the newest N (by time, default 1: one 10 GB medium is enough) build/keep-*, removes the older ones.
  • pkg-binaries.sh -- fetch the NetBSD project's binary packages.
  • images.sh -- unpack|pack|sums of the install images (make usb, make compress); images stay raw unless packing is asked for.
  • cd2.sh, cd3.sh, cd-com0.sh -- the second and further install CDs (cd3: packages in dependency order, desktop.list/games.list per medium for sysinst) (make iso), and a CD copy whose loader talks on com0.
  • makronix-distfiles.sh, makronix-pins.sh, srctree-stage.sh -- the source set (make sourcesets, docs/OFFLINE-BUILD.md); cd-source.sh -- the source DVD (make isosrc).

Tests (they run VMs; docs/PLATFORMS.md):

  • test-tools.sh -- tests for the build tools (pkglist, makronix-set, keep-images, mxupgrade, ext-resync), no network, no build; run first by make test.
  • test-ext-resync.sh [SCRIPT] -- the cases of ext-resync.sh in a scratch tree with a stand-in bmake (changed, unchanged, stale .pristine, pkgsrc-changed, removed, configure.ac); test-tools.sh runs it.
  • mcde-tests.sh -- the unit tests of MCDE (libMcdeSys, libDtSvc, libDtWidget, the plain-C parts of dtbar/dtlaunch/dtsystemsettings/dtterm), from a native build of this host; run by make test before the release tests.
  • vmsh.sh -- a QEMU machine on a serial console driven from sh; state in build/vmsession/. The VM driver to use.
  • vm-boot-iso.sh, vm-screendump.sh -- boot an image once, log the serial console or save the screen. A UEFI boot is judged on the SCREEN (-U stick), never on the serial line: after efiboot the kernel's console is the framebuffer, so a serial log ends at efiboot's :-( although the boot goes on (the stick was thought not to boot under OVMF until 2026-11-17, t0086).
  • write-stick.sh -- an image to a USB stick, guarded; afterwards the backup GPT is moved to the end of the device (fdisk) and the stale one in the image area is zeroed.
  • install-simple.sh, install-cgd.sh -- end-to-end installation tests.
  • test-desktop-login.sh -- boots an installed disk and logs in at dtlogin: the user name and the password are typed through the QEMU monitor (the greeter is on the framebuffer, the serial console cannot reach it), then dtsession, dtwm, dtbar, mcdesoundd, ttsession and rpcbind are checked from a root shell on the serial console; the screen is saved to build/logs/desktop-login-.png. -k keeps the machine running.
  • test.sh (make test), mediacheck.sh -- the tests of a release.
  • devvm.sh, host-nfs-setup.sh -- the kept VM of docs/BUILD-VM.md.

MCDE and the logo:

  • mcde-host.sh (make mcde-host), mcde-linux.sh (make mcde-linux), mcde-shot.sh -- MCDE on this host, and screenshots.
  • mcde-keytest.sh -- tries the shortcuts of docs/reference/shortcuts.txt on a private X display (t0058; dtwm keys need a working dtwm, t0216).
  • mcde-desktop.sh -- starts MCDE through dtlogin on a private Xvfb display, logs in as $USER, and runs a control script (wait/shot/type/key/click/move/run/ focus/close/exit) to take targeted screenshots for the website; backs up and restores $HOME/.dt and /etc/pam.d/dtlogin. Hazard: for the length of the run the HOST's dtlogin service is pam_permit (sudo); the trap that puts it back is set before the switch. mcde-desktop-webshots.cmds is the script for the website's pictures (raw shots in www/screenshots/, not tracked; the kept ones are copied to www/img/).
  • dtlogin-check.sh -- the INSTALLED package (make debian-install, /usr/mdt with /etc/mdt) through dtlogin: greeter, login, session, front panel. mcde-desktop.sh does that for the dev tree; this is the path of a package user, which the tree never exercises. Runs on :94, exit 0 means the front panel's Applications menu was in the window tree. Hazard, like mcde-desktop.sh: /etc/pam.d/dtlogin is pam_permit for the length of the run (sudo). Two things it must do in the right order, both learned the hard way: kill the display's dtlogin and its Xvfb BEFORE putting $HOME/.dt back (dtsession writes sessions/current and errorlog while it dies, and a copy restored too early is written over), and roll dtlogin.log before the run (a previous run's Greeter started satisfies the wait loop and the test then measures a display that never came up). -ac on the Xvfb line is not optional: dtlogin starts the server as nobody and nothing can look at it otherwise.
  • mcde-xkey.sh -- presses keys by their plain keycodes (XTest), mcde-xkey.sh Super_L h; xdotool key F8 on Xvfb sends Alt+F8 (header of the script).
  • logo-ascii.sh, theme-logo.sh -- the logo as ASCII, and in a palette's colours (docs/logo/AGENTS.md).

claude-build-gate.sh -- build gate that enforces the forbidden commands (root AGENTS.md). Its match is textual: a command that names releasedir and performs hand work on it (rm, mv, cp, touch, chmod, mkdir, sed -i, tee, or a shell redirection whose target path is under releasedir) is refused. A read-only command that only redirects stderr/stdout (such as 2>&1) is allowed. claude-build-gate-test.sh -- POSIX-sh test cases for the hook.

Legacy, still here for the test VM only: devvm.sh and vm-boot.cfg (docs/BUILD-VM.md). Building in a VM is gone: vmbuild/, packages.vm.list, vm-pkgbuild.sh and vm-pkgcollect.sh were removed on 2026-11-13; the unused Python drivers vmctl.py and vmmon.py were removed later (no longer called by the tree). Do not extend the drivers and do not describe them as the way to build.

What may be changed

Anything here, freely, as long as it stays POSIX sh (check with dash -n) and its header and this list stay true. A script that gains or loses a job changes here in the same commit.

What must not be touched

  • No script builds by a path the root Makefile does not name, and none writes under the release directory by hand.
  • No Python, no unattended loops or timers (root AGENTS.md, "Forbidden").
  • Writing an install stick is not in the tree: check lsblk first (a name that is not a block device makes dd write a plain file into /dev) and read the stick back twice before it goes to a machine.