diff --git a/.claude/AGENTS.md b/.claude/AGENTS.md deleted file mode 100644 index f0f5b6008d..0000000000 --- a/.claude/AGENTS.md +++ /dev/null @@ -1,27 +0,0 @@ -# .claude/ -- Claude Code configuration for this tree - -## What it is for - -What an AI session may do in this tree. - -## What is in it - -- `settings.json` -- permission allow/deny lists and the PreToolUse hook - `tools/claude-build-gate.sh`, which enforces the forbidden commands of the - root `AGENTS.md`. -- `settings.local.json` -- not tracked; local permissions of one machine. - -## What may be changed - -Only the user changes `settings.json`; an AI session does not. If a change is -needed, say what and why. - -## What must not be touched - -- Do not weaken the hook to get a command through. If a legitimate read is - refused, put it in a script under `tools/` instead. -- `rpcbind` is never restarted or stopped (the user's CDE desktop depends on - it). `sudo` is allowed (user's `~/.claude/settings.json`) for installing - host packages and the like, not for touching the build output. - - diff --git a/.claude/settings.json b/.claude/settings.json deleted file mode 100644 index f46434e4a7..0000000000 --- a/.claude/settings.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(make:*)", - "Bash(7z l:*)", - "Bash(ls:*)", - "Bash(cat:*)", - "Bash(grep:*)", - "Bash(rg:*)", - "Bash(git status:*)", - "Bash(git diff:*)", - "Bash(git log:*)", - "Bash(tail:*)", - "Bash(make initramfs:*)", - "Bash(sh tools/build-busybox.sh:*)" - ], - "deny": [ - "Bash(systemd-run:*)", - "Bash(systemctl:*)", - "Bash(rm -rf /*)", - "Bash(make -C build:*)" - ] - }, - "hooks": { - "PreToolUse": [ - { - "matcher": "Bash", - "hooks": [ - { - "type": "command", - "command": "/home/lotherk/src/makronix/tools/claude-build-gate.sh" - } - ] - } - ] - } -} diff --git a/.gitignore b/.gitignore index b4066d70d1..18dc94644d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,13 @@ # build/ is what the build produces: obj trees, destdir, packages, logs and the # bootstrap of pkgsrc's host tools. Nothing in it is source; the one file that -# is, is its AGENTS.md. -build/ +# is, is its AGENTS.md -- so the directory itself must stay reachable: `build/` +# would exclude it and `!build/AGENTS.md` could not bring the file back. +build/* !build/AGENTS.md # the pkgsrc checkout at the top; ext/src/*/pkgsrc are our recipes and tracked /pkgsrc/ +# harness-specific configuration is local; AGENTS.md is the common convention +/.claude/ # editor rest files #*# diff --git a/AGENTS.md b/AGENTS.md index 7454e85c41..6ba6909c27 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -155,8 +155,8 @@ No claim without a measurement: file and line, exit code, log excerpt. ## Forbidden -Enforced by the PreToolUse hook `tools/claude-build-gate.sh` (configured in -`.claude/settings.json`) where a hook can see them, binding everywhere else: +Enforced by the build gate `tools/claude-build-gate.sh` where a harness hook can +see it, binding everywhere else: - building through `systemd-run` or any transient unit; `make -C build`, `cd build && make`, hand-chained `build.sh` operations. diff --git a/README.md b/README.md new file mode 100644 index 0000000000..a13a0c030a --- /dev/null +++ b/README.md @@ -0,0 +1,213 @@ +# Makronix + +Makronix is a standalone operating system based on NetBSD, built and shaped on +purpose. It is opinionated: the user decides little and gets a complete system +in return. The desktop is MCDE, a fork of CDE 2.5.3 that lives in the `mcde` +submodule of `ext/src/mcde/`. The version in the tree is **0.99.11** +(`src/sys/conf/makronix-release`); release names are CDE palette names, and the +last one named is 0.99.10 "Camouflage", whose palette drives logo, icons and +installer theme. `uname -s` +stays `NetBSD` so pkgsrc and `config.guess` keep working +([GOAL.md](GOAL.md), decisions of 2026-11-08). + +The guiding principle is **the NetBSD way**: even after the sources have been +changed, a NetBSD developer should say "ah cool, it's still NetBSD". Read the +documentation in the tree first, find the existing pattern with `git grep`, +reuse the existing building block, and only then write code. Platform-neutral +thinking: amd64 is the first target, not the only one. Deviations from a NetBSD +convention are a finding in the report, never a silent change. + +> This file is an orientation for people and agents. Where it disagrees with +> the tree, the tree wins. Binding rules are in [AGENTS.md](AGENTS.md), the +> goal and its measurable definitions of done in [GOAL.md](GOAL.md), and the +> one permitted build procedure in [docs/BUILD-CONTRACT.md](docs/BUILD-CONTRACT.md). +> Per-directory `AGENTS.md` files say what belongs in a directory and what may +> be changed there. + +## What is in the repository + +Everything Makronix needs to build lives in this repository. `make sourcesets` +packages it into a single source set that unpacks to `/usr/src`, so an +installed system can rebuild itself offline ([docs/OFFLINE-BUILD.md](docs/OFFLINE-BUILD.md)). + +| Path | What it is | +|---|---| +| `Makefile` | The one build entry point; NetBSD make (`bmake` on a Linux host — GNU make does not read it). | +| `src/` | Makronix's NetBSD tree, tracked here, not an overlay of patches. Its upstream base commit is in `src/BASE`; NetBSD conventions still apply. | +| `xsrc/` | Makronix's X tree, tracked the same way (`xsrc/BASE`). Built by `build.sh -x -X xsrc` into the X sets (`xbase`, `xcomp`, `xetc`, `xfont`, `xserver`); pkgsrc uses `X11_TYPE=native`. | +| `pkgsrc/` | Pinned checkout of pkgsrc (its own repository). Never patched; package lists and recipes are stored outside it. | +| `packages.list` | The one list of packages Makronix ships: `set`, `bin` and `fetch` packages, media repository packages, games, and `@ARCH` restrictions ([docs/MCDE-PROGRAMS.md](docs/MCDE-PROGRAMS.md) for desktop work). | +| `ext/` | Third-party sources Makronix owns as forks (MCDE, Motif alias `mcde-motif`, afpfs-ng, glibc, splinter), each with its pkgsrc recipe and an `IMPORT` record. The forks are **submodules** of their own repositories since 2026-11-22, so a change is a commit there and then a gitlink bump here; the parent records the commit, the history lives in the submodule ([ext/AGENTS.md](ext/AGENTS.md)). | +| `mobile/` | Makronix/Linux for phones: kernel.org Linux plus our patch series, NetBSD userland from `src/` on glibc, pkgsrc in `/usr/pkg`. Its own `Makefile` and rules ([mobile/AGENTS.md](mobile/AGENTS.md)). | +| `refs/` | Read-only upstream references (NetBSD, Linux, OpenBSD) as shallow submodules. Look here, never build from here. | +| `tools/` | POSIX `sh` scripts for build, release, media, tests and MCDE; no Python, no bashisms ([tools/AGENTS.md](tools/AGENTS.md)). | +| `docs/` | Binding build contract, guides, plans, platform notes, and saved upstream reading ([docs/AGENTS.md](docs/AGENTS.md)). | +| `www/` | The project website, including the Guide as an HTML page. | +| `build/` | All build output: object trees, logs, packages, media and test VMs — nothing here is source, and nothing here is committed except `build/AGENTS.md` ([build/AGENTS.md](build/AGENTS.md)). | +| `distfiles/`, `distfiles.lst` | `distfiles.lst` lists the archives that belong to Makronix (path, file name, size, SHA512); `distfiles/` carries them in the repository since 2026-11-19, so the build needs no network. | +| `PINS` | The pinned upstream commits of `src`, `xsrc` and `pkgsrc` (`tools/makronix-pins.sh` checks them). | +| `LICENSE` | CNCL 1.0 (Could Not Care Less) for what Makronix wrote; imported trees keep their own licences. | + +## What makes Makronix different + +- **Installer.** A fork of NetBSD's `sysinst` with two paths: the *Makronix + way* — choose the disk, optionally encrypt it, then answer the remaining + setup questions (user, network/WLAN, hostname, timezone) during + installation, before the first reboot; and the unchanged advanced NetBSD + path. "FDE" in this repository means cgd root encryption from the installer, + not a hand-typed script. The installer uses the CDE palette; sysinst remains + recognisably sysinst. +- **Desktop.** MCDE is CDE 2.5.3, extended in C99/POSIX with Motif/Xlib/X11, + with system services behind `lib/McdeSys`. The yardstick is "a 1995-class + computer": a new program must be usable in one session on 256 MB without + hardware acceleration. Release names are CDE palette names; 0.99.10 is + "Camouflage" and its palette drives the logo, icons and installer theme. +- **Packages.** The `makronix` set is generated from the installed `/usr/pkg` + tree and installed by sysinst; packages Makronix does not patch arrive as + the NetBSD project's binary packages. Extra groups (games, museum, desktop + programs) come from the media's repository and are installed with `pkg_add`, + so they stay registered for `pkg_add -u` and `pkg_admin audit`. +- **Media.** `make release` produces the installation media: sets, kernels, + the signed source set, a CD/DVD and a bootable USB image. The install DVD + carries everything on one disc; the three CDs split the system, the + `makronix` set and binary packages, with sysinst's "Next CD" menu for + disc changes. Installations from the media are tested in QEMU up to a login + prompt and a clean shutdown. +- **Upgrades.** A one-command path built on `sysupgrade`, `etcupdate` and + registered packages, with `file://` as an allowed source. Release integrity + uses a two-key signify chain: an offline root key signs the release key, + which signs the sets' `SHA512` and the media's package summary. + +## Building + +Everything builds from the root `Makefile` and one of its named targets. Use +`make` on a NetBSD host and `bmake` on a Linux host; do not create new targets +and do not chain `build.sh` operations by hand ([docs/BUILD-CONTRACT.md](docs/BUILD-CONTRACT.md)). + +```sh +make # the distribution (sets), no medium +make release ARCH=amd64 # everything: userland, sets, kernels, signed source + # set, CD/DVD images and the USB image, in one lock +make install # over a running Makronix/NetBSD only: base and X + # (the makronix set and packages follow with t0056) +make mobile # the phones (mobile/Makefile, its own agent) +make test # release tests (tool tests, MCDE units, VM installs) +``` + +`ARCH` is the name a person types (`amd64`, `evbarm`, ...); `MACHINE` is +NetBSD's internal name for it. The host may be NetBSD (native) or something +else (cross): both are one build, detected at the start. A package that builds +only one way is broken — fix its recipe or a host-tool setting, never "build it +in a VM". A VM is for testing installs and upgrades, not for building. + +Important consequences of the build contract: + +- **One build at a time per tree.** The Makefile takes `tools/build-lock.sh`; + a second build is refused with the holder's PID. Tools that write + `build/obj` or `releasedir` refuse direct invocation. Run them through make + or through the lock. +- **The gate is `checkflist`**, invoked exactly as NetBSD invokes it. Extra or + missing files fail the build. A run without that gate is not a release, even + if the images exist. +- **Do not hand-edit `build/obj/releasedir/**`**: move, delete or replace a + wrong artefact by fixing and rebuilding. Do not use `git reset --hard`, + `git checkout -- .`, `git clean -fdx` or delete set lists to make failures go + away. +- **Logs are the evidence.** Long builds run as one named background job with + output in `build/logs/-.log`; the last line is + `make exit=N`. A claim without a file:line or a log line is a guess. + +Other existing targets package or check what `release` built: `iso`, `usb`, +`compress`, `sourcesets`, `isosrc`, `userland`, `kernel`, `tools`, `stamp`, +`cdtest`. See the root Makefile and `docs/BUILD-CONTRACT.md` for the order. + +## After an install: reading and rebuilding offline + +A full-profile installation carries the source set in `/usr/src`: `src/`, +`xsrc/`, `ext/`, `pkgsrc/`, `mobile/`, `www/`, `docs/`, `tools/`, the root +files, `packages.list`, `PINS`, `distfiles.lst`, and `distfiles/` with the +archives of the Makronix packages — one tree, no `/usr/xsrc` and no +`/usr/msrc`. The install DVD and CDs do not carry sources; the full profile +asks for the separate source DVD. Source archives are split over several +files on that DVD because 5.8 GB does not fit ISO 9660's 32-bit size field. +The README on the disc gives the extraction command. + +```sh +cd /usr/src +export MAKRONIX_TOP=/usr/src +``` + +`tools/pkgsrc-cross.mk.conf` takes its paths from `MAKRONIX_TOP` and uses +`distfiles/` when present. Updating an installed system, including the cgd +boot-partition caveat for encrypted systems, is in [docs/UPDATING.md](docs/UPDATING.md). + +## Platforms + +amd64 is the reference platform: tested in QEMU (BIOS and UEFI) and on a +MacBook Pro 2011. The MacBook boots the GPT/EFI USB image directly through +"EFI Boot" and starts dtlogin after installation. Further targeted platforms +are macppc (G3/G4/G5), aarch64 `evbarm` (Raspberry Pi 4 and Zero 2 W, ODROID-M1 +and N2) and armv7 `evbarm` (ODROID-U3+), plus mobile on the OnePlus 7T +("hotdogb"). A platform counts as supported only once its test in QEMU is +green; where QEMU cannot model the hardware, real hardware evidence is +required. Current state and gaps are in [docs/PLATFORMS.md](docs/PLATFORMS.md) +and [ISSUES.md](ISSUES.md). Those documents are dated measurements, not +promises. + +## Documentation map + +- [GOAL.md](GOAL.md) — what Makronix is, decisions made by Konrad, and the + measurable definition of done for each part. +- [AGENTS.md](AGENTS.md) — the binding working rules: docs before code, the + NetBSD way, licensing, build rules, forbidden commands and definition of done. +- [docs/BUILD-CONTRACT.md](docs/BUILD-CONTRACT.md) — the only build procedure, + the `checkflist` gate, task-card format and how a reviewer reruns evidence. +- [docs/OFFLINE-BUILD.md](docs/OFFLINE-BUILD.md) — the source set and what has + actually been measured about rebuilding without a network. +- [docs/UPDATING.md](docs/UPDATING.md) — updating an installed Makronix, and + what is not yet measured. +- [docs/PLATFORMS.md](docs/PLATFORMS.md), [ISSUES.md](ISSUES.md) — platform + tests and the Raspberry Pi 4 issue register. +- [docs/guide/](docs/guide/) — *The Makronix Guide*: one DocBook source built + into manual pages, PDF, HTML and an MCDE information library. +- [ROADMAP.md](ROADMAP.md) — a **draft**, not confirmed by Konrad: proposed + phases (build/media, MCDE, upgrade, platforms, network ideas). +- `docs/reference/` — upstream documentation read and saved with source and + date, so the next session does not start over. Historical narratives here + are history, not rules. + +## Contributing + +Rules before changes ([AGENTS.md](AGENTS.md)): + +1. Read the documentation in the relevant directory and in NetBSD's tree + (`src/BUILDING`, `src/share/misc/style`, `src/distrib/sets/README`, + `src/etc/rc.subr`, man pages, file headers) and save what you read under + `docs/reference/.txt` with source and date. Quote the sentence that + settles a question, with its location, before acting on it. +2. Find the pattern already in the tree with `git grep` and use the existing + building block. Comment which NetBSD pattern the code follows. Write `tools/` + scripts in POSIX `sh` (`dash -n`); no Python, no bashisms. +3. Measure: a task is done when its test is green and committed, a build when + `checkflist` reports nothing missing or extra, a medium when an installation + reaches a login prompt and shuts down cleanly with the log kept. State the + command, the exit code and the log excerpt — no status prose. +4. Commit with explicit paths, one commit per topic, with the test evidence in + the message, and push to both remotes. Do not commit work that is red or + unfinished; say what is missing instead. Another agent works in `mobile/` + in the same repository, so keep commits scoped. + +Project-wide tasks are tracked in tasksd under the `makronix` scope (and its +children, e.g. `makronix/build`, `makronix/mcde`, `makronix/sysinst`); each +card carries "messbar fertig", "Beleg" and "Quellen" +([docs/BUILD-CONTRACT.md](docs/BUILD-CONTRACT.md)). `ROADMAP.md` is a proposal, +not an assignment. + +## Licence + +What Makronix wrote itself is under [CNCL 1.0](LICENSE) (Could Not Care Less): +do whatever you want, no attribution, no conditions. Files carry the line +`License: CNCL 1.0 ...`. Imported trees keep their own licences: `src/` and +`xsrc/` are NetBSD/BSD, `pkgsrc/` and `refs/*` keep upstream terms, and MCDE in +`ext/` is CDE, LGPL 2.0 or later. A new file in a fork gets the CNCL line; a +changed upstream file keeps the notice it already had. diff --git a/build/AGENTS.md b/build/AGENTS.md new file mode 100644 index 0000000000..e20a45c5f7 --- /dev/null +++ b/build/AGENTS.md @@ -0,0 +1,34 @@ +# build/ -- what the build produces + +Nothing here is source and nothing here is committed, except this file +(`.gitignore`). Anything can be regenerated. + +## Layout (as seen on 2026-11-06) + +- `obj/` -- the build's object tree: `tooldir.*` (cross toolchain), + `destdir.amd64` (the sysroot), `releasedir/` (the release and + `images/*.iso`), `distrib/**` (instkernel, ramdisks, kmods). +- `logs/` -- one log per run, named `-.log`; the last line of a + build log is `make exit=N`. Evidence cited in documents points + here. +- `pkg/`, `pkgsrc-bootstrap/`, `pkgsrc-work/` -- pkgsrc's host tools and work + directories (`tools/pkgsrc-cross.mk.conf`). +- `vm/`, `vmshare/`, `usrpkg.tar.gz` -- the test VM (installed via + `tools/install-simple.sh`, driven by `tools/vmsh.sh`). +- `distfiles/` -- the archives of the Makronix packages only + (`tools/makronix-distfiles.sh fetch`); `srctree/` -- the staging directory of + the source set (`make sourcesets`); `vmsession/` -- the test VM of + `tools/vmsh.sh`. +- The leftovers of earlier sessions (`fde*`, `probe`, `pristine`, `trash`, + `*.img`, loose `*.log`, about 28 GB) were deleted on 2026-11-06 with the + user's agreement. Anything new that no document refers to is a candidate + again. + +## Rules + +- `obj/releasedir/**` is not touched by hand: no write, move, delete, replace + (root `AGENTS.md`, "Forbidden"). The hook refuses a command that names the + path and contains a write-like token or any `>` (also `2>&1`); read without + redirections, or through a script in `tools/`. +- Do not run `make` inside this directory (`make -C build` is refused). +- Every log you cite is kept; do not delete a log that a document names. diff --git a/docs/reference/AGENTS.md b/docs/reference/AGENTS.md index c0d79c32a8..2b22172dd9 100644 --- a/docs/reference/AGENTS.md +++ b/docs/reference/AGENTS.md @@ -32,7 +32,9 @@ Records by area; each file's first lines name source and date. - Removed text kept whole: `agents-history-2026-11-13.txt` (root `AGENTS.md`), `tools-agents-history-2026-11-13.txt` (the AGENTS.md files of `tools/`, `.claude/`, `www/`, `ext/`, `docs/`, `refs/` before they were - shortened). + shortened). `.claude/` itself was removed from the repository on + 2026-11-22; `AGENTS.md` is the harness-independent convention. The history + files keep their original wording. ## What may be changed diff --git a/tools/AGENTS.md b/tools/AGENTS.md index ec6777ada3..2a5d21e8b4 100644 --- a/tools/AGENTS.md +++ b/tools/AGENTS.md @@ -118,8 +118,8 @@ MCDE and the logo: - `logo-ascii.sh`, `theme-logo.sh` -- the logo as ASCII, and in a palette's colours (`docs/logo/AGENTS.md`). -`claude-build-gate.sh` -- PreToolUse hook that enforces the forbidden commands -(root `AGENTS.md`, `.claude/AGENTS.md`). Its match is textual: a command that +`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