system

the Chamesle handbook, init, live ISO and install helpers
git clone https://github.com/tortr-rs/system
Log | Files | Refs | README | LICENSE

commit 6f4f75626424dad749a77e3c7d364dc4bb71464a
parent 19ad381905f7a15b081a120122a5e5baf48b845b
Author: torter <koubbamohamedrayan@gmail.com>
Date:   Mon, 16 Nov 2026 23:11:45 +0000

handbook: hoard and Gentoo's ebuilds instead of mag and pkgsrc

Diffstat:
Ahandbook/__pycache__/html.cpython-314.pyc | 0
Mhandbook/handbook.md | 457++++++++++++++++++++++++++++++++++---------------------------------------------
Mhandbook/html.py | 4++--
3 files changed, 196 insertions(+), 265 deletions(-)

diff --git a/handbook/__pycache__/html.cpython-314.pyc b/handbook/__pycache__/html.cpython-314.pyc Binary files differ. diff --git a/handbook/handbook.md b/handbook/handbook.md @@ -3,7 +3,7 @@ 1. About Chamesle 2. Preparing 3. Installing by hand -4. Using mag +4. Using hoard 5. rifle 6. The base system 7. The kernel and firmware @@ -27,18 +27,16 @@ The parts: | kernel | a prebuilt Linux 6.18 LTS kernel with its modules | | musl | the C library | | rifle | the coreutils, all in one C file; `cat`, `ls`, `cp` and the rest are links to one program | -| mag | the package manager; it reads NetBSD pkgsrc packages as they are, and recipes of its own | +| hoard | the package manager, from SPAS; it builds from source and runs Gentoo's ebuilds | | mksh | the shell, login shell and `/bin/sh` | | init | Winchester, `/sbin/init`, a shell script that runs under mksh, in the style of FreeBSD's: `/etc/rc`, `/etc/init.conf`, services | | limine | the boot loader, BIOS and UEFI | -There is nothing from GNU in the system. Two exceptions are on the machine that builds: the kernel's own build tools, -and `gmake`, which musl's Makefile needs. +Chamesle is made to be the most UNIX distribution possible. The coreutils are rifle's, the init is Winchester, and the rest +is what Gentoo's ebuilds build: GNU software where a package needs it, bash for the ebuilds themselves. -The package repository is NetBSD's pkgsrc, read directly by `mag` without `bmake`. Chamesle adds hand-written recipes -only for what pkgsrc does not have: musl, the kernel, its headers and firmware, limine, eudev, kmod, util-linux, iw, -libnl, iproute2, usbutils, netbsd-curses, libtool and ZFS. Everything is built on the machine that installs it, so the first -install takes a while (LLVM is the longest). +The package repository is Gentoo's, on the musl profile, and `hoard` runs its ebuilds. Everything is built on the machine that +installs it, so the first install takes a while (LLVM is the longest). ### 1.2 The layout of the system @@ -49,8 +47,8 @@ install takes a while (LLVM is the longest). /etc configuration /lib/modules kernel modules, one directory per kernel version /lib/firmware firmware for the hardware, zstd compressed - /var/lib/mag which package owns which file - /var/cache/mag downloaded sources + /var/db/pkg which package owns which file + /var/cache/distfiles downloaded sources /run /tmp tmpfs, made new at every boot The PATH of a login shell is `/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`. Packages install into `/usr`. @@ -60,11 +58,11 @@ The PATH of a login shell is `/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`. Pac | directory | what is in it | |-----------|---------------| | `system/` | `tools/` (`chamesle-bootstrap`, `chamesle-chroot`, `chamesle-disk`), `files/` (init, rc and the services), `iso/`, this handbook | -| `mag/` | `mag.c`, `build.sh`, `tests/run.sh`, `repo/` with the hand recipes and `PROVIDES` | +| `SimplePackagemAnagingSystem/` | SPAS: the Rust source of `hoard`, and `src/ebuild.sh`, the environment ebuilds run in | | `rifle/` | `rifle.c`, `build.sh`, `tests/run.sh` | -| pkgsrc | NetBSD's package tree, which you fetch yourself (chapter 2) | +| Gentoo | the ebuild tree, which `hoard sync` fetches (chapter 2) | -The commands in this book assume the three source trees are in `$HOME/src/system`, `$HOME/src/mag` and +The commands in this book assume the source trees are in `$HOME/src/system`, `$HOME/src/SimplePackagemAnagingSystem` and `$HOME/src/rifle`. Change the paths if yours are elsewhere. @@ -74,9 +72,10 @@ The commands in this book assume the three source trees are in `$HOME/src/system Chamesle is built from a running Linux machine: any distribution, or the live ISO of chapter 8. The host needs: -* `clang` and `lld`: `mag` and `rifle` are built with them, and so is everything in the new system +* `clang` and `lld`: `rifle` is built with them, and so is everything in the new system +* `cargo` and `rustc`, for `hoard`, with the musl standard library for `x86_64-unknown-linux-musl` +* `bash`, which ebuilds run in * `gmake`, for musl -* `ftp` (tnftp), which mag uses for downloads (`MAG_FETCH`) * `tar` and a POSIX `sh` * `sfdisk`, `mkfs.ext4` and `mkfs.fat` to prepare the disk * `blkid` to read UUIDs @@ -84,68 +83,48 @@ Chamesle is built from a running Linux machine: any distribution, or the live IS Plan for about 20 GB of free disk space for the sources and build directories of a first install, and a network connection. -### 2.2 Building mag and rifle +### 2.2 Building hoard and rifle -Both are a single C file with no libc under it: +rifle is a single C file with no libc under it: - cd $HOME/src/mag && ./build.sh cd $HOME/src/rifle && ./build.sh -`mag/build.sh` leaves `./mag`. `rifle/build.sh` leaves `./rifle` and a `bin/` directory with a link for every tool. -Put `mag` in your PATH: +`rifle/build.sh` leaves `./rifle` and a `bin/` directory with a link for every tool. hoard is a Rust program. For a +system on musl it is built for the musl target, as a static binary: - install -m755 $HOME/src/mag/mag /usr/local/bin/mag + cd $HOME/src/SimplePackagemAnagingSystem + cargo build --release --target x86_64-unknown-linux-musl + install -m755 target/x86_64-unknown-linux-musl/release/hoard /usr/local/bin/hoard -### 2.3 Getting the pkgsrc tree +The releases of SPAS have a binary for glibc machines, which is what a Gentoo host uses to start with. -Let mag fetch a pkgsrc tree from NetBSD and unpack it into `/usr/pkgsrc`: +### 2.3 Getting the Gentoo tree - mag sync + mkdir -p /var/db/repos /etc/spas/repos.conf + printf '[gentoo]\nlocation = /var/db/repos/gentoo\nsync-type = git\nsync-uri = https://github.com/gentoo-mirror/gentoo.git\n' > /etc/spas/repos.conf/gentoo.conf + hoard sync -`sync` downloads `https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.xz` and replaces the tree with it, so it is also how -the tree is brought up to date. `MAG_SYNC_URL` names another file, and under `MAG_ROOT` the tree goes into `$MAG_ROOT/usr/pkgsrc`. -By hand it is the same thing: +`sync` clones the tree the first time and pulls it after that, so it is also how the tree is brought up to date. +Gentoo has a directory per category (`app-editors`, `sys-apps`, ...) and a directory per package inside it +(`app-editors/vim`) with the ebuilds, a `Manifest` and the files they carry. - cd /usr - ftp -o pkgsrc.tar.xz https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.xz - tar -xf pkgsrc.tar.xz +### 2.4 The profile -pkgsrc has a directory per category (`shells`, `editors`, `www`, ...) and a directory per package inside it -(`shells/mksh`). `mag` reads the package's `Makefile`, `distinfo` and `patches/` itself. +The profile says what a package is built for. Chamesle uses the musl one, and `make.profile` is a link to it: -### 2.4 MAG_REPO + ln -sfn /var/db/repos/gentoo/profiles/default/linux/amd64/23.0/musl /etc/spas/make.profile -`MAG_REPO` is a list of repositories separated by colons. Chamesle's own recipes come first, so they win over pkgsrc -when both have a package of the same name: +`--root DIR` says where to install; it is the new root during an installation (chapter 3) and left out on a running system. +Its own `etc/spas` is the one used. - export MAG_REPO=$HOME/src/mag/repo:/usr/pkgsrc +### 2.5 make.conf -If `MAG_REPO` is not set, mag looks in `/usr/share/mag/repo` (Chamesle's own recipes, which the live ISO and every -bootstrapped root carry) and then in `/usr/pkgsrc`, where `mag sync` puts the tree. `MAG_ROOT` says where to install; it is the new root -during an installation (chapter 3) and unset on a running system. +`/etc/spas/make.conf` holds the build settings, and section 4.4 has what goes in it. `chamesle-bootstrap` writes a first one +for the new system. For the host you build from, make one yourself: -A file called `PROVIDES` in a repo tells mag how our recipes meet pkgsrc's. Its lines are: - - pkgsrc/package our/package our package stands in for the pkgsrc one - pkgsrc/package - nothing is needed, the dependency is dropped - needs pkgsrc/package dep a dependency the pkgsrc Makefile forgets - -For example `converters/libiconv -` (musl has iconv) and `needs editors/vim dev-libs/netbsd-curses`. - -### 2.5 mag.conf - -`$MAG_ROOT/etc/mag.conf` holds the build settings. It uses the syntax of pkgsrc's `mk.conf`: plain `VAR=value` lines. -`chamesle-bootstrap` writes a first one for the new system. For the host you build from, make one yourself: - - JOBS=8 - CFLAGS=-O2 -std=gnu17 - -* `JOBS` is `$JOBS` in the build steps, the number to give `make -j`. Without it mag uses 4 -* `CFLAGS`, `CXXFLAGS`, `CPPFLAGS` and `LDFLAGS` are set for every build -* `PKG_DEFAULT_OPTIONS` and `PKG_OPTIONS.name` set pkgsrc options (section 4.6) -* `CONFIGURE_ARGS.name` adds arguments to the `configure` of one pkgsrc package, such as `CONFIGURE_ARGS.libtirpc=--disable-gssapi` - -The environment wins over the file: `MAG_JOBS`, `CFLAGS` and the others, when set, are used as they are. + CFLAGS="-O2 -pipe -std=gnu17" + CXXFLAGS="${CFLAGS}" + MAKEOPTS="-j8" `-std=gnu17` matters. clang defaults to C23 now, and a lot of older source does not compile under it (section 9.3). @@ -220,7 +199,7 @@ the ISO is mounted on `/run/live/rootfs` and the ISO itself on `/run/live/medium cp /run/live/medium/boot/initrd /mnt/boot/initrd That is the whole base system, kernel, modules and ZFS included, as it was when the ISO was made. The copy keeps the -fstab chamesle-disk wrote. The firmware for wifi and some network cards is not on the ISO. Add it with mag once the new system runs (section 4), or build everything instead (3.4), which needs a +fstab chamesle-disk wrote. The firmware for wifi and some network cards is not on the ISO. Add it with hoard once the new system runs (section 4), or build everything instead (3.4), which needs a machine with a compiler. Work inside the new root with `chamesle-chroot`: @@ -236,44 +215,34 @@ Then go on with 3.6 (fstab) and the rest. rifle (3.5) is on the ISO already, ski ### 3.4 Building the system from source, instead -Point mag at the repositories (section 2.4) and run chamesle-bootstrap: +Have hoard and the tree ready (sections 2.2 to 2.4) and run chamesle-bootstrap: - export MAG_REPO=$HOME/src/mag/repo:/usr/pkgsrc $HOME/src/system/tools/chamesle-bootstrap -n yourhostname /mnt Its usage: - chamesle-bootstrap [-r REPOS] [-s PACKAGES] [-n HOSTNAME] TARGET + chamesle-bootstrap [-s PACKAGES] [-n HOSTNAME] TARGET -* `-r` sets the repositories, instead of `MAG_REPO` * `-s` is the list of packages to install instead of the base set * `-n` is the host name, `chamesle` if not given It makes the directories (`bin boot dev etc/skel home lib lib/firmware mnt proc root run sbin srv sys tmp usr/bin usr/lib usr/sbin usr/share usr/local/bin var/cache var/lib var/log var/tmp`, with `tmp` and `var/tmp` mode 1777 and `root` mode 700), installs everything in `files/` (init, rc, the services, `init.conf`), writes the first `/etc` files (`passwd`, -`group`, `shells`, `fstab`, `profile`, `os-release`, `mag.conf`), and builds the base set into the target with `mag`: - - sys-libs/musl devel/gmake archivers/libarchive app-arch/bsdtar archivers/pigz shells/mksh sys-apps/util-linux - sys-apps/kmod sys-apps/eudev net/dhcpcd net/tnftp sysutils/e2fsprogs sysutils/dosfstools sys-boot/limine - sys-kernel/linux sys-kernel/linux-firmware sys-firmware/sof-firmware sys-firmware/wireless-regdb editors/vim - sys-fs/zfs sys-kernel/zfs-module lang/clang devel/lld lang/compiler-rt lang/libunwind - -`lang/clang` (with `lang/llvm` under it), `devel/lld`, `lang/compiler-rt` and `lang/libunwind` are the compiler of the new -system: it builds what `mag install` asks for after `mag sync`, so no other machine is needed. They are the longest part of the bootstrap. -It also copies the recipes of the first repo that has a `PROVIDES` file into `/usr/share/mag/repo`, installs `chamesle-chroot` and -`chamesle-disk`, and runs `depmod`. - -The sources go in `/mnt/var/cache/mag` and are not fetched twice. An existing file in `/etc` is never overwritten, so -the script can be run again after a failure. A build that fails stops and names the directory it left behind. +`group`, `shells`, `fstab`, `profile`, `os-release`, and `spas/make.conf` with the musl profile), copies the tree into the new +root, and builds the base set into the target with `hoard --root`: -Once musl is in the new root, every later package is built with clang aimed at it, with the loader and library -paths pointing into `/mnt`. That lets the programs run on the host while they are built. They need their real paths -before you boot the new system: + sys-libs/musl app-shells/bash app-shells/mksh sys-apps/util-linux sys-apps/kmod sys-fs/eudev net-misc/dhcpcd + sys-fs/e2fsprogs sys-fs/dosfstools sys-boot/limine sys-kernel/gentoo-sources sys-kernel/linux-firmware + sys-fs/zfs sys-fs/zfs-kmod app-editors/vim llvm-core/clang llvm-core/lld llvm-runtimes/compiler-rt llvm-runtimes/libunwind - MAG_ROOT=/mnt mag relocate +`llvm-core/clang` (with LLVM under it), `lld`, `compiler-rt` and `libunwind` are the compiler of the new system: it builds +what `hoard install` asks for after `hoard sync`, so no other machine is needed. They are the longest part of the bootstrap. +It also installs `chamesle-chroot` and `chamesle-disk`, and runs `depmod`. -Run `mag relocate` again after every `MAG_ROOT=/mnt mag install` that adds programs (section 9.4). +The sources go in `/mnt/var/cache/distfiles` and are not fetched twice. An existing file in `/etc` is never overwritten, so +the script can be run again after a failure. A build that fails stops and names the directory it left behind, and +`hoard --root /mnt install --resume` goes on from where it stopped. ### 3.5 rifle @@ -287,8 +256,7 @@ it is. Add the packages you want now, or after the first boot: - MAG_ROOT=/mnt mag install editors/vim - MAG_ROOT=/mnt mag relocate + hoard --root /mnt install app-editors/vim ### 3.6 fstab @@ -382,140 +350,133 @@ file systems and starts the services of `init.conf`, and puts a login on the tty Then: 1. Bring the network up (section 6.7). -2. `mag sync` fetches the pkgsrc tree (section 2.3). Mag's own recipes are in `/usr/share/mag/repo` already and the - default `MAG_REPO` covers both, so `mag install name` works from then on, and the compiler is in the base set. -3. `mag list` shows what the bootstrap put on the machine. +2. `hoard sync` brings the Gentoo tree up to date (section 2.3), so `hoard install name` works from then on, and the + compiler is in the base set. +3. `hoard list` shows what the bootstrap put on the machine. -## 4. Using mag +## 4. Using hoard + +hoard is the package manager of SPAS. It is a replacement for Portage written in Rust, and it runs Gentoo's ebuilds. Chamesle +uses Gentoo's repository on the musl profile, so a package is an ebuild in `/var/db/repos/gentoo`, and everything is built +on the machine that installs it, unless a binary package matches. ### 4.1 The commands - Usage: mag [-nfk] COMMAND [PACKAGE]... - - install PKG... fetch, build and install, dependencies first - remove PKG... take a package off - upgrade reinstall what the repos have a newer version of - autoremove remove what was only installed as a dependency and is not needed now - list what is installed - info PKG what a recipe says, and whether it is installed - search WORD recipes whose name or desc has WORD - files PKG the files a package put on the system - owns PATH which package a file came from - deps PKG its dependencies, rdeps PKG for what needs it - fetch PKG... only download and check the sources - build PKG build into a stage directory, install nothing - sync download the pkgsrc tree to /usr/pkgsrc - hash FILE... sha256 of files, for writing recipes - - -n only say what would happen -f go on when files clash or something needs the package - -k keep the build directory - -`add` is `install` and `del` is `remove`. `mag relocate` is the one command not in the usage text: it puts the real -loader and library paths into what was built in a `MAG_ROOT` (section 4.4). `mag --version` and `mag --help` do what -they say. + hoard install PKG... install, dependencies first (-p pretend, -1 do not add to world, -u -D -N, -jN parallel builds) + hoard upgrade update everything (install -uDN @world) + hoard remove PKG... uninstall + hoard autoremove uninstall what @world and @system no longer need + hoard sync sync the repositories + hoard search REGEX names (-d: descriptions too) + hoard info PKG versions, masks, keywords, USE + hoard list what is installed + hoard files PKG the files a package put on the system + hoard owns PATH which package a file came from + hoard env-update regenerate /etc/profile.env and ld.so.conf + hoard manifest PKG|DIR write the DIST lines of an overlay package's Manifest + hoard self-update replace a hand-installed hoard with the newest release + +A package name works without its category (`hoard install tree`); hoard asks if two categories have it. +`hoard --root DIR` does any of this in another root, which is how a new system is built (chapter 3). ### 4.2 Installing and removing - mag install shells/mksh - mag install editors/vim net/tnftp - mag -n install net/tnftp what would be built, nothing is done - mag remove vim - -Packages are named as in the repo, `category/name`. `install` takes the dependencies first, downloads the source, checks -its sha256 against the recipe or the pkgsrc `distinfo`, builds into a staging directory, and then installs. - -What `mag` guarantees when it installs: + hoard install app-editors/vim + hoard install -p app-misc/fastfetch what would be built, nothing is done + hoard remove vim -* every file is checked against what other packages own before anything is touched; a clash stops it (`-f` goes on) -* files are put in place with a rename, so a running program is never half written -* a file under `/etc` that is already there stays, and the package's version is written next to it as `.new` -* each package keeps its file list in `var/lib/mag`, which is all `remove`, `files`, `owns` and `autoremove` use +`install` takes the dependencies first, downloads the sources, checks their size, BLAKE2B and SHA512 against the Manifest, +builds in a private directory as the `portage` user without network, and merges the result. Before it touches anything it +checks every file against what other packages own, a file under `/etc` that you changed stays and the new one is written +next to it as `._cfg0000_name`, and each file is replaced atomically, so a running program is never half written. -`remove` stops when another package needs the one you remove; `-f` goes on. `autoremove` takes off the packages that -were installed only as dependencies and that nothing needs any more. +If a build fails, hoard keeps the build directory. `hoard install --resume` goes on from the phase that stopped, +`--skipfirst` leaves the failed package out and `--keep-going` builds everything that does not depend on it. -### 4.3 Finding things +### 4.3 Where it keeps things - mag search editor names and descriptions - mag info net/tnftp the recipe, its version, whether it is installed, its options - mag deps net/tnftp what it needs - mag rdeps sys-libs/musl what needs it - mag files vim what an installed package put on the disk - mag owns /usr/bin/vim which package a file belongs to - mag list everything installed +| what | where | +|------|-------| +| configuration | `/etc/spas`: `make.conf`, `make.profile`, `repos.conf/`, `package.use`, `package.accept_keywords`, `package.mask`, `package.license`, `package.env` and `env/` | +| the repositories | `/var/db/repos/gentoo`, and any overlay you add | +| installed packages | `/var/db/pkg`, one directory per package, with its `CONTENTS` | +| the world file | `/var/lib/portage/world` | +| downloaded sources | `/var/cache/distfiles` | +| binary packages | `PKGDIR`, from `/etc/spas/make.conf` | -### 4.4 Installing somewhere else +If there is no `/etc/spas`, hoard reads `/etc/portage` instead, so a machine that has Portage's files is understood as it is. -`MAG_ROOT=/mnt mag install ...` installs and records in `/mnt` instead of `/`. This is how a new system is built -(chapter 3), and how the root of an ISO is built (chapter 8). The `etc/mag.conf` inside that root is the one used. +### 4.4 make.conf -Once the root has musl, mag aims clang at it so that what is built can run on the host (section 9.4). `mag relocate` -puts the real paths back: +`/etc/spas/make.conf` holds the build settings, in the shell syntax of Portage's: - MAG_ROOT=/mnt mag relocate + COMMON_FLAGS="-O2 -pipe -std=gnu17" + CFLAGS="${COMMON_FLAGS}" + CXXFLAGS="${COMMON_FLAGS}" + CHOST="x86_64-pc-linux-musl" + MAKEOPTS="-j8" + ACCEPT_KEYWORDS="amd64" + USE="-systemd" -### 4.5 Other variables +* `MAKEOPTS` is the number of jobs for `make`, and `-jN` on the hoard command line is how many packages build at once +* `USE` turns features on and off for every package; one package gets its own line in `package.use` +* `ACCEPT_KEYWORDS` says how new the packages may be: `amd64` is stable, `~amd64` is testing +* `/etc/spas/make.profile` is a link to a profile of the tree. Chamesle uses the musl one: + `ln -sfn /var/db/repos/gentoo/profiles/default/linux/amd64/23.0/musl /etc/spas/make.profile` -| variable | meaning | default | -|----------|---------|---------| -| `MAG_ROOT` | where to install | `/` | -| `MAG_REPO` | repositories, split by colons | `/usr/share/mag/repo:/usr/pkgsrc` | -| `MAG_SYNC_URL` | the file `mag sync` fetches | NetBSD's `pkgsrc.tar.xz` | -| `MAG_FETCH` | the download command, given a file and a URL | `ftp -o` | -| `MAG_PREFIX` | `$PREFIX` in the steps | `/usr` | -| `MAG_JOBS` | `$JOBS` in the steps | `JOBS` of mag.conf, else 4 | -| `MAG_SH` | the shell the steps run under | `/bin/sh` | +`-std=gnu17` matters. clang defaults to C23 now, and a lot of older source does not compile under it (section 9.3). -mag does not speak https itself; `MAG_FETCH` does, so `ftp` has to be on the machine. +### 4.5 Repositories -### 4.6 pkgsrc options +`/etc/spas/repos.conf/gentoo.conf` names the tree and where it comes from: -Many pkgsrc packages have options (`PKG_OPTIONS`). mag works them out the way pkgsrc does: the package's suggested -options, then `PKG_DEFAULT_OPTIONS`, then `PKG_OPTIONS.name`, each word adding an option, or taking it off when it has a -minus. Put them in `/etc/mag.conf`: + [gentoo] + location = /var/db/repos/gentoo + sync-type = git + sync-uri = https://github.com/gentoo-mirror/gentoo.git - PKG_DEFAULT_OPTIONS=-http2 idn - PKG_OPTIONS.vim=python +`hoard sync` brings every repository up to date. A git repository whose newest commit is not validly signed is rolled back, +and a tree from rsync is checked against its signed Manifests. -`mag info net/tnftp` shows the options a package ends up with, and its dependencies change with them. The recipes of -Chamesle's own repo have no options; they see `JOBS` and the flags only. +### 4.6 USE flags and keywords -### 4.7 Writing a recipe +When nothing satisfies a dependency, hoard works out the smallest change that would (a `package.use` line, a `~amd64` +keyword or a license), shows it, and writes it to `zz-hoard-autounmask` in the config directory after you say yes. -If pkgsrc does not have what you want, write a recipe. It is a file called `category/name` in a repository that comes -before pkgsrc in `MAG_REPO`. It can also be a directory with a file called `recipe` in it, when there are patches or -other files to carry: `$RECIPE_DIR` is that directory (`repo/dev-build/libtool` is one). + hoard info net-misc/curl the versions, the USE flags and what they are now + echo "net-misc/curl http2 -idn" >> /etc/spas/package.use - desc: nl80211 wireless configuration tool - version: 6.17 - url: https://cdn.kernel.org/pub/software/network/iw/iw-${version}.tar.xz - sha256: 7d182e498289ab39b257da6780d562e415377107f50358ee5b55b8cfe40b1e33 - deps: net-libs/libnl devel/pkgconf - steps: - make -j$JOBS - make PREFIX=$PREFIX DESTDIR=$DESTDIR install +### 4.7 Binary packages -The fields: +`hoard install -g` uses prebuilt packages from Gentoo's binary host when the version, slot and every USE flag match, +and otherwise builds the ebuild. They are checked against the index and the release key before they are unpacked. +`-b` (or `FEATURES=buildpkg`) saves everything you build as a `.gpkg.tar` in `PKGDIR`, and hoard installs from those the +next time the version and USE match. -* `desc` is the line `mag search` matches and shows -* `version` is also `${version}` inside `url` -* `url` is the source archive; it is unpacked with its first directory stripped -* `sha256` is the checksum of that archive; `mag hash file.tar.xz` prints it -* `deps` are other packages, split by spaces, built first -* `steps:` is a block of lines that start with a tab, run as a plain `sh -e` script in the unpacked source +### 4.8 Writing an ebuild -The steps see `$DESTDIR` (everything has to be installed there, never into the real root), `$PREFIX` (`/usr`), `$JOBS`, -`$NAME`, `$VERSION`, `$SRC` and `$RECIPE_DIR`. The package is made from what ends up in `$DESTDIR`. +If the tree does not have what you want, write an ebuild in an overlay. An overlay is a repository with `profiles/repo_name`, +`metadata/layout.conf` and `category/name/name-VERSION.ebuild`: -Try it without installing: + EAPI=8 + DESCRIPTION="nl80211 wireless configuration tool" + HOMEPAGE="https://wireless.docs.kernel.org/en/latest/en/users/documentation/iw.html" + SRC_URI="https://cdn.kernel.org/pub/software/network/iw/${P}.tar.xz" + LICENSE="ISC" + SLOT="0" + KEYWORDS="amd64" + DEPEND="dev-libs/libnl" + RDEPEND="${DEPEND}" + BDEPEND="virtual/pkgconfig" - mag build net-wireless/iw builds, says where the files are - mag -k build net-wireless/iw keeps the build directory too + src_install() { + emake PREFIX="${EPREFIX}/usr" DESTDIR="${D}" install + } -and when it is right: +`hoard manifest net-wireless/iw` writes the checksums of the sources into the package's `Manifest`. Add the overlay to +`/etc/spas/repos.conf/`, run `hoard sync`, and `hoard install net-wireless/iw` builds it. - mag install net-wireless/iw ## 5. rifle @@ -573,8 +534,7 @@ are compared. The machine that runs the tests therefore has GNU coreutils for th not. `./build.sh` has to have run first. A case that starts with `@ro` runs with the whole file system read-only under `bwrap`, and is skipped when `bwrap` is missing. -mag has a test of its own: `mag/tests/run.sh` builds a fake repo with local tarballs and goes through install, upgrade -and remove in a scratch root. It needs ftp, tar and the rifle tools in PATH. +hoard has tests of its own, in the SPAS sources (`cargo test`). ## 6. The base system @@ -678,7 +638,7 @@ once (`now`) or after `+minutes`, with an optional message sent through `wall`: | `fstab` | `proc`, `sysfs`, `tmpfs` on `/tmp`, plus the lines you add | | `profile` | `PATH`, `EDITOR=vim`, `PAGER=less`, `umask 022` | | `os-release` | `NAME=Chamesle`, `ID=chamesle` | -| `mag.conf` | `JOBS` and `CFLAGS` for mag | +| `make.conf` | `MAKEOPTS` and `CFLAGS` for hoard | | `skel/` | empty directory for the files new homes start from | The login shell is mksh and `/etc/profile` is read by login shells. For a prompt and aliases make `~/.mkshrc` and set @@ -710,9 +670,9 @@ kmod provides `modprobe`, `insmod`, `rmmod`, `lsmod`, `modinfo` and `depmod`. A dhcpcd eth0 -`dhcpcd` without arguments takes every interface. It is the `network` service, in `boot-services` by default, so it is up at boot. `/sys/class/net/` lists the interfaces. For `ip`, install iproute2 from Chamesle's repo: +`dhcpcd` without arguments takes every interface. It is the `network` service, in `boot-services` by default, so it is up at boot. `/sys/class/net/` lists the interfaces. For `ip`, install iproute2: - mag install net-misc/iproute2 + hoard install sys-apps/iproute2 A static address: @@ -723,9 +683,9 @@ A static address: ### 6.8 Wireless -`iw` talks to the kernel's nl80211. It is in Chamesle's repo, with libnl: +`iw` talks to the kernel's nl80211. It is in Gentoo's tree, with libnl: - mag install net-wireless/iw + hoard install net-wireless/iw iw dev the wireless interfaces ip link set wlan0 up iw dev wlan0 scan | grep SSID @@ -734,8 +694,8 @@ A static address: `/lib/firmware` from `sys-kernel/linux-firmware`. If `dmesg` says a firmware file failed to load, check that it is there. -For an open network `iw dev wlan0 connect NAME` is enough. For WPA the connection needs `wpa_supplicant`; if your pkgsrc -tree has it (`mag search wpa`), install it, give it a configuration file with the `ssid` and the `psk`, and run it on the +For an open network `iw dev wlan0 connect NAME` is enough. For WPA the connection needs `wpa_supplicant`; it is +`net-wireless/wpa_supplicant` (`hoard search wpa`). Install it, give it a configuration file with the `ssid` and the `psk`, and run it on the interface. Then `dhcpcd wlan0`. ### 6.9 Mounting and disks @@ -774,14 +734,10 @@ Edit `repo/sys-kernel/linux`: version: 6.18.64 sha256: the new one -Download the file the `url` names with the new version filled in, and take the checksum: - - ftp -o FILE URL - mag hash FILE +The kernel comes from `sys-kernel/gentoo-sources`, or from `sys-kernel/vanilla-sources` for the plain one. Install it, which +puts the source in `/usr/src`: -Then: - - mag install sys-kernel/linux + hoard install sys-kernel/gentoo-sources and add an entry in `/boot/limine.conf` for the new `vmlinuz-VERSION`. Keep the old one until the new one has booted: @@ -805,7 +761,7 @@ after installing a new kernel, reboot before loading any. ### 7.4 Firmware - mag install sys-kernel/linux-firmware + hoard install sys-kernel/linux-firmware puts the firmware for wifi, graphics, ethernet and the rest, compressed with zstd, into `/lib/firmware`. `sys-firmware/sof-firmware` has the sound firmware of newer Intel machines. Both are in the base set. A new firmware @@ -851,7 +807,7 @@ On ZFS the command line is `root=ZFS=rpool/root rw`. The ZFS module is `sys-kern ### 8.1 What it is The ISO is a live system to work from. It boots on BIOS and UEFI machines with limine, from a disc or a stick, and has -mksh, vim, mag with Chamesle's recipes (`mag search` and `mag info` work before `mag sync`), `chamesle-bootstrap`, +mksh, vim, hoard with the Gentoo tree (`hoard search` and `hoard info` work before `hoard sync`), `chamesle-bootstrap`, `chamesle-chroot`, `chamesle-disk`, the disk tools (`cfdisk`, `sfdisk`, `mkfs.ext4`, `mkfs.fat`, `zpool`, `zfs`) and this handbook in `/usr/share/doc/chamesle/handbook.md`. It is where you do chapter 3 on a machine that has nothing on it. @@ -884,59 +840,47 @@ To write the ISO to a stick: `dd if=chamesle.iso of=/dev/sdX bs=4M conv=fsync`. ### 9.1 Updating packages - mag -n upgrade - mag upgrade + hoard sync + hoard upgrade -p + hoard upgrade -The first says what would be rebuilt, the second reinstalls whatever the repos have a newer version of. pkgsrc itself is -updated with `mag sync` (section 2.3). One package: `mag install name`. When you work with -`MAG_ROOT` set, run `mag relocate` afterwards. +`sync` brings the Gentoo tree up to date (section 2.3), the second says what would be rebuilt, the third rebuilds whatever +the tree has a newer version of. One package: `hoard install name`. ### 9.2 Cleaning up - mag autoremove dependencies nothing needs any more - rm -rf /var/cache/mag/* downloaded sources; they are fetched again when needed + hoard autoremove dependencies nothing needs any more + rm -rf /var/cache/distfiles/* downloaded sources; they are fetched again when needed ### 9.3 C23 and CFLAGS clang compiles C as C23 by default. Older programs written for C89 or C99 stop with errors about `bool`, `true` or -`false` used as names, or about functions declared as `int f()` and called with arguments. `CFLAGS=-O2 -std=gnu17` in -`mag.conf` makes the compiler use C17 for every build. It is in the file chamesle-bootstrap writes; if you wrote your -own `mag.conf` without it, add it. - -To see the error of a failed build, run `mag -k install name`: the build directory is kept, and the error is above the -line that says `the steps failed, left in ...`. +`false` used as names, or about functions declared as `int f()` and called with arguments. `CFLAGS="-O2 -std=gnu17"` in +`/etc/spas/make.conf` makes the compiler use C17 for every build. It is in the file chamesle-bootstrap writes; if you wrote your +own `make.conf` without it, add it. -### 9.4 The root's compiler and mag relocate +To see the error of a failed build, read the log hoard names: the build directory is kept, and `hoard install --resume` +goes on from the phase that stopped. -When `MAG_ROOT` has musl in it (`usr/lib/crt1.o` and `usr/lib/libc.so`), mag makes a `cc` script in the build directory -and puts it first in `PATH`, with `gcc`, `clang` and `c99` as links to it. It runs the clang of the host with -`--target=x86_64-linux-musl`, `--sysroot` and `-isystem` pointed at the root, lld, compiler-rt, and the loader and -library paths set to the ones in the root, so that what was built runs on the host. `-lgcc`, `-lgcc_s` and `-lgcc_eh` -are dropped from the command line because compiler-rt replaces them. +### 9.4 Installing into a root -A program built that way names `/mnt/usr/lib/libc.so` as its loader and `/mnt/usr/lib` as its library path. On the real -system neither exists, and running the program says "not found" although the file is there. `mag relocate` goes -through `usr`, `bin`, `sbin` and `lib` in the root and puts back `/lib/ld-musl-x86_64.so.1` and `/usr/lib`. Run it before -the first boot and after every install into a `MAG_ROOT`. +`hoard --root /mnt install name` builds and merges into `/mnt`, with the configuration of `/mnt/etc/spas`. Once the root has +musl in it, the builds use the clang of the new root, so a package is built for the system it goes into. -If there is no `clang` in `PATH` outside the root, mag stops with "no clang in PATH: it is the compiler for a musl root". +### 9.5 Build tools -### 9.5 libtool - -pkgsrc packages that use libtool expect a `libtool` script. `dev-build/libtool` is a small one of Chamesle's that -compiles, links and installs shared and static libraries; kmod, for example, is built with `LIBTOOL=libtool`. If a -package fails at a libtool step, read `repo/dev-build/libtool/libtool`, and for a package that insists on its own -libtool pass `LIBTOOL=libtool` to its `make`. +Ebuilds call the usual tools by name: `make`, `awk`, `sed`, `grep`, `diff`, `cmp`, `install`, `python3`, `perl`, `m4`. The +coreutils ones are rifle's, and the rest are packages like any other. A name an ebuild asks for that is missing is a package +to install, and `hoard install -p` says which one. ### 9.6 Failures you will see | what you see | why, and what to do | |--------------|---------------------| -| `no recipe for NAME` | the name is in no repo of `MAG_REPO`; try `mag search`, and check the pkgsrc path is in `MAG_REPO` | -| a checksum mismatch | the download is not the one the recipe names; for the kernel see section 7.2 | +| `no ebuilds match NAME` | the name is in no repository of `repos.conf`; try `hoard search`, and run `hoard sync` | +| a checksum mismatch | the download is not the one the Manifest names; hoard fetches it again | | `no clang in PATH` | the build host has no clang outside the new root; install one | -| a program says `not found` though the file is there | its loader path is the one of the build: `MAG_ROOT=... mag relocate` | -| files clash, or a package cannot be removed | another package owns the file or needs the package; read what mag says, `-f` goes on | +| files clash, or a package cannot be removed | another package owns the file or needs the package; read what hoard says | | errors on `bool`, `true`, `false` or on old declarations | C23; `CFLAGS=-O2 -std=gnu17` (section 9.3) | | musl's build fails | `gmake` is missing on the host | | "root device not found" at boot | the kernel cannot see the disk or the file system: it needs a module, use an initramfs (section 7.5) | @@ -944,14 +888,12 @@ libtool pass `LIBTOOL=libtool` to its `make`. | a BIOS machine does not boot | `limine bios-install /dev/sda` was not run, or `limine-bios.sys` is not in `/boot` | | a UEFI machine does not boot | `EFI/BOOT/BOOTX64.EFI` is not on the EFI partition, or the partition is not of type EFI System | | a login without a password | the password field of `passwd` is empty | -| no devices in `/dev` | udev did not start; check that `udevd` is installed with `mag list` | +| no devices in `/dev` | udev did not start; check that `udevd` is installed with `hoard list` | ### 9.7 Keeping a build - mag -k install name - -keeps the build directory. `mag fetch name` downloads and checks the sources without building, and `mag build name` builds -into a staging directory and prints where the files are. +hoard keeps the build directory of a failed build, in `/var/tmp/portage`. `hoard install -f name` only downloads and +checks the sources, and `hoard install --resume` carries on from the phase that stopped. ## 10. File reference @@ -968,19 +910,18 @@ into a staging directory and prints where the files are. | `/etc/passwd`, `/etc/group`, `/etc/shells` | accounts, groups, login shells | | `/etc/fstab` | file systems | | `/etc/os-release` | `NAME=Chamesle`, `ID=chamesle` | -| `/etc/mag.conf` | mag's build settings: `JOBS`, `CFLAGS`, `PKG_DEFAULT_OPTIONS`, `PKG_OPTIONS.name` | +| `/etc/spas/` | hoard's configuration: `make.conf`, `make.profile`, `repos.conf/`, `package.use` and the rest (section 4.3) | | `/boot/limine.conf` | the boot entries | | `/boot/limine-bios.sys` | limine's BIOS stage | | `/boot/EFI/BOOT/BOOTX64.EFI` | limine for UEFI | | `/boot/vmlinuz-V`, `config-V`, `System.map-V` | the kernel | | `/lib/modules/V/` | its modules | | `/lib/firmware/` | firmware | -| `/var/lib/mag/` | the file list of each installed package | -| `/var/cache/mag/` | downloaded sources | +| `/var/db/pkg/` | the file list of each installed package | +| `/var/cache/distfiles/` | downloaded sources | | `/usr/share/limine/` | limine's boot files, for installing it | | `/usr/share/doc/chamesle/handbook.md` | this book, on the live ISO | -| `/usr/share/mag/repo/` | Chamesle's recipes | -| `/usr/pkgsrc/` | the pkgsrc tree, from `mag sync` | +| `/var/db/repos/gentoo/` | the Gentoo tree, from `hoard sync` | ### 10.2 In the sources @@ -997,24 +938,14 @@ into a staging directory and prints where the files are. | `system/iso/profile/limine.conf` | the live boot menu | | `system/iso/profile/overlay/` | files copied over the live root | | `system/handbook/handbook.md` | this book | -| `mag/mag.c`, `mag/build.sh`, `mag/c.h` | the package manager and its libc | -| `mag/tests/run.sh` | tests on a fake repo: install, upgrade, remove in a scratch root | -| `mag/repo/PROVIDES` | pkgsrc packages replaced or skipped, and dependencies added | -| `mag/repo/sys-libs/musl` | the libc | -| `mag/repo/sys-kernel/{linux,linux-headers,linux-firmware,zfs-module}` | kernel, headers, firmware, the ZFS module | -| `mag/repo/sys-fs/zfs` | ZFS userland: `zpool`, `zfs` | -| `mag/repo/sys-boot/limine` | the boot loader | -| `mag/repo/sys-apps/{eudev,kmod,util-linux,usbutils}` | udev, module tools, the basics, usb tools | -| `mag/repo/net-libs/libnl`, `net-wireless/iw`, `net-misc/iproute2` | network tools | -| `mag/repo/sys-firmware/{sof-firmware,wireless-regdb}` | firmware extras | -| `mag/repo/dev-libs/netbsd-curses`, `dev-build/libtool` | curses and libtool | +| `SimplePackagemAnagingSystem/src/` | hoard, in Rust, and `ebuild.sh`, the environment ebuilds run in | | `rifle/rifle.c`, `rifle/c.h`, `rifle/build.sh` | the coreutils | | `rifle/tests/run.sh`, `rifle/tests/cases` | the comparison tests | ### 10.3 Commands in short - chamesle-bootstrap [-r REPOS] [-s PACKAGES] [-n HOSTNAME] TARGET + chamesle-bootstrap [-s PACKAGES] [-n HOSTNAME] TARGET mkinitramfs [-m modules] ROOTFS KVER OUT - mag [-nfk] install|remove|upgrade|autoremove|list|info|search|files|owns|deps|rdeps|fetch|build|sync|relocate|hash + hoard [--root DIR] install|upgrade|remove|autoremove|sync|search|info|list|files|owns|env-update|manifest|self-update rifle --install DIR | --list limine bios-install DEVICE diff --git a/handbook/html.py b/handbook/html.py @@ -5,7 +5,7 @@ import html, os, re, sys, time out = sys.argv[1] src = sys.argv[2] if len(sys.argv) > 2 else os.path.join(os.path.dirname(os.path.abspath(__file__)), 'handbook.md') -slugs = ['about', 'preparing', 'installing', 'mag', 'rifle', 'base', 'kernel', 'iso', 'maintaining', 'files'] +slugs = ['about', 'preparing', 'installing', 'hoard', 'rifle', 'base', 'kernel', 'iso', 'maintaining', 'files'] NAV = ('<a href="./">Home</a> |\n<a href="download.html">Download</a> |\n<b>Handbook</b> |\n' '<a href="packages.html">Packages</a> |\n<a href="new.html">News</a> |\n<a href="board.html">Board</a> |\n' @@ -147,7 +147,7 @@ for k, (title, body) in enumerate(chapters): toc.append('<ul>' + ''.join(f'<li><a href="{fname(k)}#{ident(s)}">{html.escape(s)}</a></li>' for s in subs) + '</ul>') toc.append('</li>') toc.append('</ol>') -open(os.path.join(out, 'docs.html'), 'w').write(page('Handbook', 'The Chamesle handbook, chapter by chapter: preparing, installing by hand, mag, rifle, the base system, the kernel, the live ISO and the files of the system.', 'docs.html', '\n'.join(toc))) +open(os.path.join(out, 'docs.html'), 'w').write(page('Handbook', 'The Chamesle handbook, chapter by chapter: preparing, installing by hand, hoard, rifle, the base system, the kernel, the live ISO and the files of the system.', 'docs.html', '\n'.join(toc))) for k, (title, body) in enumerate(chapters): name = re.sub(r'^\d+\. ', '', title)