Files
lotherk 974603f8a6 pkgsrc: the forks of ext/ build from their tree, not from an archive
Each fork kept a recipe beside its source and a tarball in distfiles/ whose
distinfo had to be regenerated after every commit (tools/ext-dist.sh,
tools/mcde-dist.sh), and the work directory of a build could not see a later
commit at all (tools/ext-resync.sh merged an archive into it).  Three tools,
one artefact per fork in git, and the failure mode that cost the 2026-11-23
release: mcde 288d1383 built from the commit of the day before, because the
recipe's mtime said "not stale".

Now the recipe builds the source tree itself, which is how pkgsrc's own
net/fetch and pkgtools/pkg_install do it: DISTFILES= # empty, do-extract
fills WRKSRC.  What is gone with that:

  - the tarballs (distfiles/{mcde,splinter,junction,wikid,skilld,memoryd,
    tasksd}-*) and their .key
  - tools/ext-dist.sh, tools/mcde-dist.sh, tools/ext-resync.sh and its test
  - fork_archives in tools/makronix-distfiles.sh (nothing to fetch or stage)
  - the distinfo files of the eight recipes

What replaces it: tools/ext-extract.sh, called from do-extract.  It hashes
the tree, copies only the files that differ, keeps the time stamp of the rest
(so a commit rebuilds what it touched and not 27 minutes of MCDE) and
removes the copy when a file left the tree.  The build key of a fork carries
the source commit for the same reason: a commit does not change the recipe.

The recipes keep $Makronix$ as their header; afpfs-ng keeps its upstream
$NetBSD: ...$ line and its real distfile, and fork_src() leaves it alone.

Verified:
  - bmake package built all eight recipes from the tree with no distinfo:
    splinter, junction, wikid, skilld, memoryd, tasksd, mcde (16 MB), and
    mcde-motif's shared tree
  - tools/test-tools.sh: 38 ok, 0 bad (5 new cases for ext-extract.sh)
  - tools/makronix-distfiles.sh check: 0 missing, 0 wrong hash
  - tools/makronix-pins.sh check: PINS matches
2026-11-23 19:49:07 +00:00

166 lines
9.8 KiB
Markdown

# 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-sync.sh` -- the recipe of a fork in `ext/`, made visible inside pkgsrc
(a mirror of symlinks; the recipe builds the source tree itself, no archive).
- `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-<date>.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.
<!-- License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. -->