diff --git a/AGENTS.md b/AGENTS.md index 1a85c71900..3b6bdbf445 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,7 +1,16 @@ # AGENTS.md -- how work happens in this tree Makronix is a NetBSD, built and shaped on purpose. Read this before changing -anything; it is short because the rules are few and they are binding. +anything; the rules are few and they are binding. + +Read in this order, every time: `GOAL.md` (what Makronix is and when a part is +done), this file, `docs/BUILD-CONTRACT.md` (the one way to build). Every +directory below the root carries its own `AGENTS.md`: what lives there, what +may be changed, what may not. Read the one in the directory you work in +before you touch it. + +Where this file and a measurement disagree, the measurement wins and this file +is wrong: fix the file, name the log line that settled it. ## The rule before all others @@ -26,12 +35,25 @@ quiet change in the tree. ## What belongs where -- `src/` and `xsrc/` are the NetBSD import and stay PRISTINE. `git -C src - status` clean is the proof. Everything we change lives as a patch under - `patches/src/` or `patches/xsrc/`, applied in filename order by - `tools/apply-patches.sh` before the build. A patch that no longer applies is - a finding, never something to force. Upgrading the import is then a rebase - of our patch set, not a merge of local edits. +- `src/` and `xsrc/` are the NetBSD import at the pinned commit. Every + change to them is recorded in this repository, in one of two forms, and + never made by hand in the import: + - a **patch** under `patches/src/` or `patches/xsrc/`, applied in filename + order, for a small edit to a file NetBSD owns; + - an **overlay unit** under `overlay/`, a full tracked copy of a directory + we really rework (today `usr.sbin/sysinst`), put into `src/` by + `tools/overlay.sh sync` before every build. Work in `overlay/`, not in + `src/` (`overlay/AGENTS.md`). + Not both for the same directory. Both are applied in place, because + `build.sh` builds from `src/`; so `git -C src status` shows the files our + patches and overlay units touch, plus the untracked `AGENTS.md` files + (below) -- anything beyond that is an edit nobody recorded. A patch that no + longer applies is a finding, never something to force. Upgrading the + import is a rebase of the patches and of the overlay (`overlay/AGENTS.md`), + not a merge of local edits. `tools/apply-patches.sh` is not called by the + `Makefile` and cannot yet tell "already applied" from "conflicts" for + patches that stack on one file (0001 and 0002): known defect, see + `tools/AGENTS.md`. - `ext/` holds third-party sources that Makronix ships: `ext/src//` is the unpacked upstream tree, `ext/src//pkgsrc/` its recipe, and an `IMPORT` record names pkgsrc path, version, archive, hash and licence. An update @@ -41,15 +63,45 @@ quiet change in the tree. ## Building -Everything builds cross, from any host, with `build.sh`: +Everything builds cross, from any host, with `build.sh`, through the targets +of the root `Makefile` and nothing else: - make the distribution - make release ARCH=... through to a finished release + make build build.sh distribution: the sets, no medium + make release ARCH=... build.sh release: the distribution plus the + `distrib` stage -- INSTALL kernel (instkernel), + ramdisks, kmods, boot-com.iso + (src/distrib/amd64/Makefile, `TARGETS+= release`) + make iso build.sh iso-image: packages what `release` built + into RELEASEDIR/images/*.iso (CD and DVD) + make sourcesets the source sets in RELEASEDIR/source/sets: NetBSD's + (with their .git) and msrc (pkgsrc, patches, + tools, the Makronix distfiles, PINS; docs/OFFLINE-BUILD.md) + make isosrc the DVD with those source sets on it make install over a running Makronix, idempotent and incremental; refuses on a host that is not NetBSD -Long builds belong in `systemd-run --user` (or an equivalent that outlives the -tool call); a plain background job is killed after about ten minutes. +The order for an install medium is `make release ARCH=amd64`, then `make iso`. +`make build` then `make iso` does not work: `build-stamp.sh` removes the +derived artefacts, `distribution` does not recreate `instkernel`, and +`iso-image` stops with `netbsd-GENERIC.gz: stat: No such file or directory` +(`build/logs/make-iso-2026-11-06.log:49`). `iso-image` only packages. Since +2026-11-06 `make iso` checks first (`tools/build-stamp.sh -c`) and stops with +a message, without removing anything, if the sources, patches or the overlay +changed since the last `make release`. + +A boot message `WARNING: 1 module failed to load` for `cd9660` is not a +defect: the INSTALL kernel has cd9660 built in, the loader's attempt to push +the kmod finds it already there (`Module 'cd9660' pushed by boot loader +already exists`), and the CD is mounted as root regardless +(`build/logs/baseline-bios-boot-2026-11-06.log:34,109`). Comparing the +timestamps of `netbsd` and `cd9660.kmod` in the ISO proves nothing: `make -u` +does not rebuild a kmod whose sources did not change. + +Long builds: start the one named target in the background with its output in +`build/logs/-.log` and end the turn; the next turn reads the +log. Read the exit status from the log (`make exit=N` as the last +line), not from the background wrapper, which reports the status of the +`echo` that follows. No transient units, no per-attempt wrappers. The gate on a build is `checkflist`, and it is run the way NetBSD runs it: @@ -142,7 +194,7 @@ Removing a package means removing its entries from the list; entries that existed keep the NetBSD convention and are marked `obsolete`. sysinst installs it. `SET_MAKRONIX` is an enum value in -`src/usr.sbin/sysinst/defs.h`, a row in `dist_list` in `util.c`, part of +`overlay/usr.sbin/sysinst/defs.h`, a row in `dist_list` in `util.c`, part of `SET_SYSTEM` -- so a full installation and an installation without X11 both take it, a minimal one (`SET_CORE`) does not -- and a message in every `msg.mi.*`; `msg_xlat.sh` fails the build on a missing translation. Those @@ -160,6 +212,8 @@ stays as upstream wrote it, and the serial console was set at the loader prompt (`consdev com0,115200`) -- a boot.cfg that carries the line ships a medium that is deaf on a machine without a serial port. +Since 2026-11-07 the CD no longer carries the `makronix` set: it is on a second CD (`tools/cd2.sh`); the numbers in the next paragraph are from the single CD before that and are kept as history. + The second medium shape is the CD and the DVD. `build.sh ... iso-image` runs `distrib/amd64/cdroms` and writes two artifacts into `releasedir/images`: `NetBSD-11.99.9-amd64.iso` (698 MiB, the install CD) and @@ -259,3 +313,75 @@ an install from it reaches a login prompt and shuts down cleanly -- with the log kept in the tree. No claim without a measurement: file and line, exit code, log excerpt. + +## Forbidden + +These are enforced by the PreToolUse hook `tools/claude-build-gate.sh` +(configured in `.claude/settings.json`) where a hook can see them, and binding +everywhere else: + +- building through `systemd-run` or any transient unit. One attempt is one + named call of an entry point of the root `Makefile`. +- `make -C build`, `cd build && make`, and hand-chained `build.sh` operations + with self-chosen arguments. +- writing, moving or deleting anything under `build/obj/releasedir/**` by + hand. A wrong artefact means a wrong build. (The hook is textual: it + refuses a command that names `releasedir` and also contains `rm `, `mv `, + `cp `, `touch `, `chmod `, `sed -i` or `>` -- a redirection such as `2>&1` + is enough, so a read-only `ls` can be refused. Do such reads without + redirections, or in a script under `tools/`.) +- `git checkout`, `git clean`, `git reset` anywhere that touches `src/`, + `xsrc/` or `pkgsrc/`. The import's state is the build; undo a patch with + `patch -R` after a `--dry-run`, and record the change in `patches/`. +- deleting `src/distrib/sets/lists/**` to make `checkflist` pass. +- unattended loops: cron jobs, timers, or "tick" scripts that start builds or + tests or hand work to an agent. An earlier setup did this every fifteen + minutes, tested media the build had just removed and started builds in + parallel; it was removed on 2026-11-06. + +## How to work + +- Plan before acting on anything non-trivial: say which command you will run + and what you expect, then run it, then compare. +- Every claim carries `file:line` or a log line. A sentence without one is a + guess and is treated as one. +- Do not trust a status document, a commit message or an old log over a + measurement you can repeat. Repeat it. +- `src/`, `xsrc/`, `pkgsrc/` are untracked on purpose (each is its own + repository). Changes to them go through `patches//NNNN-*.patch`. +- Tools in `tools/` are POSIX `sh`: no Python, no bashisms. Check with + `dash -n` and, where installed, `checkbashisms`. + +## AGENTS.md in every directory + +Each directory of this repository has an `AGENTS.md` that says, in this order: +what the directory is for, what is in it, what may be changed and how, what +must not be touched. When a directory gains a purpose, a rule or a hazard, +its `AGENTS.md` changes in the same commit. + +The three imports (`src/`, `xsrc/`, `pkgsrc/`) are upstream trees of about +49,000 directories. They carry an `AGENTS.md` at the root of each, and `src/` +one in each of its 21 top-level directories (decided 2026-11-06). These files +sit directly in the imports, untracked and outside `patches/`: they are not +upstream, and a new import does not contain them, so after an upgrade they must +be written again. Do not add `AGENTS.md` below that level: what a directory is +for is answered by the upstream documentation (`README`, the manual pages, +`src/BUILDING`, hier(7)), and `pkgsrc` alone has tens of thousands of packages. + +## Status of the measurements in this file + +The numbers and the build/boot results in "The makronix set", "Where a Linux +build host stops" and "The build host" were taken by earlier sessions, before +2026-11-06, and have not been repeated since. Re-measured on 2026-11-06 and +confirmed: `make release ARCH=amd64` and `make iso` exit 0 +(`build/logs/make-release-2026-11-06.log`, `make-iso2-2026-11-06.log`), and the +CD boots to sysinst's terminal prompt +(`build/logs/baseline-bios-boot-2026-11-06.log`). Also measured that day: +an installation from that CD to `login:` in the simple mode, BIOS/amd64, with +`/etc/mtree/set.makronix` (1814864 bytes, the same size as the earlier +measurement) and `/usr/pkg/dt/bin/dtwm` on the installed disk +(`tools/install-simple.sh`; logs `build/logs/install-simple-bios-*-2026-11-06.log`). +The installer printed 18 set archives with lower-case names, `makronix.tar.xz` +among them; the kernel sets were not counted, so the "20" of the earlier +measurement is not re-derived. Not yet re-measured: `checkflist`, the +installation in the advanced mode, UEFI, and the sizes. diff --git a/GOAL.md b/GOAL.md new file mode 100644 index 0000000000..b849557f65 --- /dev/null +++ b/GOAL.md @@ -0,0 +1,129 @@ +# GOAL.md -- was Makronix ist und wann es fertig ist + +Definiert von Konrad, aufgeschrieben am 2026-11-06. Diese Datei beschreibt das +Ziel, nicht den Weg. Der Weg steht in `AGENTS.md` und `docs/BUILD-CONTRACT.md`. +Widerspricht ein anderes Dokument dieser Datei, ist das Dokument falsch oder +veraltet, und der Widerspruch ist ein Befund. + +## Was Makronix ist + +Ein eigenständiges Betriebssystem auf Basis von NetBSD. Eigene Patches und +Änderungen, CDE als Standard-Desktop, und stark opinionated: alles gehört +zusammen, wie bei macOS. Der Benutzer entscheidet wenig und bekommt dafür ein +vollständiges System. + +NetBSD wurde gewählt, weil es auf sehr vielen Plattformen läuft. Das gilt auch +für Makronix. + +## Das Leitprinzip: der NetBSD-Weg + +Alles bleibt im NetBSD-Stil, so dass ein NetBSD-Entwickler sagen würde: "ah +cool, ist ja eigentlich immer noch NetBSD". Das gilt auch dann, wenn wir +später ganz andere Dinge in die Quellen packen. + +- Erst die Doku im Baum lesen, dann nach dem vorhandenen Muster suchen + (`git grep`), dann den vorhandenen Baustein benutzen, erst dann Code + schreiben. Der Kommentar nennt das NetBSD-Muster, dem er folgt. +- Plattformneutral denken. amd64 ist das erste Ziel, nicht das einzige. +- Änderungen an `src/` und `xsrc/` gibt es nur als Patch unter `patches/`. +- Werkzeuge unter `tools/` sind POSIX-`sh`. Kein Python, keine Bashismen. +- Ein Patch, der eine NetBSD-Konvention bricht, ist ein Befund für den + Bericht, keine stille Änderung. + +## Das Ziel: ein angepasster sysinst + +Makronix bekommt einen eigenen Fork von sysinst (`src/usr.sbin/sysinst`), +angepasst an Makronix. Er besteht aus drei Teilen: + +1. **Aussehen.** Die Farben sind die CDE-Standardpalette. +2. **Einfache Installation.** Der Benutzer wählt die Zielplatte, den Rest + erledigt das System: Partitionieren und Installieren aller Sets. Die + manuelle Partitionierung bleibt als optionaler Weg erhalten. +3. **Verschlüsselung.** Der Benutzer kann die Zielplatte verschlüsseln (cgd). + Das ist gemeint, wenn in diesem Repo "FDE" steht. Es ist eine Funktion des + Installers, kein Handbuch-Skript, das eine Prozedur eintippt. + +## Die Pakete: das makronix-Set + +Das Userland von Makronix kommt aus pkgsrc, gebaut mit der Toolchain dieses +Baums, und liegt im Set `makronix` (`/usr/pkg`). Das Set liegt auf dem +Installationsmedium. sysinst installiert es standardmäßig mit auf die +Zielplatte. Der Stand heute ist in `AGENTS.md` beschrieben. + +## Der Selbstbau: das Source-Set + +Makronix kann sich 100 % offline selbst bauen. Dafür trägt das Medium die +Quellen mit: + +- NetBSD-`src` und `xsrc` über die vorhandenen Source-Sets von NetBSD + (`makesrctars`: `src`, `gnusrc`, `syssrc`, `sharesrc`, `xsrc`). +- Ein eigenes Set (Arbeitsname `msrc`) mit allem, was NetBSD nicht + abdeckt: `pkgsrc`, `patches`, `tools`, `Makefile`, `docs`, die Distfiles und + eine Datei mit den Pins der Importe. +- Die Distfiles sind nur die, die zu Makronix gehören (die `makronix`- + Paketliste), nicht der ganze pkgsrc-Bestand. +- Das Source-Set ist in sysinst wie alles andere standardmäßig ausgewählt. + +## Das Medium + +Drei CDs (`make iso`), damit auch Rechner ohne DVD-Laufwerk Makronix +vollständig installieren können: CD 1 trägt das System, CD 2 das `makronix`-Set +(`tools/cd2.sh`), CD 3 die Binärpakete (Firefox, Thunderbird, QEMU; `tools/cd3.sh`, +`tools/pkg-binaries.sh`). Der Installer von CD 1 läuft aus dem RAM; fehlt ein Set auf +der CD im Laufwerk, fragt sysinst nach der nächsten CD (Menü "Next CD"), +hängt sie ein und macht weiter. Die DVD (`make iso`, mit Quell-Sets `make +isosrc`) trägt alle Sets und braucht keinen Wechsel. Gemessen am 2026-11-07: +`build/logs/install-simple-cd13-2026-11-07.log`, `install-cgd-cd13-2026-11-07.log` +(BIOS), `install-cgd-uefi-cd2-2026-11-07.log` (UEFI). + +## Was nicht zum Ziel gehört + +- Ein Installer, der sich nicht mehr wie sysinst anfühlt oder aufbaut. +- Eine zweite Installationsmethode neben sysinst. +- Umwege über selbstgebaute Ramdisk-Bootpfade, wenn sysinst und der + NetBSD-Standard das Problem lösen. Die Patches `0005` und `0006` + (cgdroot-Ramdisk) wurden am 2026-11-06 deshalb aus dem Baum genommen + (`patches/unused/`). + +## Wann ein Teil fertig ist + +Ein Teil ist fertig, wenn ein Lauf von Null den Beleg zeigt und das Log im Baum +liegt. Die Regeln für Befehl, Beleg und Quelle stehen in +`docs/BUILD-CONTRACT.md`. + +| Teil | Messbar fertig | +|---|---| +| Basis | `make release ARCH=amd64` und `make iso` laufen mit Exit 0, die Installation bootet bis `login:`. | +| Aussehen | Der Installer zeigt die CDE-Palette, belegt durch einen Screenshot oder ein Konsolen-Log aus dem Lauf. | +| Einfache Installation | Von einer leeren Platte: Platte wählen, nichts sonst, das System bootet bis `login:`. Der manuelle Weg funktioniert weiterhin. | +| Verschlüsselung | Von einer leeren Platte mit der Option "verschlüsseln": das System fragt beim Boot nach der Passphrase und bootet bis `login:`. Die Platte enthält keinen Klartext-Root. | +| Pakete | `checkflist` meldet nichts Fehlendes und nichts Überzähliges. Das `makronix`-Set ist auf dem installierten System vollständig. | +| Einfacher Abschluss | Root-Passwort, Benutzer (wheel, operator, staff, users, dialer, games), Hostname, DHCP, Zeitzone in sysinst; `dtlogin` statt `xdm`, `ntpd` aktiv. Gemessen: `install-simple-cd13-2026-11-07.log` (Login mit Passwort, Gruppen, `dtlogin` läuft; `dhcpcd` im DVD-Lauf `install-src-cd13-2026-11-07.log`). | +| Source-Set | In der VM ohne Netzwerk installieren, darin `make release` ausführen, bis Exit 0. | + +## Entschieden und offen + +Entschieden (Konrad, 2026-11-06): Medien, Standardauswahl des Source-Sets und +Umfang der Distfiles wie oben. `AGENTS.md` in den Eigenverzeichnissen des +Repos, je eine im Root von `src`, `xsrc` und `pkgsrc` und je eine in den 21 +obersten Verzeichnissen von `src`, direkt im Baum und nicht als Patch. + +Offen: + +- Wie genau startet ein verschlüsselter Root unter EFI mit dem + NetBSD-Standard? Das wird im Quelltext von sysinst und im Bootloader + nachgelesen, bevor Code entsteht. +- Endgültiger Name des Source-Sets (`msrc` oder anders). +- Die `AGENTS.md`-Dateien in den Importen gehen bei einem neuen Import + verloren (sie liegen untracked direkt im Baum, nicht in `patches/`). Wer sie + danach neu anlegt, und woher der Text kommt, ist nicht festgelegt. + +## Entschieden: X11 und Wayland (Konrad, 2026-11-07) + +- Der Desktop (NetBSD) behält NetBSDs `xsrc`; `X11_TYPE=native`. Grund: die + Binärpakete von pkgsrc (Firefox, Thunderbird, QEMU) hängen am X der Basis, + und `xsrc` ist, was NetBSD ausliefert. +- Die Mobile Edition (Linux) bekommt kein X, sondern Wayland aus pkgsrc. Auf + dem Handy läuft nichts von `xsrc`: es ist NetBSDs X-Build und läuft nur auf + einem NetBSD-Kernel. +- Offen: welcher Compositor es wird, und ob XWayland für X11-Programme mitkommt. diff --git a/docs/AGENTS.md b/docs/AGENTS.md new file mode 100644 index 0000000000..6fa5af9c9d --- /dev/null +++ b/docs/AGENTS.md @@ -0,0 +1,28 @@ +# docs/ -- binding rules and saved reading + +## What is in it + +- `BUILD-CONTRACT.md` -- binding (German). The one way to build, the three + sections every task card needs (measurable done, evidence, sources), the + reviewer's duty to rerun, "docs before code", no status prose. +- `reference/` -- what upstream documentation says, saved with source and + date (see its `AGENTS.md`). + +## Rules + +- `BUILD-CONTRACT.md` is a contract, not a log. Change it only when the user + asks. Known stale parts, to be rewritten with the user: + - section 6 defines "done" by the encrypted-root chain through + `boot-com.iso`; the goal is now in `GOAL.md` (a sysinst that encrypts); + - sections 1 and 6 name `make release` followed by the ISO; the measured + order for a medium is `make release ARCH=amd64`, `make iso` + (root `AGENTS.md`, "Building"). +- Status, handoffs and "state of the world" documents do not live here. They + go stale within a day and then mislead; one such file (a handoff dated + 2026-11-05) held three wrong claims and was deleted on 2026-11-06. What is + durable goes into the `AGENTS.md` of the directory it concerns, with a log + line as evidence. + +- `BUILD-VM.md` -- the kept build VM (made from the DVD with sources, `tools/devvm.sh`), how to stop it, what was measured about it. +- `OFFLINE-BUILD.md` -- the source sets (`make sourcesets`, `make isosrc`), what + `msrc` carries, where it lands, which distfiles, what is proven. diff --git a/docs/BUILD-VM.md b/docs/BUILD-VM.md new file mode 100644 index 0000000000..87a0e4f0c0 --- /dev/null +++ b/docs/BUILD-VM.md @@ -0,0 +1,147 @@ +# The build VM + +A kept installation of Makronix, with the source sets on it, in which Makronix +is built: the playground, and the place for the offline proof +(`docs/OFFLINE-BUILD.md`). + +## Made + +From the DVD with the source sets (`make isosrc`), in the simple mode, by + + MX_VMOPTS="-s 64G -m 10G -c 8" MX_HOST=makronix-dev \ + tools/install-simple.sh -S -d build/vm/makronix-dev.qcow2 + +Log `build/logs/install-devvm-2026-11-07.log`: all checks PASS (users, groups, +`dtlogin` running, `/usr/src`, `/usr/xsrc`, `/usr/msrc` with 71 distfiles). +Disk: 64 GB qcow2, sparse; 8.2 GB used after the install, 42 GB free on `/`. +8 CPUs, 10 GB RAM. `sshd=YES` and the key `build/vm/id_vm.pub` for `tester` +were added by hand over the serial console afterwards (the simple mode does +not turn sshd on). + +## Used + + tools/devvm.sh start boot it, wait for sshd (127.0.0.1:2222) + tools/devvm.sh ssh [cmd] as tester (wheel, operator, ...) + tools/devvm.sh scp ... + tools/devvm.sh stop shutdown(8), wait for qemu to exit + +**Always `stop`, never `vmsh.sh stop` or killing qemu.** The install test ends +with `vmsh.sh stop`, which kills qemu; the disk it leaves is dirty. The first +boot of this VM needed `fsck_ffs` by hand (duplicate blocks, a few inodes +cleared); `mtree` against `/etc/mtree/set.*` then found nothing wrong but the +files the installation itself changes (`/etc/master.passwd`, `/etc/motd`) and +`rescue/[`, whose digest in `set.rescue` does not match the binary the build +ships (the same on the host: a stale digest in the set, not damage). +After that, a `stop` and `start` cycle booted without any fsck correction. + +The passwords of root and `tester` are the test password of +`tools/install-simple.sh`; change them before the VM is used for anything else. + +## Measured about it (2026-11-07) + +- `cc` is GCC 14.4.0 (`nb4 20260926`), `make` works, `/usr/src/build.sh` is there. +- `git` is not in the guest: the `.git` directories of `/usr/src` and the + others are on disk but cannot be used there. pkgsrc has `devel/git`; whether + it builds offline is part of the offline proof. +- `sysctl hw.physmem` prints -1 at 10 GB (32-bit sysctl); `hw.physmem64` is the + one to read. + +## Not yet + +- A start without a network (the offline proof): `vmsh.sh` has no switch for + `-nic none` yet. +- The first build in the VM (`build.sh release` from `/usr/src`). + +## Binary first + +Where the NetBSD project publishes a binary package for the platform and +Makronix does not patch the package, the binary is taken, not built +(decided 2026-11-07). The work goes where nothing is published or where we +change something: `cde` (not published, built in the VM), the packages of the +`makronix` set that the cross build produces. + +- `tools/pkg-binaries.sh [-a amd64|aarch64] list|fetch` -- resolves the + packages named in `packages.binary.list` (all platforms) and + `packages.binary.ARCH.list` over the project's `pkg_summary.gz`, with their + run-time dependencies, and fetches them to `build/packages/ARCH/All`, a + directory `pkg_add` can install from (`PKG_PATH`). +- Source of the binaries: `cdn.netbsd.org/pub/pkgsrc/packages/NetBSD//11.0_2026Q3/All`, + the quarterly branch built for NetBSD 11.0. Makronix is NetBSD 11.99.9; the + binaries of the release branch are what is published for it. Whether they + run on it is measured when they are installed, not before. +- Measured 2026-11-07 (`tools/pkg-binaries.sh list`): amd64: firefox + 154.0.1nb1, thunderbird 154.0nb1, qemu 11.1.1nb1 with 112 packages in all, + 501 MB of archives (`qemu` alone is 117 MB, 871 MB installed); aarch64: + qemu and firefox, 109 packages, 630 MB; **thunderbird has no aarch64 binary** + in that branch (reported, skipped). +- The lists are tracked: `packages.list` (built, in the `makronix` set, all + platforms), `packages.amd64.list` and `packages.aarch64.list` (built, one + platform), `packages.binary.list`, `packages.binary.amd64.list`, + `packages.binary.aarch64.list` (binary, shipped beside the sets). +- Not done yet: the binary directory is not put on a medium; the sizes say + the DVD, not CD 2. The binaries are not covered by the offline rebuild (no + sources in `msrc`): Makronix rebuilds itself, not Firefox. The version + of the branch (2026Q3) is not the version of the pinned pkgsrc tree + (`git-base` is 2.55.0 there and 2.56.0 in the VM's build); mixing the two in + one `/usr/pkg` is possible only where their dependency versions agree. + +## Two VM sessions + +`tools/vmsh.sh` keeps one machine in one session directory. The install +tests (`install-simple.sh`, `install-cgd.sh`) use `build/vmsession` and start +with `vmsh.sh stop`, which kills qemu; the build VM must not share it. +`tools/devvm.sh` therefore uses `build/vmsession-dev` (`VMDIR`). Found on +2026-11-07, before the first test run that would have killed the VM during its +first NetBSD build; the VM that was started before the change still lives in +`build/vmsession` and moves when it is restarted. + +## Known small defect + +`tools/makronix-distfiles.sh fetch` reports "0 archives taken from +${MAKRONIX_TOP}/distfiles": the shared DISTDIR is read from +`tools/pkgsrc-cross.mk.conf` unexpanded, so nothing is linked from it and +everything is fetched again. Correct, only slower. + +## Sharing the host tree with the VM (measured 2026-11-07) + +The host's `~/src/makronix` can be mounted in the VM, so both work on the same +files. Two ways were measured, in the VM (8 CPUs, KVM, QEMU user-mode network, +tooldir and object files on the local disk, sources from the share): + +| | local | 9p (`mount_9p -Ccu`) | NFS (`mount_nfs -3 -T`) | +|---|---|---|---| +| `find` over `sys/` (35,803 files), 1st / 2nd run | 0.83 s | 20.6 s / 9.3 s | 22.3 s / 3.3 s | +| `tar` of `sys/dev` (88 MB), 1st / 2nd run | 1.25 s | 8.3 s / 4.1 s | 7.3 s / 3.4 s | +| kernel build GENERIC (`build.sh kernel=GENERIC`, 3425 compiles) | 267 s, 322 s | not finished | **837 s** | + +- The two local runs differ by 20 %: that is the noise of this measurement. +- NFS builds the kernel 2.6 to 3.1 times slower than the local disk. The cold + first read is the cost (every file once through QEMU's user-mode network); + warm reads are fast. +- 9p: the kernel build did not finish in the measurement (it was cut off after + about 20 minutes, 245 of 3425 compiles, load 1.5 to 2.7 with `-j 8`: the + build waited on the share); `puffs` in user space is the reason. Treat it as + "at least 4 times slower", not as a measured factor. + +What follows for the work: **edit through the share, build from a local copy.** +`overlay/`, `patches/`, `tools/` and `docs/` are small and read warm; `src/`, +`xsrc/` and `pkgsrc/` are built from the VM's own disk (`/usr/src`, `/usr/msrc`). + +### How it is set up + +- 9p: `tools/devvm.sh start` exports `~/src/makronix` (`vmsh.sh start -h DIR`); + in the guest `mount_9p -Ccu /dev/vio9p0 /host` (the `-u` is needed, QEMU + speaks 9P2000.u; run it with its output redirected, it stays in the + background). +- NFS: the host needs a server: `sudo tools/host-nfs-setup.sh install` (see the + header of the script; `remove` undoes it). In the guest + `mount_nfs -3 -T 10.0.2.2:/home/lotherk/src/makronix /host`. + Facts from the first runs: the export needs `insecure` (QEMU's user-mode + network connects from a port above 1024; with the default `secure`, + `mount_nfs` says "Permission denied"); nfsd and mountd listen on all + addresses and `host=` in `/etc/nfs.conf.d` did not change that, so a + nftables table `makronix_nfs` drops 2049 and the pinned mountd port 20048 + on every interface but `lo`; `rpcbind` is not touched (the host's CDE + desktop depends on it; the first version of the script restarted it, which + was a mistake). `insecure` means any process on the host can mount the tree + from 127.0.0.1 and then acts as user 1000 in it. diff --git a/docs/OFFLINE-BUILD.md b/docs/OFFLINE-BUILD.md new file mode 100644 index 0000000000..7e49152d2e --- /dev/null +++ b/docs/OFFLINE-BUILD.md @@ -0,0 +1,91 @@ +# Rebuilding Makronix without a network + +What the source sets are, where they land, and what is and is not proven. + +## The sets + +`make sourcesets` writes `RELEASEDIR/source/sets/`: + +| set | unpacks to | what | +|---|---|---| +| `src`, `gnusrc`, `syssrc`, `sharesrc` | `/usr/src` | NetBSD, at the pin in `PINS`, with our patches and the overlay already applied, with its `.git` (in `src`) | +| `xsrc` | `/usr/xsrc` | NetBSD X, with its `.git` | +| `msrc` | `/usr/msrc` | the Makronix tree: `Makefile`, `GOAL.md`, `AGENTS.md`, `docs/`, `tools/`, `patches/`, `overlay/`, `packages.list`, `PINS`, `distfiles.lst`, its own `.git`, `pkgsrc/` (pinned checkout with `.git`), `distfiles/` (only the archives of Makronix packages), and the links `src -> /usr/src`, `xsrc -> /usr/xsrc` | + +The first five come from NetBSD's `makesrctars`; `msrc` from the same +command (`-m`, patch 0010), assembled by `tools/msrc-stage.sh`. The +trees carry their git repositories (`makesrctars -g`), so on the installed +system `git -C /usr/msrc/src status` shows the same as in development, +and `tools/overlay.sh`, `tools/build-stamp.sh` and `tools/makronix-pins.sh` +need nothing special. `tools/makronix-pins.sh check` compares `PINS` with +the repositories. + +The sets are `.tgz` (`makesrctars`), about 2.3 GB together with the git +repositories: they fit a DVD, not a CD. `make isosrc` writes the DVD with +`RELEASEDIR/source` on it (`CDSOURCE`, `distrib/common/Makefile.bootcd`); the +CD does not carry them. sysinst installs the source sets that the medium +carries in the simple mode, and skips silently those it does not. + +## Which distfiles + +Only the archives of the Makronix packages: `packages.list` names the packages +that go into the `makronix` set, `tools/makronix-distfiles.sh list` derives the +closure (`bmake show-depends-recursive`) and writes `distfiles.lst` with size +and SHA512 from each package's `distinfo`; `fetch` fills `build/distfiles` +with exactly those (what the shared distfiles directory has with the right +hash, the rest by `bmake fetch`); `check` verifies them. The shared +directory of the development machine is not the source: it holds every +package ever built there, in several versions. + +The list is a superset: it is evaluated on the build host (Linux for the +cross build), and it includes packages that the base system satisfies. + +## What to do on the installed system + + # as root; the sets are unpacked by sysinst or with tar -xzpf -C / + cd /usr/msrc + export MAKRONIX_TOP=/usr/msrc + +`tools/pkgsrc-cross.mk.conf` takes its paths from `MAKRONIX_TOP` and uses +`distfiles/` when it exists. git needs `safe.directory` for trees owned by +`root:wsrc` when used by another user. + +## What is proven, what is not + +See the end of this file; the measurements are in `build/logs/`. + +(filled in by the tests: nothing below this line is a claim until it names a +log) + +### Measured 2026-11-07 + +- The DVD made by `make isosrc` installs `/usr/src`, `/usr/xsrc` and + `/usr/msrc` (with `PINS`, `pkgsrc`, and all 71 distfiles of `distfiles.lst`); + `PINS` names the overlay base of the tree it was made from: + `build/logs/install-src-cd13-2026-11-07.log` (all checks PASS). +- Not proven yet: that a system installed this way rebuilds itself with no + network. That is done in the build VM (see `docs/BUILD-VM.md`). + +### Measured 2026-11-07: NetBSD builds itself on Makronix + +In the build VM (`docs/BUILD-VM.md`), installed from the DVD with sources, as +the user `tester` (member of `wsrc`), from `/usr/src` as installed: + + ./build.sh -U -j 8 -m amd64 -O ~/obj -T ~/tools -x tools distribution + +`tools` and `distribution` built from the sources on the disk: **2 h 02 min** +(`Build started 08:28:57`, `finished 10:31:23`, 8 CPUs, KVM; the pkgsrc bootstrap +and the build of `git-base` ran in the same VM for part of that time), log in +the VM, `/home/tester/log/build2.log`. The build then stopped in +`checkflist`, and only there: **10825 files of `./usr/pkg` missing in DESTDIR**. +That is the file list of the `makronix` set, whose packages were not in the +build's DESTDIR. Not a defect of the sources, a missing step of the recipe: +a self-build has to put the userland into DESTDIR first (what `make release` +on the host gets from `tools/vm-pkgcollect.sh` / `tools/makronix-set.sh`). +Not done yet: that step for the VM, and `release` after it. + +Things this run found in the set, now fixed in the tree: `makesrctars` gave +every file mode 0664 (pkgsrc's `bootstrap` was not executable: patch 0010), +two empty build directories and a `Makefile.orig` of ours were inside +`src/` and made `cleandir` fail for a user who may not remove them, and the +user made by sysinst was not in `wsrc`, the owner group of the trees. diff --git a/docs/reference/AGENTS.md b/docs/reference/AGENTS.md new file mode 100644 index 0000000000..5c13caa678 --- /dev/null +++ b/docs/reference/AGENTS.md @@ -0,0 +1,40 @@ +# docs/reference/ -- documentation read before changing something + +The rule from the root `AGENTS.md`: read the documentation first, save what +you read here, with source and date, and quote the sentence that settled the +question. One topic per file, `.txt`. + +## Files + +- `boot-cfg-timeout.txt` -- how the `boot.cfg` timeout reaches a medium + (source: tree, import `e523df740`, read 2026-11-04). Basis of patch 0007. +- `install-image-boot.txt` -- what the amd64 install image writes into itself + at boot (tree, read 2026-11-04). +- `installcd-console-and-cgd-boot.txt` -- `installboot(8)` console option and + the cgd boot path (tree, read 2026-11-05). Basis of patch 0008. +- `cgdroot-guide.txt` -- the NetBSD wiki page on encrypted root, text + extracted (wiki.netbsd.org/security/cgdroot, fetched 2026-11-05). +- `make-release-build.md` -- `src/BUILDING` on `release` (read 2026-11-05). +- `cgdroot-tree.txt` -- the encrypted-root machinery the NetBSD tree already + carries (cgdroot.rc, the miniroot module, what is on the CD), tree and ISO + read 2026-11-06; its last section lists what is still unread. +- `cgdroot-design.txt` -- boot.cfg `load`, the `NAME=cgd.conf` mount, the + gpt/cgdconfig calls, and the design of the encrypted install in sysinst + (tree, read 2026-11-06); its last section lists what the test must decide. +- `cde-colours.txt` -- slot 5 of Default.dp is the window colour, measured on a + running CDE (2026-11-06); the other slots are not mapped. +- `sysinst-survey.txt` -- what sysinst already does about colours, whole-disk + install and cgd, with file:line (tree, read 2026-11-06; a first pass with + grep, the "Not yet read" list at its end is what is still open). + +## Caveats + +- These are records of what was read, not of what is true now. A conclusion + that went into a patch no longer in `patches/src/` (the cgdroot ones) is + history; the quoted sentences from upstream remain valid. +- The cgdroot guide says sysinst does not support an encrypted root. That is + a statement about the wiki on its date, to be checked against + `src/usr.sbin/sysinst` before the sysinst fork designs around it + (`GOAL.md`, "Offen"). +- Add a file for every area before you change it; do not paraphrase from + memory. diff --git a/docs/reference/cde-colours.txt b/docs/reference/cde-colours.txt new file mode 100644 index 0000000000..518528fe4e --- /dev/null +++ b/docs/reference/cde-colours.txt @@ -0,0 +1,35 @@ +CDE default palette: which slot is what, measured on a running CDE +================================================================== +Measured 2026-11-06 on the CDE that runs on this host (dtsession, dtwm under +/usr/mdt, display :0). No CDE source is in the tree; this is from the running +system only. + +/usr/mdt/palettes/Default.dp, eight lines, 16 bits per channel: + 1 #ed00a8007000 2 #9900991b99fe 3 #89559808aa00 4 #68006f008200 + 5 #c600b2d2a87e 6 #49009200a700 7 #b70087008d00 8 #938eab73bf00 + +`xrdb -query` of the session: + *ColorPalette: Default.dp *background: #C6C6B2B2A8A8 + *foreground: #000000000000 *enableCDEColorFactors: True +=> `*background' is slot 5 cut to 8 bits per channel (c6 b2 a8), and the text + is black. Every ordinary window (terminals, dialogs, the front panel) is + that colour; that is the colour sysinst takes. What the other slots colour + (title bars, workspace buttons, shadows) was not mapped: the slot meaning + was not read from a source, only slot 5 is proven. + +Use in sysinst (overlay/usr.sbin/sysinst/util.c, do_coloring): default pair +black on white; where curses can_change_color(), COLOR_WHITE is redefined to +0xc6/0xb2/0xa8 (776/698/659 of 1000); measured on an xterm-256color console: sysinst sends OSC 4;7;rgb:C5/B1/A8 (curses rounding, one unit below C6/B2/A8; log build/logs/colours-xterm-2026-11-06.log). On a console with the eight fixed colours +(wscons, vt220 over serial: no colours at all in terminfo) it stays black on +white. Not done: the active/selected colour (needs another slot, unproven). + +Note: do not screenshot the whole display of this host for this kind of +measurement -- it shows private windows. xrdb -query and the .dp files are +enough. + +Second use (2026-11-06): the menu selection and box +--------------------------------------------------- +util.c do_coloring also takes slot 4 (#686f82, slate) for the selected menu line +(white text) and the menu box. That is a design choice, not a measurement: +the role slot 4 has in CDE was not established. The pairs are drawn by menuc +(src/usr.bin/menuc/menu_sys.def, patches/src/0009-menuc-colour-pairs.patch). diff --git a/docs/reference/cgdroot-design.txt b/docs/reference/cgdroot-design.txt new file mode 100644 index 0000000000..911622cae5 --- /dev/null +++ b/docs/reference/cgdroot-design.txt @@ -0,0 +1,97 @@ +Encrypted root installed by sysinst: what was read, and the design +================================================================== +Read 2026-11-06 in the tree at /home/lotherk/src/makronix, src/ pinned at +e523df740. Continues cgdroot-tree.txt. + +What was read, and the sentence that settles each point +-------------------------------------------------------- +boot.cfg(5) (src/share/man/man5/boot.cfg.5, "load"): + "Used to load kernel modules, which will be passed on to the kernel for + initialization during early boot. The argument is either the complete path + and file name of the module to be loaded, or a symbolic module name." + and the example "menu=Boot with module foo:load /foo.kmod;boot". + => the boot partition carries /cgdroot.kmod and boot.cfg says + "load /cgdroot.kmod;boot /netbsd". The wiki's `fs /ramdisk-cgdroot.fs` + (cgdroot-guide.txt) is the older mechanism; this tree builds the module + (cgdroot-tree.txt) and has it on the CD. + +distrib/common/cgdroot.rc lines 39-45 (unmodified in the tree): + for dev in NAME=cgd.conf /dev/wd0a /dev/ld0a ; do + if mount -o ro $dev /etc/cgd 2>/dev/null ; then + => mount without -t: the partition labelled "cgd.conf" must be a file system + the kernel can mount by its wedge type, so GPT type ffs; cgd.conf and the + parameter file are at its root. Lines 57-63: root is NAME=cgdroot or + /dev/cgd0a, so cgd0 carries a disklabel with `a` as root. + +gpt(8) (src/sbin/gpt/gpt.8, "add"): + "-l label ... -s size ... -t type": `gpt add -t ffs -l cgd.conf -s 256m disk` + and `gpt add -t cgd -l cgdroot disk` (the second takes the rest). + +sysinst partman (partman.c pm_cgd_init, 1366-1392): its defaults are + pkcs5_pbkdf2/sha1, verify disklabel, aes-xts, encblkno1, 256 bit. The + installer uses the same ones: `cgdconfig -g -V disklabel -i encblkno1 + -k pkcs5_pbkdf2/sha1 -o aes-xts 256`, then `cgdconfig -V re-enter + cgd0 ` (partman.c:1466-1490). + +Upstream sysinst writes no cgd.conf into the target and has no boot partition +for a cgd root: grep cgd over the sysinst sources finds only the partman menus, +gpt.c:114 (the GPT type), configmenu.c ("Enable cgd") and util.c (have_cgd). +(The `setup_cgd_boot` of cgdroot-tree.txt's source note was our own patch +0005, now in patches/unused/; it is not NetBSD.) + +Design (overlay/usr.sbin/sysinst: cgdroot.c, hooks in install.c, disks.c, +arch/i386/md.c, arch/amd64/Makefile -DCGDROOT) +---------------------------------------------------------------------------- +Simple mode only, BIOS only (UEFI would need cgdroot.rc to mount the FAT ESP). + 1. "Encrypt the disk?" after the mode menu (cgdroot_ask). + 2. disk chosen; cgdroot_prepare(): swap check, the last chance for the real + disk, destroy the scheme, `gpt create -f`, the two `gpt add`, read the + GPT back to get the dk names, the two cgdconfig calls (passphrase twice), + then find_disks() again with the disk forced to cgd0 (cgdroot_force_disk); + "cgd" is added to is_bootable_device()'s list so that cgd0 is handled like + raid: no MBR, no BIOS geometry, a plain disklabel. + 3. the ordinary simple flow on cgd0: default layout, disklabel, newfs, fstab + (root /dev/cgd0a), md_post_newfs_bios returns early, sets unpacked. + 4. cgdroot_finish(): newfs -O 2 and mount the boot partition at + /targetroot/cgdboot; copy netbsd and /usr/mdec/boot from the new root and + cgdroot.kmod from the CD (/mnt2/amd64/installation/miniroot/); write + cgd.conf ("cgd0 NAME=cgdroot /etc/cgd/cgdroot") and the parameter file; + md_cgdroot_boot(): boot.cfg, `installboot -f -o console=...` with + bootxx_ffsv2 on the boot partition, `gpt biosboot -b disk`; + fstab gets "NAME=cgd.conf /cgdboot ffs rw,noauto". + +Result (same day): `tools/install-cgd.sh` passed; the CD has the /dev nodes +(dk0-63, cgd0), so the MAKEDEVTARGETS worry below did not apply, and the loader +found boot.cfg on the GPT ffs partition. Two fixes were needed: cgd0 must get a +disklabel (partitions_read_disk makes a GPT), and the CD is the installer root, +so the kmod path comes from ext_dir_bin, not /mnt2. + +Not read, not tested (as of this note) +-------------------------------------- + - whether the miniroot of the CD has the /dev nodes (dk*, cgd0) cgdconfig + needs: the unused patch 0005 claimed it had not (MAKEDEVTARGETS); the test + decides. + - whether the loader finds /boot.cfg on a GPT ffs partition at the first + boot partition without a MBR active flag (the protective MBR from + `gpt biosboot`). + - a wrong passphrase at boot, and a kernel update (copy to /cgdboot). + +UEFI (same day, tools/install-cgd.sh -f uefi passed) +---------------------------------------------------- +Read: src/sys/arch/i386/stand/lib/biosdisk.c biosdisk_findpartition() (1040- +1125): the default boot partition is, in this order, the one with the GPT +"bootme" attribute, the one starting at the boot sector, else "bootable_fs_part", +the first partition of type FFS/LFS/RAID/CCD/CGD/ISO9660. A FAT ESP is none of +these, so the EFI loader's default device is the first FFS partition, here +cgd.conf (log: "boot: NAME=cgd.conf:/netbsd: No such file" when the kernel was +on the ESP). efiboot/boot.c:67: boot.cfg is read from esp:/EFI/NetBSD/boot.cfg, +else /boot.cfg of the default device. +Layout: ESP 128m (EFI/boot/bootx64.efi installed with `installboot -e -o +console=...`, EFI/NetBSD/boot.cfg), cgd.conf 256m FFS (netbsd, cgdroot.kmod, +boot.cfg, cgd.conf, cgdroot), cgdroot. cgdroot.rc is unchanged. +Test infrastructure: the OVMF IDE driver reads a CD so slowly that the loader +needed more than 9 minutes for the kernel; vmsh.sh puts the disk and the CD on +AHCI for -f uefi (CD to the installer: 261 s). tools/vm-screendump.sh saves the +screen of a VM. +Not tested: a UEFI machine with real NVRAM boot entries (the test boots the +removable path EFI/boot/bootx64.efi); wrong passphrase; kernel update. diff --git a/docs/reference/cgdroot-tree.txt b/docs/reference/cgdroot-tree.txt new file mode 100644 index 0000000000..ca73256198 --- /dev/null +++ b/docs/reference/cgdroot-tree.txt @@ -0,0 +1,70 @@ +The encrypted-root machinery that the NetBSD tree already carries +================================================================= +Source: the tree at /home/lotherk/src/makronix, src/ pinned at e523df740 +(NetBSD 11.99.9), read 2026-11-06. The CD facts are from `7z l` of the ISO that +`make iso` built that day. Not yet read line by line: sys/arch/i386/stand +(loader), boot.cfg(5), cgdconfig(8), gpt(8). + +How the tree does an encrypted root (distrib/common/cgdroot.rc, 88 lines) +------------------------------------------------------------------------- +The boot loader loads a *miniroot* as a kernel module; the miniroot is a +ramdisk that runs cgdroot.rc as its init. The script: + 1. mounts a read-only partition at /etc/cgd, trying in this order + NAME=cgd.conf /dev/wd0a /dev/ld0a (lines 36-45) + ("Could not mount the boot partition" and exit 2 if none works); + 2. `cgdconfig -C` configures every cgd in /etc/cgd/cgd.conf; this is where the + passphrase is asked (lines 48-54; "Could not decrypt the encrypted volume"); + 3. chooses the root to mount: NAME=cgdroot and /dev/cgd0a when step 1 found the + config by NAME=, otherwise only /dev/cgd0a (lines 57-63); + 4. mounts it read-only at /altroot (lines 65-77); + 5. `umount /etc/cgd` and `sysctl -w init.root=/altroot`: init continues from + the decrypted root (lines 85-88). +So an encrypted Makronix needs, on the disk: a boot partition the loader can +read (loader, kernel, boot.cfg, the miniroot module), a small partition named +`cgd.conf` holding /etc/cgd (cgd.conf and its parameter files), and a cgd +partition named `cgdroot` whose cgd0 carries a disklabel with `a` = root. + +How the miniroot module is built and shipped +-------------------------------------------- +distrib/amd64/kmod-cgdroot/Makefile: MINIROOT=cgdroot, RAMDISK=ramdisk-cgdroot +(6 lines), which includes distrib/common/Makefile.minirootkmod: it takes +stand///modules/miniroot/miniroot.kmod, adds the ramdisk as the +section `miniroot` with objcopy, gzips it, and in its `release` target installs +it into RELEASEDIR//installation/miniroot/. +distrib/amd64/ramdisks/ramdisk-cgdroot/Makefile: IMAGE=ramdisk-cgdroot.fs, +IMAGESIZE=5000k, lists distrib/common/list.cgdroot and mtree.cgdroot. +No set list names cgdroot (grep over distrib/sets/lists): the module is not part +of any set, so sysinst does not unpack it. + +It IS on the install CD built on 2026-11-06 (7z l): + amd64/installation/miniroot/cgdroot.kmod 1523615 bytes + amd64/installation/miniroot/miniroot.kmod 1713556 bytes + amd64/installation/ramdisk/ramdisk-cgdroot.fs 5120000 bytes + stand/amd64/11.99.9/modules/miniroot/miniroot.kmod 3256 bytes +=> sysinst, running from that CD, can copy cgdroot.kmod into the boot partition + of the target. + +Loader side +----------- +sys/arch/i386/stand/lib/biosdisk.c understands NAME= as a boot +device (lines 94, 928, 1008, 1363, 1642); cgdroot.rc's NAME=cgd.conf and +NAME=cgdroot rely on wedge names, which GPT provides. + +What sysinst has and lacks for this (see sysinst-survey.txt) +------------------------------------------------------------ +Has: GPT partition type "cgd" (gpt.c:114), the cgd menus and cgdconfig -g / +-V re-enter in the installer (partman.c:1456-1497), "Enable cgd" in the config +menu. Lacks: a layout with a boot partition, a `cgd.conf` partition and a +`cgdroot` partition; writing cgd.conf and its parameter files into the config +partition; copying the kernel, loader and cgdroot.kmod into the boot partition; +a boot.cfg that loads the module; a disklabel on cgd0 with root in `a`. + +Open, to read before writing code +--------------------------------- + - the loader's `load` command and boot.cfg(5) syntax for a module; + - how the EFI loader (bootx64.efi) finds boot.cfg and the kernel on an ESP, and + whether the kernel and module may live on the FAT ESP; + - gpt(8): partition labels (-l) for `cgd.conf` and `cgdroot`; + - cgdconfig(8): the parameter file, keygen (pkcs5_pbkdf2/sha1), and how the + passphrase is entered when `cgdconfig -C` runs in the miniroot; + - what the BIOS boot path needs (bootxx on which partition). diff --git a/docs/reference/sysinst-survey.txt b/docs/reference/sysinst-survey.txt new file mode 100644 index 0000000000..405e21e6c7 --- /dev/null +++ b/docs/reference/sysinst-survey.txt @@ -0,0 +1,129 @@ +sysinst: what the tree already does about colours, whole-disk install and cgd +========================================================================== +Source: the tree at /home/lotherk/src/makronix, src/usr.sbin/sysinst, import +src/ pinned at e523df740 (NetBSD 11.99.9). Read 2026-11-06 with grep and +sed, not yet read line by line. Everything below is a file:line of that tree. + +Size: 32471 lines in *.c, *.h, menus.*, msg.mi.en. Largest: partman.c (3440), +mbr.c (3207), util.c (2793), disks.c (2782), label.c (2437), bsddisklabel.c +(2039), gpt.c (1971). Documentation in the directory: sysinst.8, +README.md_defs, TODO. sysinst.8 and TODO contain no mention of cgd or +encryption (grep -i 'cgd|encrypt'). + +Colours +------- +main.c:206-207 default colour pair: clr_arg.bg = COLOR_BLUE, .fg = COLOR_WHITE +main.c:308 start_color() +util.c:2187-2196 one pair only: bg and fg are clamped to <= COLOR_WHITE (the + eight basic curses colours), init_pair(1, fg, bg), applied + with wbkgd/wattrset to stdscr and mainwin +run.c:395-396 the action window copies stdscr's background and attributes +=> The whole installer uses one colour pair out of eight colours. There is no + init_color() call; a palette of arbitrary RGB values (CDE) is not + expressible without adding one. + +Whole-disk install +------------------ +part_edit.c:963 parts_use_wholedisk() +part_edit.c:1035 set_use_entire_disk() +part_edit.c:1081-1083 menu option MSG_Use_the_entire_disk +msg.mi.en (ptnsizes): "The default is to allocate all the space to the root + file system." A partition-size menu follows, in which the + user may split /usr, /var, /home. +=> sysinst already has "use the entire disk" and a default layout; what is + missing for the Makronix goal is skipping the questions around it. + +cgd +--- +partman.c (106 of the 111 "cgd" hits in the *.c files): the "extended +partition manager" creates cgd volumes: menus for base device, encryption, +key size, IV algorithm, key generation, verification (partman.c:1281-1360, +msg.pm.en:115-121). msg.pm.en:68-71: "To use RAID, LVM, or CGD: 1) Create +partitions with the appropriate type; 2) Create RAID/LVM VG/CGD using these +partitions; 3) Save changes; 4) Create partitions for RAID/CGD ..." +partman.c:1456-1497 pm_cgd_commit(): runs + cgdconfig -g -V -i -k -o /tmp/cgd.N.conf + then + cgdconfig -V re-enter cgdN /tmp/cgd.N.conf + i.e. it configures cgd inside the running installer. +util.c:2468 have_cgd = binary_available("cgdconfig") + +Correction, 2026-11-06 (measured on an installed system, see the end of this +file): the post-install config menu has an entry "m: Enable cgd (cryptographic +disk configuration)", shown as YES (configmenu.c, two "cgd" hits, not read +line by line). So the statement below that nothing enables cgd at boot is too +strong: the config menu can. What is still true is that no code writes +/etc/cgd/cgd.conf for a cgd volume created by the partition manager. + +What was NOT found (grep over *.c, *.h, menus.*, msg.*.en): + - no match for 'etc/cgd', 'cgd=YES' or 'cgd.conf': nothing copies the cgd + configuration into the target (add_rc_conf exists, util.c:2017, and is used + for random_file, util.c:1618; the config menu sets rc.conf variables + through its own table, configmenu.c); + - no handling of an encrypted root: for RAID there is + `raidctl -A root` (partman.c:2738-2751); there is no equivalent for cgd. +=> As the tree stands, sysinst can create and use a cgd volume during the + installation, and the installed system would not know how to unlock it at + boot. This agrees with the wiki page saved in cgdroot-guide.txt, which + says the encrypted root is not supported by sysinst. + +Not yet read (to be read before designing the fork) +--------------------------------------------------- + - how the target /etc/fstab is written for a cgd device (partman.c:2641 and + the commit path); + - the cgdroot machinery of the tree: distrib/amd64/kmod-cgdroot, + distrib/common/cgdroot.rc, list.cgdroot, mtree.cgdroot, and the loader's + NAME= handling in sys/arch/i386/stand/lib/biosdisk.c; + - whether sysinst offers the CD to be changed during an installation + (multi-CD, GOAL.md). + +Measured: the installation flow on amd64/BIOS, 2026-11-06 +-------------------------------------------------------- +Driven by hand through tools/vmsh.sh on the CD built by `make iso' (log: +build/logs/install-simple-bios-phase1-2026-11-06.log, console, 100662 bytes). +The screens, in order, as the console printed them: + 1. Terminal type (ENTER = vt220) + 2. language menu (a: English) + 3. main menu: "NetBSD-11.99.9 Install System" a: Install NetBSD to hard disk + 4. "Shall we continue?" (Yes/No) + 5. [Makronix] "Select the installation mode": a: Simple (recommended), b: + Advanced, x: Abandon installation + 6. "Available disks": a: wd0, b: Extended partitioning, x: Exit + 7. [upstream, still asked in simple mode in that build] BIOS geometry: + "a: This is the correct geometry" + 8. "Ok, we are now ready to install NetBSD on your hard disk (wd0). ... last + chance" Shall we continue? + 9. newfs of dk0, then "Bootblocks selection" (a: BIOS console ... x: Continue; + the default b: serial port com0 was the console in use) +10. "Install from": a: CD-ROM / DVD / install image media, b: HTTPS ... + ("Sets selected 20") +11. extraction (kernel, modules, base, etc, comp, ... makronix); a notice that + base32 is optional and not on the medium ("Hit enter to continue") +12. "extraction ... is complete" (Hit enter), then the root password prompt + ("New password:", empty line accepted), then the entropy menu +13. config menu a..r (network, timezone, date, root shell, root password, + binary packages, pkgsrc, sshd, ntpd, ..., xdm, cgd, lvm, raidframe, add a + user, entropy, shell), x: Finished configuring +14. "The installation of NetBSD-11.99.9 is now complete" (Hit enter), main menu, + d: Reboot the computer + +Second boot (disk only, qemu -no-reboot restarted without the CD): login: in 38 +seconds (build/logs/install-simple-bios-phase2-login-2026-11-06.log). As root: + /etc/mtree/set.makronix 1814864 bytes + /usr/pkg/bin 51 entries; /usr/pkg/dt/bin has Xsession, dsdm, dtaction, ... + /dev/dk0 17G root; gpt show wd0: PMBR, GPT, 18G FFS (index 1), 2G swap (2) +Menu keys: a letter only selects, RETURN activates. + +Added 2026-11-06 (Makronix fork, measured) +------------------------------------------ +Welcome screen: main.c, after init_lang(): msg_fmt_display(MSG_welcome, "%s", +REL) and the menu `welcome` (menus.mi, one OK entry). Text in the five +languages (msg.mi.*: welcome, welcome_ok). Seen on the CD under xterm-256color: +"Welcome to the Makronix 11.99.9 installation", description, "Thank you for +choosing Makronix.", "Press OK to continue." (build/logs/colours-xterm-2026-11-06.log). +Colours: three pairs (util.c do_coloring, menuc patch 0009). Under +xterm-256color sysinst sends OSC 4 for colour 4 (68/6E/82, slate), 6 (FF/FF/FF) +and 7 (C5/B1/A8, window colour) -- same log. Install tests after both changes: +install-simple.sh, install-cgd.sh -f bios and -f uefi, all exit 0 +(build/logs/*-col3-2026-11-06.out). Not seen: the colours drawn on a screen +(the log shows the escape sequences, not the pixels), and the translations.