commit 5b7489fe3f0665827d067593e580cbb0def4d585 parent d88d148927b1e041e5d153fc471c31135265187d Author: torter <koubbamohamedrayan@gmail.com> Date: Sat, 21 Nov 2026 13:05:33 +0000 bootstrap from mag instead of a stage: own signed repo, chamesle-base, x86 iso, handbook rewritten Diffstat:
43 files changed, 803 insertions(+), 672 deletions(-)
diff --git a/files/etc/init.conf b/files/etc/init.conf @@ -2,13 +2,12 @@ hostname = chamesle # started in this order at boot, stopped in reverse at shutdown -#boot-services = {udev,modules,dbus,NetworkManager,LightDM} boot-services = {udev,modules,network} # kernel modules to load by hand modules = {evdev,psmouse,i8042,atkbd,usbhid,hid_generic,hid_multitouch,i2c_hid_acpi,xhci_pci,virtio_net,e1000,e1000e,r8169,8139too,igb} # $tty is the name of the line; getty-NAME overrides getty for one line -ttys = {tty1,ttyS0} -getty = agetty --noclear -n -l /usr/bin/mksh $tty linux -getty-ttyS0 = agetty -L -n -l /usr/bin/mksh $tty 115200 vt100 +ttys = {tty1,tty2,tty3,tty4,tty5,tty6,ttyS0} +getty = agetty --noclear $tty linux +getty-ttyS0 = agetty -L $tty 115200 vt100 diff --git a/files/etc/rc.d/dbus b/files/etc/rc.d/dbus @@ -3,7 +3,7 @@ procname=dbus-daemon svc_start() { mkdir -p /var/lib/dbus /run/dbus - chown dbus:dbus /run/dbus + chown messagebus:messagebus /run/dbus [ -s /var/lib/dbus/machine-id ] || dbus-uuidgen --ensure=/var/lib/dbus/machine-id rm -f /run/dbus/pid dbus-daemon --system diff --git a/files/etc/rc.d/iwd b/files/etc/rc.d/iwd @@ -0,0 +1,5 @@ +#!/bin/sh +. /etc/rc.subr +procname=iwd +svc_start() { /usr/libexec/iwd & } +run "$1" diff --git a/files/sbin/init b/files/sbin/init @@ -1,4 +1,4 @@ -#!/usr/bin/mksh +#!/bin/mksh # winchester, pid 1: runs /etc/rc, keeps the gettys of init.conf alive, and stops the machine on a signal. # INT and TERM reboot, USR1 halts, USR2 powers off export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin @@ -45,6 +45,7 @@ sleep 2 kill -s KILL -- -1 sync umount -a -r +[ -e /proc/sysrq-trigger ] || mount -t proc proc /proc echo 1 > /proc/sys/kernel/sysrq case $stop in reboot) echo "rebooting"; echo b > /proc/sysrq-trigger;; diff --git a/files/sbin/service b/files/sbin/service @@ -11,7 +11,7 @@ find_script() { case $1 in -l) for d in $dirs; do - for f in $d/*; do [ -x "$f" ] && echo "${f##*/}"; done + for f in $d/*; do if [ -x "$f" ]; then echo "${f##*/}"; fi; done done;; -e) for s in $(conf boot-services); do 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 SPAS +4. mag 5. rifle 6. The base system 7. The kernel and firmware @@ -16,9 +16,9 @@ ### 1.1 What it is -Chamesle is a Linux distribution built from source that you put on a disk yourself, starting from the ISO. There is no installer: you -install the root file system, write the configuration and the boot entry by hand. `chamesle-disk` partitions and formats the -disk for you if you want, and this handbook goes through every other step. +Chamesle is a small Linux distribution on musl that you put on a disk yourself, from the ISO. There is no installer and +nothing is compiled: `chamesle-bootstrap` puts the base into an empty root with the package manager, and you write the +fstab, the password and the boot entry by hand. This handbook goes through every step. The parts: @@ -26,115 +26,101 @@ The parts: |--------|------------| | kernel | a prebuilt Linux 6.18 LTS kernel with its modules | | musl | the C library | +| mag | the package manager, binary packages only, in one C file | | rifle | the coreutils, all in one C file; `cat`, `ls`, `cp` and the rest are links to one program | -| SPAS | the package manager; its command is `hoard`. It builds from source and runs Gentoo's ebuilds | -| mksh | the shell, login shell and `/bin/sh` | +| mksh | the login shell; `/bin/sh` is busybox's ash | | 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 | -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. +Chamesle is made to be the most UNIX distribution possible, and to run on almost anything: the same base goes on a new +laptop and on a Pentium 4 with 256 MB of memory. It is a system for the tty first. Anything else is a `mag install` away. -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 Where the packages come from -### 1.2 The layout of the system +mag reads two kinds of repository, both signed: + +* Chamesle's own, at `https://chamesle.org/repo`: `chamesle-base` (Winchester, `/etc/rc`, the services, the tools of this + book and the keys), `mag` and `rifle` +* a large musl repository with everything else: the kernel, the firmware, the libraries, editors, compilers, X, about + 28,000 packages for x86_64 + +Both are in `/etc/mag/repos`. A package is checked against the keys in `/etc/mag/keys` before anything of it is unpacked. + +### 1.3 The layout of the system /bin /sbin /lib /lib holds the musl loader and the firmware - /usr/bin /usr/sbin programs, /usr/lib libraries, /usr/share data, /usr/include headers + /usr/bin /usr/sbin programs, /usr/lib libraries, /usr/share data /usr/local/bin yours, first in PATH - /boot kernel, config, System.map, limine.conf (on the EFI partition) - /etc configuration + /boot kernel, initramfs, limine.conf (on the EFI partition) + /etc configuration; /etc/mag is mag's /lib/modules kernel modules, one directory per kernel version - /lib/firmware firmware for the hardware, zstd compressed - /var/db/pkg which package owns which file - /var/cache/distfiles downloaded sources + /lib/firmware firmware for the hardware + /var/lib/mag which package owns which file + /var/cache/mag downloaded indexes and packages /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`. - -### 1.3 Where the sources are +### 1.4 Where the sources are | directory | what is in it | |-----------|---------------| -| `system/` | `tools/` (`chamesle-bootstrap`, `chamesle-chroot`, `chamesle-disk`), `files/` (init, rc and the services), `iso/`, this handbook | -| `SimplePackagemAnagingSystem/` | SPAS: the Rust source of `hoard`, and `src/ebuild.sh`, the environment ebuilds run in | +| `system/` | `tools/` (`chamesle-bootstrap`, `chamesle-chroot`, `chamesle-disk`, and `mkapk`, `mkrepo`, `mkpkgs` for the repo), `files/` (init, rc and the services), `pkg/`, `keys/`, `iso/`, this handbook | +| `mag/` | `mag.c`, `c.h`, `build.sh` | | `rifle/` | `rifle.c`, `build.sh`, `tests/run.sh` | -| Gentoo | the ebuild tree, which `hoard sync` fetches (chapter 2) | -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. +They are on github.com/tortr-rs. ## 2. Preparing -### 2.1 What the build host needs - -Chamesle is built from a running Linux machine: any distribution, or the live ISO of chapter 8. The host needs: - -* `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 -* `tar` and a POSIX `sh` -* `sfdisk`, `mkfs.ext4` and `mkfs.fat` to prepare the disk -* `blkid` to read UUIDs - -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 SPAS and rifle - -rifle is a single C file with no libc under it: - - cd $HOME/src/rifle && ./build.sh - -`rifle/build.sh` leaves `./rifle` and a `bin/` directory with a link for every tool. SPAS is a Rust program, and builds the `hoard` command. For a -system on musl it is built for the musl target, as a static binary: - - 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.1 What you need -The releases of SPAS have a binary for glibc machines, which is what a Gentoo host uses to start with. +* the ISO, from chamesle.org, written to a stick or a disc (chapter 8). It has everything chapter 3 uses +* a network connection: the packages come from the repositories +* about 1 GB of disk for a base system with a kernel, more for what you add +* 256 MB of memory is enough to install and to run -### 2.3 Getting the Gentoo tree +The CPU can be x86_64, or a 32-bit x86 one from the Pentium 4 on (section 3.10). - 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 +### 2.2 From another Linux -`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. +The ISO is the easy way, but any Linux machine can install Chamesle. It needs `mag`, the keys and the repos: -### 2.4 The profile + curl -LO https://chamesle.org/repo/x86_64/mag-0.3.apk + tar -xzf mag-0.3.apk usr/bin/mag + mkdir -p /etc/mag + cp -R keys /etc/mag/keys + cp pkg/chamesle-base/repos /etc/mag/repos + install -m755 usr/bin/mag /usr/local/bin/mag -The profile says what a package is built for. Chamesle uses the musl one, and `make.profile` is a link to it: +`keys/` and `pkg/chamesle-base/repos` are in `system/` of the sources. The `tar` line warns about the signature and +control parts it does not know; the program comes out all the same. mag is static, so it runs on any distribution. +From there chapter 3 is the same, without the live system. - ln -sfn /var/db/repos/gentoo/profiles/default/linux/amd64/23.0/musl /etc/spas/make.profile +### 2.3 Getting on the network -`--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. +On the live system a cable works by itself: `dhcpcd` runs at boot. Check it with -### 2.5 make.conf + ip addr + ping -c 3 chamesle.org -`/etc/spas/make.conf` holds the build settings, and section 4.4 has what goes in it. The stage has one. For the host you build from, make one yourself: +For wireless, `iwctl` (iwd runs at boot on the ISO): - CFLAGS="-O2 -pipe -std=gnu17" - CXXFLAGS="${CFLAGS}" - MAKEOPTS="-j8" + iwctl device list + iwctl station wlan0 scan + iwctl station wlan0 get-networks + iwctl station wlan0 connect NAME -`-std=gnu17` matters. clang defaults to C23 now, and a lot of older source does not compile under it (section 9.3). +It asks for the passphrase. dhcpcd gives the interface an address once it is connected. ## 3. Installing by hand Follow the BIOS or the UEFI variant where they differ. The disk here is `/dev/sda`; change it to yours. Everything below -is run as root on the machine you install from, usually the live ISO, and it erases the disk. +is run as root on the live system, and it erases the disk. There are two ways through 3.1 and 3.2: `chamesle-disk` does the partitioning and the file systems and leaves the -root on ZFS, or you do both yourself. From 3.3 on the steps are the same, and they are yours: `chamesle-disk` is only a helper. +root on ZFS, or you do both yourself with the root on ext4. From 3.3 on the steps are the same, and they are yours: +`chamesle-disk` is only a helper. ### 3.1 chamesle-disk @@ -161,11 +147,12 @@ the root. Then it does, in this order: zpool set bootfs=rpool/root rpool and mounts `rpool/root`, `rpool/home` and `rpool/var` under `/mnt` and the boot partition on `/mnt/boot`. It also writes -`/mnt/etc/fstab` with the boot partition by UUID and the `proc`, `sysfs` and `tmpfs` lines (an existing one is left alone). It writes nothing else: no -`limine.conf`, no host name, no password. Those are 3.7 and 3.8. +`/mnt/etc/fstab` with the boot partition by UUID and the `proc`, `sysfs` and `tmpfs` lines. It writes nothing else. -ZFS mounts its own datasets, so the fstab does not list them. limine cannot read ZFS: the kernel, the initrd and -`limine.conf` live on the FAT partition, which is `/boot`, and the initramfs imports the pool (3.8). +ZFS mounts its own datasets, so the fstab does not list them. limine cannot read ZFS: the kernel, the initramfs and +`limine.conf` live on the FAT partition, which is `/boot`. + +ZFS on a machine with little memory is slow; on the 256 MB machine use ext4 (3.2). ### 3.2 Partitioning and file systems by hand @@ -187,101 +174,42 @@ On an NVMe disk the partitions are `/dev/nvme0n1p1` and so on. Replace `sda1`, ` mount /dev/sda2 /mnt/boot The FAT partition is `/boot`. The kernel and `limine.conf` end up there, where limine looks for them on both BIOS and -UEFI. The root can be ZFS by hand as well: the `zpool` and `zfs` lines of 3.1 are all there is to it. +UEFI. + +### 3.3 chamesle-bootstrap -### 3.3 Unpacking the stage + chamesle-bootstrap /mnt -The system comes as a stage tarball, as on Gentoo: a root with the base already in it. rifle, mksh, Winchester, musl, gcc, -python, perl, gettext, `hoard` and its records of what is installed (`/var/db/pkg`) are all inside. Nothing is compiled -until you ask hoard for something. It is on the releases page of github.com/tortr-rs/chamesle, with its `.sha256`. Check the tarball against its `.sha256` and unpack it: +That is the whole base. It copies `/etc/mag/repos` and `/etc/mag/keys` of the live system into `/mnt`, runs +`mag update` there, and installs `chamesle-base`, the kernel (`linux-lts`) and its firmware with everything they need. The +kernel package writes `vmlinuz-lts` and `initramfs-lts` into `/mnt/boot`. It takes as long as the download, a few minutes. - sha256sum -c chamesle-stage-20261117.tar.xz.sha256 - tar -C /mnt --exclude ./etc/fstab -xpf chamesle-stage-20261117.tar.xz -[ -e /mnt/etc/fstab ] || tar -C /mnt -xpf chamesle-stage-20261117.tar.xz ./etc/fstab + chamesle-bootstrap [-a ARCH] [-n HOSTNAME] [-k KERNEL] [-f FIRMWARE] TARGET [PACKAGE]... -Make the directories the stage leaves out: +| option | what | +|--------|------| +| `-n` | the host name, `chamesle` if not given | +| `-f` | the firmware package. The default, `linux-firmware-none`, has no firmware; take the one your hardware needs (7.4) | +| `-k` | the kernel package, `linux-lts` if not given | +| `-a` | the architecture, the machine's own if not given (3.10) | - mkdir -p /mnt/proc /mnt/sys /mnt/dev /mnt/run /mnt/tmp /mnt/var/tmp /mnt/var/log /mnt/var/cache /mnt/home - chmod 1777 /mnt/tmp /mnt/var/tmp +Packages after the target go in too. A ThinkPad with Intel wireless and graphics, with an editor: -Keep `-p`: the modes and the owners matter. `/boot`, `/home`, `/proc`, `/sys`, `/dev`, `/run`, `/tmp`, `/var/cache`, `/var/log` and the -Gentoo tree are not in the stage: the first are yours, the tree comes from `hoard sync` (section 2.3). The fstab chamesle-disk -wrote is left alone, the stage's own is only used if there is none (3.6). The kernel -and the initrd come from the ISO: + chamesle-bootstrap -n t480 -f linux-firmware-intel /mnt vim - cp /run/live/medium/boot/initrd /mnt/boot/initrd - cp /run/live/medium/boot/vmlinuz-* /mnt/boot/ +What `chamesle-base` brings: Winchester and the files of chapter 6, mag, rifle, mksh, busybox for the tools rifle does not +have, `agetty`, eudev, kmod, dhcpcd, e2fsprogs and curl. -Work inside the new root with `chamesle-chroot`: +### 3.4 Working inside the new root chamesle-chroot /mnt chamesle-chroot /mnt passwd root It mounts `proc`, `sys`, `dev`, `dev/pts` and a tmpfs on `run` under the directory, copies `/etc/resolv.conf` into it, runs -`chroot` with an empty environment (`HOME=/root`, `TERM`, `PATH`) and takes the mounts away again when the command ends. Without a command it -starts `/usr/bin/mksh -l`. - -Inside, fetch the tree and install what you want: - - hoard sync - hoard install -y -j4 --keep-going app-editors/vim - -The stage's `/etc/spas/make.conf` builds with gcc (`CC=gcc`, `CXX=g++`) for `x86_64-pc-linux-musl` and the musl profile. Its -`/etc/spas/profile/package.provided` lists what the stage already has, so hoard does not build those again: `musl`, -`baselayout`, `util-linux`, `libunistring`, `make`, `m4`, `linux-headers`, `e2fsprogs`, `gettext` and a few others. `--resume` goes -on after a failed build. Then go on with 3.6 (fstab) and the rest. - -### 3.4 Building the stage - -You do not need this to install. It is how the stage is made. Start from a Gentoo musl stage3, whose gcc, binutils, python, perl -and gettext are binaries, check its digest, and take from it the files each package lists in `/var/db/pkg/*/*/CONTENTS`, plus the -`/var/db/pkg` directories themselves so hoard knows they are installed. Put rifle, mksh, Winchester, the files in -`files/` and a `hoard` built for musl on top, write `make.conf` and `package.provided`, build whatever else the base needs with -hoard, and pack the root: - - tar -C ROOT -cpf - --exclude=./proc --exclude=./sys --exclude=./dev --exclude=./run --exclude=./tmp \ - --exclude=./boot --exclude=./home --exclude=./var/tmp --exclude=./var/cache --exclude=./var/log \ - --exclude=./var/db/repos . | xz -T0 > chamesle-stage-20261117.tar.xz - -GNU patch is the one thing the stage3 does not give, and it is built from source. - -### 3.5 The other stages - -There are four stages. The unpacking in 3.3 is the same for all of them; only the tarball differs. +`chroot` with an empty environment (`HOME=/root`, `TERM`, `PATH`) and takes the mounts away again when the command ends. +Without a command it starts `/bin/mksh -l`. Inside, `mag install name` works as on the finished system. -| tarball | libc | what is in it | -|---------|------|---------------| -| `chamesle-stage-DATE` | musl | the base of 3.3: rifle, mksh, Winchester, gcc, SPAS, sam | -| `chamesle-stage-graphical-DATE` | musl | the base, plus X, 9wm, sxhkd, dmenu, and plan9port with 9term and acme | -| `chamesle-stage-glibc-DATE` | glibc | Gentoo's glibc userland (GNU coreutils stay), with Winchester, mksh, SPAS, rifle and sam | -| `chamesle-stage-glibc-graphical-DATE` | glibc | the glibc stage, plus the same graphical set | - -Pick the libc by what you want to run. musl is Chamesle's own; glibc is for programs that only come as binaries for glibc. -SPAS reads the profile in `/etc/spas/make.profile`, which is the musl profile in the musl stages and the plain one in the -glibc stages. - -#### The graphical stages - -On the first boot the login on tty1 is `chamesle-session`, not a shell. It starts X, and X starts `9wm`, which is the -window manager that looks and works like rio: the right button makes windows (New, Reshape, Move, Delete, Hide), and -text is selected and cut by chording the mouse buttons. A `9term` is open when it comes up, with `plumber` behind it. -When X ends you land in `mksh`. The login is `root` with no password until you set one (3.7). - -`sxhkd` carries the keys of the dwm setup that make sense without tags (`/etc/sxhkd/sxhkdrc`): - -| key | does | -|-----|------| -| Super+t, Super+Shift+Return | a new `9term` | -| Super+d | `dmenu_run` | -| Super+a | `acme` | -| Super+e | `sam` in a `9term` | -| Super+Shift+q | ends the session (kills `9wm`) | -| volume and brightness keys | `amixer` and `brightnessctl` | - -`EDITOR` is `sam -d` there too. Everything is a file to change: `/etc/X11/xinit/xinitrc` is the session, and -`getty-tty1` in `/etc/init.conf` is what starts it. Take that line out to go back to a plain login. - -### 3.6 fstab +### 3.5 fstab If you used chamesle-disk the file is written. Look at it: the boot partition by UUID on `/boot`, then `proc`, `sysfs` and `tmpfs`, and nothing for the ZFS datasets, because ZFS mounts them itself. @@ -290,57 +218,51 @@ By hand, `blkid` prints the UUIDs: blkid /dev/sda2 /dev/sda3 -Open `/mnt/etc/fstab` and add the root and boot lines under the `proc`, `sysfs` and `tmpfs` lines already there: - - UUID=ROOT-UUID / ext4 defaults 0 1 - UUID=BOOT-UUID /boot vfat defaults 0 2 - -A root on ZFS gets only the boot line. Check that the UUID is the one `blkid` shows for the boot partition. - -### 3.7 Host name, users, password - -The host name is already in `/mnt/etc/init.conf` from `-n`. The root account is in `/mnt/etc/passwd` with an `x` in the -password field, and there is no shadow file, so the hash goes into that field. Make one on any machine that has -openssl, SHA-512: +Write `/mnt/etc/fstab`: - openssl passwd -6 + UUID=ROOT-UUID / ext4 defaults 0 1 + UUID=BOOT-UUID /boot vfat defaults 0 2 + proc /proc proc defaults 0 0 + sysfs /sys sysfs defaults 0 0 + tmpfs /tmp tmpfs nosuid,nodev 0 0 -Put the output in the second field of the root line: +A root on ZFS gets no root line. - root:$6$salt$hash:0:0:root:/root:/usr/bin/mksh +### 3.6 Host name and password -musl's `crypt` reads `$6$` hashes. An empty field means no password at all. +The host name is in `/mnt/etc/init.conf`, from `-n`. Set the root password: -The groups are `root`, `wheel` (10) and `users` (100). More accounts are lines in `passwd` and `group` and a home -directory you make (section 6.5). + chamesle-chroot /mnt passwd root -### 3.8 The kernel and the boot entry +The hash goes into `/etc/shadow`. The login shell of root is mksh. -The kernel package put these in `/mnt/boot` (the version number is whatever the recipe carries): +### 3.7 The boot entry ls /mnt/boot - config-6.18.63-0-lts System.map-6.18.63-0-lts vmlinuz-6.18.63-0-lts + System.map-6.18.64-0-lts config-6.18.64-0-lts initramfs-lts vmlinuz-lts -Write `/mnt/boot/limine.conf` with the file name you see and the UUID of the root partition: +The names stay the same when the kernel is updated, so `limine.conf` is written once. `/mnt/boot/limine.conf`, with +the UUID of the root partition: timeout: 3 /Chamesle protocol: linux - path: boot():/vmlinuz-6.18.63-0-lts - module_path: boot():/initrd - cmdline: root=UUID=ROOT-UUID rw console=tty0 + path: boot():/vmlinuz-lts + module_path: boot():/initramfs-lts + cmdline: root=UUID=ROOT-UUID modules=sd-mod,usb-storage,ext4 rootfstype=ext4 quiet + +`boot()` is the partition `limine.conf` is on, which is `/boot`. The initramfs finds the root, loads the modules on the +command line and starts `/sbin/init`. Take `quiet` out to see the kernel's messages. For a serial console add +`console=ttyS0,115200`. -For a root on ZFS the command line names the dataset, there is no UUID: +A root on ZFS names the dataset; the initramfs needs the zfs module, which is section 7.5: - cmdline: root=ZFS=rpool/root rw console=tty0 + cmdline: root=ZFS=rpool/root rootfstype=zfs quiet -`boot()` is the partition `limine.conf` is on, which is `/boot`; with ZFS it is the FAT partition, since limine cannot read -ZFS. The kernel has ext4 and the disk drivers as modules, so -the system needs the initramfs. The one from the ISO (`/mnt/boot/initrd`, copied in 3.3) finds the root by `root=UUID=` or -`root=ZFS=` and loads the modules in `iso/profile/modules`. Section 7.5 says how to make your own. +Install limine. `limine` is a package; install it into the new root, or use the one of the live system: -limine's files are in `/mnt/usr/share/limine`. + chamesle-chroot /mnt mag install limine #### BIOS @@ -359,7 +281,7 @@ The firmware starts `EFI/BOOT/BOOTX64.EFI` of the EFI System partition by itself Do both and the disk boots either way. -### 3.9 First boot +### 3.8 First boot umount -R /mnt zpool export rpool @@ -368,145 +290,101 @@ Do both and the disk boots either way. Leave out `zpool export` if the root is not on ZFS. Take out the installation medium. limine shows the entry for three seconds and boots the kernel. `init` runs `/etc/rc`, which mounts the -file systems and starts the services of `init.conf`, and puts a login on the ttys. Log in as root. - -Then: - -1. Bring the network up (section 6.7). -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 SPAS - -SPAS is the package manager, and its command is `hoard`. 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 - - 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 - - hoard install app-editors/vim - hoard install -p app-misc/fastfetch what would be built, nothing is done - hoard remove vim +file systems and starts the services of `init.conf`, and puts a login on the ttys. Log in as root. `dhcpcd` brings up a +cable at boot; for wireless see section 6.8. -`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. +### 3.9 What to install next -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. + mag install vim htop tmux + mag search irc -### 4.3 Where it keeps things +Chapter 4 has the rest. -| 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` | +### 3.10 32-bit machines -If there is no `/etc/spas`, hoard reads `/etc/portage` instead, so a machine that has Portage's files is understood as it is. +On a 32-bit PC (Pentium 4, Athlon XP and the like) boot the ISO on another machine, or install from any Linux there +(2.2), and give the architecture: -### 4.4 make.conf + chamesle-bootstrap -a x86 /mnt -`/etc/spas/make.conf` holds the build settings, in the shell syntax of Portage's: +The x86 repository has the same packages, built for i686 with SSE2. `-a x86` is written to `/mnt/etc/mag/arch`, and mag +keeps to it from then on. `rifle` is only built for x86_64, so on x86 busybox gives the coreutils. limine boots 32-bit +BIOS machines as well; the entry is the same. - 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" -* `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` +## 4. mag -`-std=gnu17` matters. clang defaults to C23 now, and a lot of older source does not compile under it (section 9.3). +mag is the package manager. It installs binary packages from the repositories in `/etc/mag/repos`, checks every index +and every package against `/etc/mag/keys`, and keeps what it installed in `/var/lib/mag`. It is one C file and runs +nothing but the download command. -### 4.5 Repositories +### 4.1 The commands -`/etc/spas/repos.conf/gentoo.conf` names the tree and where it comes from: + mag update get the index of every repo + mag install PKG... install, with what they need + mag remove PKG... take packages off + mag upgrade install what the repos have a newer version of + mag autoremove remove what was only a dependency and is not needed now + mag list what is installed + mag info PKG version, size, description, and whether it is installed + mag search WORD names and descriptions + mag files PKG the files a package put on the system + mag owns PATH which package a file came from + mag deps PKG what it needs; rdeps PKG for what needs it + mag fetch PKG... only download them + +`-n` says what would happen and does nothing, `-f` goes on when files clash or something still needs a package. +`MAG_ROOT=/mnt mag ...` works on another root, which is what chamesle-bootstrap does. - [gentoo] - location = /var/db/repos/gentoo - sync-type = git - sync-uri = https://github.com/gentoo-mirror/gentoo.git +### 4.2 Installing and removing -`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 install vim + mag -n install xorg-server what would come with it + mag remove vim -### 4.6 USE flags and keywords +Before it unpacks anything, mag checks each file against what other packages own and stops if two packages want the same +file. A file under `/etc` that you changed stays, and the new one is written next to it as `NAME.new`. Packages carry +scripts that run after they are installed, and triggers that run when a directory they watch changes, like the one +that makes the initramfs when a kernel is installed. -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. +A name can also be what a package provides: `mag install cmd:htop` installs the package that has the command. - 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 +### 4.3 Where it keeps things -### 4.7 Binary packages +| what | where | +|------|-------| +| the repositories | `/etc/mag/repos`, one URL a line | +| the keys | `/etc/mag/keys` | +| the architecture | `/etc/mag/arch` | +| installed packages | `/var/lib/mag/NAME/`: `version`, `files`, `deps`, `explicit` and the scripts | +| indexes and downloads | `/var/cache/mag` | -`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. +### 4.4 Repositories -### 4.8 Writing an ebuild + https://chamesle.org/repo + https://dl-cdn.alpinelinux.org/alpine/v3.24/main + https://dl-cdn.alpinelinux.org/alpine/v3.24/community -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`: +Each line is the URL above the directory of the architecture: mag adds `/x86_64/APKINDEX.tar.gz`. A repository you +add needs its key in `/etc/mag/keys`. `mag update` after any change. - 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" +### 4.5 Making a package - src_install() { - emake PREFIX="${EPREFIX}/usr" DESTDIR="${D}" install - } +`tools/mkapk` packs a directory, signs it and leaves its index entry; `tools/mkrepo` signs the index of a directory of +them: -`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. + mkapk -k KEY -n hello -v 1.0 -a x86_64 -d "says hello" -D "musl" -o repo/x86_64 ./root + mkrepo repo/x86_64 KEY +Put the public half of KEY in `/etc/mag/keys` and the repo's URL in `/etc/mag/repos`. `tools/mkpkgs` is how Chamesle's +own repo is made. ## 5. rifle ### 5.1 What it is -rifle is the coreutils of Chamesle in one C file, `rifle.c`, on `c.h`, a one-file libc. It has no GNU code in it and no +rifle is the coreutils of Chamesle on x86_64 in one C file, `rifle.c`, on `c.h`, a one-file libc. It has no GNU code in it and no libc under it. It sorts and compares by bytes, always; there are no locales. There is one program. `cat`, `ls`, `cp` and the other commands are links to it, and it runs whichever name it was @@ -539,6 +417,8 @@ Not there yet: `stty`, `who` and friends, `fmt`, `pr`, `csplit`, `numfmt`, `shre ### 5.3 Building +The `rifle` package has it built. From the sources: + cd $HOME/src/rifle ./build.sh @@ -557,8 +437,6 @@ 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. -SPAS has tests of its own, in its sources (`cargo test`). - ## 6. The base system @@ -600,11 +478,10 @@ lines are ignored, spaces around `=` are free. A list is in braces and may go ov hostname = chamesle # started in this order at boot, stopped in reverse at shutdown - #boot-services = {NetworkManager,LightDM,dbus} boot-services = {udev,modules,network} modules = {} - ttys = {tty1,ttyS0} + ttys = {tty1,tty2,tty3,tty4,tty5,tty6,ttyS0} getty = agetty --noclear $tty linux getty-ttyS0 = agetty -L $tty 115200 vt100 @@ -621,8 +498,8 @@ The parser is `conf` in `/etc/init.sh`; `conf KEY` prints the value, with a list `ttys` or `getty` takes effect at the next boot. A service is an executable file in `/etc/rc.d` (or `/usr/local/etc/rc.d`, for the ones you add) that takes -`start`, `stop`, `restart` or `status`. The base set has three: `udev` (starts `udevd`, replays the devices and waits -for them), `modules` and `network` (`dhcpcd`). A name in `boot-services` without a script is skipped with one line +`start`, `stop`, `restart` or `status`. The base set has `udev` (starts `udevd`, replays the devices and waits +for them), `modules`, `network` (`dhcpcd`), and `dbus`, `iwd` and `NetworkManager` for when those packages are installed. A name in `boot-services` without a script is skipped with one line saying so. `service` is the way to run them: @@ -655,71 +532,63 @@ once (`now`) or after `+minutes`, with an optional message sent through `wall`: | file | what it holds | |------|---------------| -| `passwd`, `group` | accounts and groups; no shadow file, the hash is in `passwd` | -| `shells` | `/bin/sh`, `/usr/bin/mksh`, `/usr/bin/ksh` | +| `passwd`, `shadow`, `group` | accounts, password hashes, groups | +| `shells` | the login shells; `/bin/mksh` is one | | `init.conf` | host name, boot services, modules, ttys (6.2) | -| `fstab` | `proc`, `sysfs`, `tmpfs` on `/tmp`, plus the lines you add | -| `profile` | `PATH`, `EDITOR="sam -d"`, `PAGER=less`, `umask 022` | +| `fstab` | the file systems (3.5) | +| `profile` | `PATH`, `PAGER`, `umask 022`, and `/etc/profile.d/*.sh` | | `os-release` | `NAME=Chamesle`, `ID=chamesle` | -| `make.conf` | `MAKEOPTS` and `CFLAGS` for hoard | -| `skel/` | empty directory for the files new homes start from | +| `mag/` | the repos, the keys and the architecture (4.3) | +| `skel/` | 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 `ENV=$HOME/.mkshrc` in `/etc/profile`. ### 6.5 Users -There is no `useradd`. To add `alice`: + adduser alice + adduser alice wheel - echo 'alice:HASH:1000:1000:alice:/home/alice:/usr/bin/mksh' >> /etc/passwd - echo 'alice:x:1000:' >> /etc/group - mkdir /home/alice - chown 1000:1000 /home/alice - -`HASH` comes from `openssl passwd -6` on a machine that has it. To put alice in `wheel`, add her name to the last field -of the `wheel:x:10:` line. +`adduser` makes the account, the group and the home, and asks for the password; `passwd alice` changes it. +`deluser alice` takes the account away. For `doas` or `sudo`, `mag install` them and give `wheel` the right in their file. ### 6.6 udev and modules -eudev is the udev. `udevd` gives devices their nodes in `/dev` and loads the modules the hardware needs. eudev is built -without the hardware database (`--disable-hwdb`). +eudev is the udev. `udevd` gives devices their nodes in `/dev` and loads the modules the hardware needs. kmod provides `modprobe`, `insmod`, `rmmod`, `lsmod`, `modinfo` and `depmod`. A kernel's modules are in `/lib/modules/VERSION`. To load one by hand: `modprobe name`. To load one at every boot, put its name in `modules` of `/etc/init.conf`. To keep one from loading, put `blacklist name` in a file in `/etc/modprobe.d/`. ### 6.7 Networking -`dhcpcd` is the DHCP client and is in the base set. For a wired interface: - - 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: +`dhcpcd` is the DHCP client and is in the base set. It is the `network` service, in `boot-services` by default, and takes +every interface, so a cable is up at boot. `ip` lists them: - hoard install sys-apps/iproute2 + ip addr + ip link set eth0 up A static address: ip addr add 192.168.1.10/24 dev eth0 - ip link set eth0 up ip route add default via 192.168.1.1 echo 'nameserver 192.168.1.1' > /etc/resolv.conf +and take `network` out of `boot-services`. + ### 6.8 Wireless -`iw` talks to the kernel's nl80211. It is in Gentoo's tree, with libnl: +The card needs its firmware (7.4). Then iwd: - hoard install net-wireless/iw - iw dev the wireless interfaces - ip link set wlan0 up - iw dev wlan0 scan | grep SSID + mag install iwd dbus -`sys-firmware/wireless-regdb` (in the base set) has the regulatory database, and the card's firmware is in -`/lib/firmware` from `sys-kernel/linux-firmware`. If `dmesg` says a firmware file failed to load, check that it is -there. +and put `dbus` and `iwd` in `boot-services` before `network`: -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`. + boot-services = {udev,modules,dbus,iwd,network} + +`service dbus start`, `service iwd start` to have them now. `iwctl` connects, the same as on the ISO (2.3), and remembers +the network. dhcpcd gives it an address. + +`wpa_supplicant` works too, for those who know it: `mag install wpa_supplicant`. ### 6.9 Mounting and disks @@ -727,8 +596,8 @@ interface. Then `dhcpcd wlan0`. mount -t vfat -o ro /dev/sdb1 /mnt/usb umount /mnt/usb -`mount`, `umount`, `lsblk`, `blkid`, `sfdisk`, `fdisk` and `cfdisk` are util-linux's, `zpool` and `zfs` are OpenZFS's, `mkfs.ext4` and `fsck.ext4` are -e2fsprogs', `mkfs.fat` is dosfstools'. +`mount` and `umount` are busybox's; `lsblk`, `blkid`, `sfdisk` and `cfdisk` are packages of their own, `mkfs.ext4` and +`fsck.ext4` are e2fsprogs', `mkfs.fat` is dosfstools', `zpool` and `zfs` are `zfs`. On a ZFS root, `/etc/rc` runs `zfs mount -a` right after `mount -a`, which mounts `rpool/home` and `rpool/var`; the root itself was mounted by the initramfs. @@ -738,101 +607,80 @@ mounted by the initramfs. ### 7.1 The kernel package -Nobody builds a kernel in Chamesle. `sys-kernel/linux` is a prebuilt Linux 6.18 LTS kernel with its modules, taken from a -binary mirror, with a generic configuration that runs on most machines. The recipe unpacks the package and installs +Nobody builds a kernel in Chamesle. `linux-lts` is a Linux 6.18 LTS kernel with a generic configuration that runs on +most machines, and it installs - /boot/vmlinuz-VERSION + /boot/vmlinuz-lts /boot/config-VERSION /boot/System.map-VERSION /lib/modules/VERSION/ -`VERSION` is the one the package carries, such as `6.18.63-0-lts`. `sys-kernel/linux-headers` has the headers the libc -and util-linux build against. +`linux-virt` is a smaller one for virtual machines. Give it to chamesle-bootstrap with `-k`, and name its files in +`limine.conf` (`vmlinuz-virt`, `initramfs-virt`). ### 7.2 Updating -The mirror drops a package when a newer one comes out, so a new kernel is a new `version` and `sha256` in the recipe. -Edit `repo/sys-kernel/linux`: - - version: 6.18.64 - sha256: the new one - -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`: - - hoard install sys-kernel/gentoo-sources + mag update + mag upgrade -and add an entry in `/boot/limine.conf` for the new `vmlinuz-VERSION`. Keep the old one until the new one has booted: - - /Chamesle - protocol: linux - path: boot():/vmlinuz-NEW - cmdline: root=UUID=ROOT-UUID rw - - /Chamesle (old) - protocol: linux - path: boot():/vmlinuz-OLD - cmdline: root=UUID=ROOT-UUID rw - -After a reboot, `uname -r` says what runs. +A new `linux-lts` replaces `vmlinuz-lts` and makes `initramfs-lts` again, so `limine.conf` needs no change. Reboot to +run it; `uname -r` says what runs. Keep the ISO at hand in case a new kernel does not boot. ### 7.3 Modules -Modules are `.ko` files in `/lib/modules/VERSION`. `lsmod` shows what is loaded, `modprobe name` loads a module with what +Modules are files in `/lib/modules/VERSION`. `lsmod` shows what is loaded, `modprobe name` loads a module with what it needs, `modinfo name` describes it. udev loads the ones the hardware asks for. Modules belong to one kernel build: -after installing a new kernel, reboot before loading any. +after an upgrade of the kernel, reboot before loading any. ### 7.4 Firmware - hoard install sys-kernel/linux-firmware +The firmware is split by vendor, so a machine takes only what it uses: -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 -release is a new `version` and `sha256` in `repo/sys-kernel/linux-firmware`, the same way as the kernel's. +| package | for | +|---------|-----| +| `linux-firmware-intel` | Intel wireless (iwlwifi), Bluetooth and the rest of the intel folder | +| `linux-firmware-i915` | Intel graphics | +| `linux-firmware-amdgpu`, `linux-firmware-radeon` | AMD graphics | +| `linux-firmware-rtlwifi`, `linux-firmware-rtw88`, `linux-firmware-rtw89`, `linux-firmware-rtl_nic` | Realtek wireless and ethernet | +| `linux-firmware-ath10k`, `linux-firmware-ath11k`, `linux-firmware-ath9k_htc` | Qualcomm Atheros wireless | +| `linux-firmware-brcm` | Broadcom wireless | +| `linux-firmware` | all of them, over 500 MB | +| `linux-firmware-none` | none | -### 7.5 An initramfs +`mag search linux-firmware` lists them. If `dmesg` says a firmware file failed to load, `mag owns` is no help yet, since +it is not installed; the name of the file says the vendor. -A root on ext4 on a common disk (SATA, NVMe, virtio, USB storage) needs none. A root on ZFS needs one: the pool has to be -imported before the root can be mounted. A root that needs a module to be reached, or -RAID, LVM or an encrypted disk, does. +### 7.5 The initramfs -`iso/mkinitramfs` makes one, and the live ISO uses it: +The kernel package makes `/boot/initramfs-lts` with `mkinitfs` whenever the kernel is installed or updated. What goes into +it is set in `/etc/mkinitfs/mkinitfs.conf`: - mkinitramfs [-m modules-file] ROOTFS KVER OUT + features="ata base cdrom ext4 keymap kms mmc nvme raid scsi usb virtio" -`ROOTFS` is the root whose `/lib/modules` and programs are used, `KVER` the name of the kernel's directory in -`/lib/modules`, `OUT` the file to write. It puts in a few tools (`sh mount umount switch_root insmod mkdir sleep blkid`, and `zpool` when the root has it, -with the libraries they need), the modules named in the modules file together with what they depend on, and `iso/init`. -The names after a `[zfs]` line of the modules file go into a second list, which `iso/init` loads only for `root=ZFS=`. -The result is a zstd compressed cpio. +For a root on ZFS add `zfs` to the list, install `zfs` and `zfs-lts`, and make it again: - $HOME/src/system/iso/mkinitramfs -m modules /mnt 6.18.63-0-lts /mnt/boot/initrd + mag install zfs zfs-lts + mkinitfs $(ls /lib/modules) -`iso/init` mounts `proc`, `sysfs` and `devtmpfs`, loads the modules, reads `root=` from the command line (`root=UUID=...` -or a device), waits up to 15 seconds for the device, mounts it read-only at `/mnt/root`, and runs -`switch_root /mnt/root /sbin/init`. With `root=ZFS=rpool/root` it loads the zfs modules, runs `zpool import -N -d /dev rpool` -(until it works, 15 seconds at most) and mounts the dataset with `mount -o zfsutil -t zfs`. If anything fails it prints why and drops into a shell. +The initramfs reads `root=`, `rootfstype=` and `modules=` from the command line, mounts the root and starts `/sbin/init`. +If it cannot, it says why and gives a shell. -Name the initrd in `limine.conf`: - - /Chamesle - protocol: linux - path: boot():/vmlinuz-6.18.63-0-lts - module_path: boot():/initrd - cmdline: root=UUID=ROOT-UUID rw - -On ZFS the command line is `root=ZFS=rpool/root rw`. The ZFS module is `sys-kernel/zfs-module`, for the kernel of -`sys-kernel/linux`: when one is updated the other has to be too, and `depmod` has to run after installing it. +The live ISO has its own initramfs, made by `iso/mkinitramfs`, which mounts the squashfs (chapter 8). ## 8. The live ISO ### 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, 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. +The ISO is a live system to work from. It boots on BIOS and UEFI machines with limine, from a disc or a stick, logs in as +root on every tty and has + +* mag, the keys and the repos, and `chamesle-bootstrap`, `chamesle-chroot`, `chamesle-disk` +* the disk tools: `cfdisk`, `sfdisk`, `lsblk`, `blkid`, `mkfs.ext4`, `mkfs.fat`, `zpool`, `zfs`, `limine` +* the network: `dhcpcd`, `iwd` with `iwctl`, `wpa_supplicant`, `curl` +* the Intel wireless firmware, vim, less, and this handbook in `/usr/share/doc/chamesle/handbook.md` + +It is where you do chapter 3. `chamesle.iso` is for x86_64, `chamesle-x86.iso` for 32-bit machines (BIOS only). ### 8.2 How it boots @@ -841,82 +689,70 @@ mounts and has `LiveOS/rootfs.sfs`. It mounts that squashfs read-only, puts a tm the squashfs to `/run/live/medium` and `/run/live/rootfs`, and runs `switch_root` into the result. Whatever you change in the live system is gone at shutdown. -### 8.3 Trying it in qemu +### 8.3 Making it + + iso/mkiso -o chamesle.iso + iso/mkiso -a x86 -o chamesle-x86.iso + +as root, with mag in PATH, and `xorriso`, `mksquashfs`, `zstd` and `bsdcpio` on the host. mkiso installs +`chamesle-base`, the kernel and what `iso/profile/packages` names into `work/rootfs` with mag, copies +`iso/profile/overlay` over it, makes the initramfs and the squashfs and puts them on the ISO with limine. + +### 8.4 Trying it in qemu BIOS: - qemu-system-x86_64 -cpu max -m 1G -cdrom chamesle.iso -boot d + qemu-system-x86_64 -m 1G -cdrom chamesle.iso -boot d UEFI, with the firmware of your qemu (`edk2-x86_64-code.fd`; the path differs between systems): - qemu-system-x86_64 -cpu max -m 1G -bios /usr/share/qemu/edk2-x86_64-code.fd -cdrom chamesle.iso + qemu-system-x86_64 -m 1G -bios /usr/share/qemu/edk2-x86_64-code.fd -cdrom chamesle.iso Add `-enable-kvm` for speed. To go through all of chapter 3 in a virtual machine, give it a disk: - qemu-img create -f qcow2 disk.qcow2 20G - qemu-system-x86_64 -cpu max -m 2G -enable-kvm -cdrom chamesle.iso -drive file=disk.qcow2 -boot d -nic user + qemu-img create -f qcow2 disk.qcow2 8G + qemu-system-x86_64 -m 1G -enable-kvm -cdrom chamesle.iso -drive file=disk.qcow2 -boot d -nic user + +A machine like an old Pentium 4 with 256 MB: `-cpu pentium3,+sse2 -m 256` and the x86 ISO. To write the ISO to a stick: `dd if=chamesle.iso of=/dev/sdX bs=4M conv=fsync`. ## 9. Maintaining -### 9.1 Updating packages +### 9.1 Updating - hoard sync - hoard upgrade -p - hoard upgrade + mag update + mag -n upgrade + mag upgrade -`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`. +The first gets the indexes, the second says what would change, the third does it. ### 9.2 Cleaning up - 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 + mag autoremove dependencies nothing needs any more + rm -rf /var/cache/mag/pkg downloaded packages; they are fetched again when needed -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 -`/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.3 Configuration files -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. +A changed file under `/etc` is never written over. When a package brings a new one, it lands next to yours as +`NAME.new`. Look for them after an upgrade and merge by hand: -### 9.4 Installing into a root + find /etc -name '*.new' -`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. - -### 9.5 Build tools - -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 +### 9.4 Failures you will see | what you see | why, and what to do | |--------------|---------------------| -| `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 | -| 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) | +| `no package NAME` | not in any repo; `mag search`, and `mag update` | +| a signature or hash that does not match | the download or the index is not what the repo signed; `mag update` and try again, check `/etc/mag/keys` | +| `NAME wants FILE, which OTHER has` | two packages want the same file; `-f` writes over it if you are sure | +| "root device not found" at boot | the initramfs cannot see the disk or the file system: check `root=` and `modules=` in `limine.conf` | | the machine boots to a limine prompt | `limine.conf` is not found, or its `path:` does not name a file in `/boot`; check with `ls /boot` | | 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 `hoard list` | - -### 9.7 Keeping a build - -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. +| no wireless interface | the firmware is missing (7.4); `dmesg` names the file | +| no devices in `/dev` | udev did not start; check `udev` is in `boot-services` | ## 10. File reference @@ -928,47 +764,46 @@ checks the sources, and `hoard install --resume` carries on from the phase that | `/sbin/init`, `/etc/rc`, `/etc/rc.shutdown` | init, the boot script, the shutdown script, all run by mksh | | `/etc/init.conf` | host name, boot services, modules, ttys | | `/etc/rc.d/`, `/usr/local/etc/rc.d/` | the service scripts | -| `/etc/services`, `/etc/hosts` | port names and the local host name, the libc reads them | -| `/etc/profile` | `PATH`, `EDITOR`, `PAGER`, `umask` | -| `/etc/passwd`, `/etc/group`, `/etc/shells` | accounts, groups, login shells | +| `/etc/profile` | `PATH`, `umask` | +| `/etc/passwd`, `/etc/shadow`, `/etc/group`, `/etc/shells` | accounts, passwords, groups, login shells | | `/etc/fstab` | file systems | | `/etc/os-release` | `NAME=Chamesle`, `ID=chamesle` | -| `/etc/spas/` | hoard's configuration: `make.conf`, `make.profile`, `repos.conf/`, `package.use` and the rest (section 4.3) | +| `/etc/mag/` | `repos`, `keys/`, `arch` | +| `/etc/mkinitfs/mkinitfs.conf` | what goes into the initramfs | | `/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 | +| `/boot/vmlinuz-lts`, `initramfs-lts` | the kernel and its initramfs | | `/lib/modules/V/` | its modules | | `/lib/firmware/` | firmware | -| `/var/db/pkg/` | the file list of each installed package | -| `/var/cache/distfiles/` | downloaded sources | +| `/var/lib/mag/` | what is installed, and its files | +| `/var/cache/mag/` | indexes and downloaded packages | | `/usr/share/limine/` | limine's boot files, for installing it | -| `/usr/share/doc/chamesle/handbook.md` | this book, on the live ISO | -| `/var/db/repos/gentoo/` | the Gentoo tree, from `hoard sync` | +| `/usr/share/doc/chamesle/handbook.md` | this book | ### 10.2 In the sources | path | what | |------|------| -| `system/tools/chamesle-bootstrap` | makes a root file system and builds the base set into it | +| `system/tools/chamesle-bootstrap` | puts the base into a root with mag | | `system/tools/chamesle-chroot` | chroot with the pseudo file systems mounted | | `system/tools/chamesle-disk` | cfdisk, vfat boot partition, ZFS root, mounted on `/mnt` | -| `system/files/` | init, rc, `service`, `init.conf` and the service scripts that go into every root | -| `system/iso/mkinitramfs` | builds an initramfs | -| `system/iso/init` | the first process in the initramfs | -| `system/iso/profile/packages` | what is in the live root | -| `system/iso/profile/modules` | what the initramfs loads | -| `system/iso/profile/limine.conf` | the live boot menu | -| `system/iso/profile/overlay/` | files copied over the live root | +| `system/tools/mkapk`, `mkrepo`, `mkpkgs` | packages, signed indexes, Chamesle's own repo | +| `system/files/` | init, rc, `service`, `init.conf` and the service scripts, in `chamesle-base` | +| `system/pkg/chamesle-base/` | its scripts, `repos`, `os-release`, `issue` | +| `system/keys/` | the public keys the repos are signed with | +| `system/iso/mkiso`, `mkinitramfs`, `init` | the live ISO, its initramfs and the first process in it | +| `system/iso/profile/` | `packages`, `modules`, `limine.conf` and the `overlay/` of the live root | | `system/handbook/handbook.md` | this book | -| `SimplePackagemAnagingSystem/src/` | hoard, in Rust, and `ebuild.sh`, the environment ebuilds run in | +| `mag/mag.c`, `mag/c.h`, `mag/build.sh` | the package manager | | `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 [-s PACKAGES] [-n HOSTNAME] TARGET - mkinitramfs [-m modules] ROOTFS KVER OUT - hoard [--root DIR] install|upgrade|remove|autoremove|sync|search|info|list|files|owns|env-update|manifest|self-update + chamesle-bootstrap [-a ARCH] [-n HOSTNAME] [-k KERNEL] [-f FIRMWARE] TARGET [PACKAGE]... + chamesle-chroot DIR [COMMAND...] + chamesle-disk DISK + mag [-nf] update|install|remove|upgrade|autoremove|list|info|search|files|owns|deps|rdeps|fetch rifle --install DIR | --list limine bios-install DEVICE diff --git a/handbook/html.py b/handbook/html.py @@ -5,12 +5,12 @@ 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', 'spas', 'rifle', 'base', 'kernel', 'iso', 'maintaining', 'files'] +slugs = ['about', 'preparing', 'installing', 'mag', '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' '<a href="chat.html">Chat</a> |\n<a href="source.html">Source</a> |\n' - '<a href="https://x22.chamesle.org/">X22</a> |\n<a href="https://spas.chamesle.org/">SPAS</a> |\n<a href="about.html">About</a>') + '<a href="https://x22.chamesle.org/">X22</a> |\n<a href="https://github.com/tortr-rs/mag">mag</a> |\n<a href="about.html">About</a>') def page(title, desc, url, body): t = html.escape(title) @@ -28,14 +28,15 @@ def page(title, desc, url, body): <meta property="og:title" content="{t} - Chamesle"> <meta property="og:description" content="{d}"> <meta property="og:url" content="https://chamesle.org/{url}"> -<link rel="stylesheet" href="style.css?16"> +<link rel="stylesheet" href="style.css?19"> +<link rel="icon" href="img/logo.png"> </head> <body> <div id="page"> <div id="top"> -<h1><a href="./">Chamesle</a></h1> +<h1><a href="./"><img src="img/banner-dark.png" alt="Chamesle Linux" width="223" height="56"></a></h1> </div> <div id="nav"> diff --git a/iso/mkinitramfs b/iso/mkinitramfs @@ -12,24 +12,38 @@ tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT mkdir -p "$tmp"/bin "$tmp"/dev "$tmp"/proc "$tmp"/sys "$tmp"/run "$tmp"/mnt "$tmp"/lib/modules rd=$(command -v llvm-readelf || command -v readelf) || { echo "mkinitramfs: no readelf" >&2; exit 1; } +# a path in the root with its links followed inside the root, since a link there may point at /bin/busybox +inroot() { + f=$1 + while [ -L "$f" ]; do + l=$(readlink "$f") + case $l in /*) f=$root$l;; *) f=${f%/*}/$l;; esac + done + echo "$f" +} # copy what a binary links against: the musl loader and every NEEDED library found in the root needed() { $rd -d "$1" | sed -n 's/.*(NEEDED).*\[\(.*\)\]/\1/p' | while read -r l; do [ -e "$tmp/usr/lib/$l" ] && continue for d in usr/lib lib; do - [ -e "$root/$d/$l" ] || continue + [ -e "$root/$d/$l" ] || [ -L "$root/$d/$l" ] || continue mkdir -p "$tmp/usr/lib" - cp -L "$root/$d/$l" "$tmp/usr/lib/$l" - needed "$root/$d/$l" + cp "$(inroot "$root/$d/$l")" "$tmp/usr/lib/$l" + needed "$(inroot "$root/$d/$l")" break done done } mkdir -p "$tmp/lib" "$tmp/usr/lib" -cp -L "$root/usr/lib/libc.so" "$tmp/lib/ld-musl-x86_64.so.1" +for l in "$root"/lib/ld-musl-*.so.1; do cp "$(inroot "$l")" "$tmp/lib/${l##*/}"; done for t in sh mount umount switch_root insmod mkdir sleep blkid; do f= - for d in usr/bin bin usr/sbin sbin; do [ -x "$root/$d/$t" ] && { f=$root/$d/$t; break; }; done + for d in usr/bin bin usr/sbin sbin; do + [ -e "$root/$d/$t" ] || [ -L "$root/$d/$t" ] || continue + f=$(inroot "$root/$d/$t") + [ -x "$f" ] && break + f= + done [ -n "$f" ] || { echo "mkinitramfs: no $t in $root" >&2; exit 1; } cp "$f" "$tmp/bin/$t" needed "$f" @@ -54,7 +68,7 @@ if [ -n "$list" ]; then fi for d in usr/sbin sbin usr/bin bin; do [ -x "$root/$d/zpool" ] || continue - cp "$root/$d/zpool" "$tmp/bin/zpool" + cp "$(inroot "$root/$d/zpool")" "$tmp/bin/zpool" needed "$root/$d/zpool" break done diff --git a/iso/mkiso b/iso/mkiso @@ -1,80 +1,52 @@ #!/bin/sh -# mkiso: builds the Chamesle live ISO from a profile. -# mkiso -r $HOME/src/mag/repo:/usr/pkgsrc -# mkiso -R /srv/rootfs -o chamesle.iso -# MAGREPO=$HOME/src/mag/repo mkiso ... the recipes the image carries for mag search and info +# mkiso: the Chamesle live ISO, with mag putting chamesle-base, the kernel and profile/packages in its root. +# mkiso -o chamesle.iso +# mkiso -a x86 -o chamesle-x86.iso +# MAG is the mag to build with (default: the one in PATH), REPOS a repos file to build from instead of chamesle-base's set -e here=$(cd "$(dirname "$0")" && pwd) profile=$here/profile work=$PWD/work out=chamesle.iso -while getopts p:r:R:w:o: o; do +arch=x86_64 +while getopts a:p:w:o: o; do case $o in + a) arch=$OPTARG;; p) profile=$OPTARG;; - r) MAG_REPO=$OPTARG;; - R) rootfs=$OPTARG;; w) work=$OPTARG;; o) out=$OPTARG;; - *) echo "usage: mkiso [-p profile] [-r repos] [-R rootfs] [-w workdir] [-o out.iso]" >&2; exit 2;; + *) echo "usage: mkiso [-a arch] [-p profile] [-w workdir] [-o out.iso]" >&2; exit 2;; esac done -export MAG_REPO -if [ -z "$MAGREPO" ]; then - for d in "$here/../../mag/repo" $(echo "$MAG_REPO" | tr : ' '); do - [ -f "$d/PROVIDES" ] && { MAGREPO=$d; break; } - done -fi : "${MKISOFS:=xorriso -as mkisofs}" -: "${LIMINE:=/usr/share/limine}" die() { echo "mkiso: $*" >&2; exit 1; } -[ -d "$LIMINE" ] && [ -f "$LIMINE/limine-bios-cd.bin" ] || die "no limine files in $LIMINE (set LIMINE)" -for t in mksquashfs ${MKISOFS%% *} zstd bsdcpio limine; do command -v $t >/dev/null || die "$t is not installed"; done - -iso=$work/iso -mkdir -p "$work" -rm -rf "$iso" -mkdir -p "$iso/boot/limine" "$iso/EFI/BOOT" "$iso/LiveOS" - -if [ -z "$rootfs" ]; then - rootfs=$work/rootfs - rm -rf "$rootfs" - "$here/../tools/chamesle-bootstrap" -s "$(grep -v '^#' "$profile/packages" | tr '\n' ' ')" -n chamesle-live "$rootfs" -else - from=$rootfs - rm -rf "$work/rootfs" - cp -a "$rootfs" "$work/rootfs" - rootfs=$work/rootfs -fi +[ "$(id -u)" = 0 ] || die "run it as root, the files of the image belong to root" [ -n "$MAG" ] || MAG=$(command -v mag) || die "no mag: put it in PATH or set MAG" -MAG_ROOT=$rootfs MAG_PREFIX=/usr "$MAG" relocate ${from:+"$from"} +for t in mksquashfs ${MKISOFS%% *} zstd bsdcpio; do command -v $t >/dev/null || die "$t is not installed"; done -rm -rf "$rootfs"/var/cache/mag "$rootfs"/var/tmp/mag "$rootfs"/lib/firmware -# KEEPDEV=1 keeps the headers and static libraries, so the compiler in the image can build things -if [ -z "$KEEPDEV" ]; then - rm -rf "$rootfs"/usr/include "$rootfs"/usr/lib/pkgconfig - find "$rootfs"/usr/lib -name "*.a" -o -name "*.la" | xargs rm -f -fi +iso=$work/iso rootfs=$work/rootfs +rm -rf "$iso" "$rootfs" +mkdir -p "$iso/boot/limine" "$iso/EFI/BOOT" "$iso/LiveOS" "$rootfs/etc/mag" +cp "${REPOS:-$here/../pkg/chamesle-base/repos}" "$rootfs/etc/mag/repos" +cp -R "$here/../keys" "$rootfs/etc/mag/keys" +echo "$arch" > "$rootfs/etc/mag/arch" +# CACHE is a directory to keep the downloaded packages in between builds +[ -z "$CACHE" ] || { mkdir -p "$CACHE" "$rootfs/var/cache/mag"; cp -R "$CACHE" "$rootfs/var/cache/mag/pkg"; } +MAG_ROOT=$rootfs "$MAG" update +MAG_ROOT=$rootfs "$MAG" install chamesle-base linux-lts $(grep -v '^#' "$profile/packages") +[ -z "$CACHE" ] || cp "$rootfs"/var/cache/mag/pkg/* "$CACHE/" +cp "$here/../pkg/chamesle-base/repos" "$rootfs/etc/mag/repos" tar -C "$profile/overlay" -cf - . | tar -C "$rootfs" -xf - -for t in chamesle-bootstrap chamesle-chroot chamesle-disk; do - install -Dm755 "$here/../tools/$t" "$rootfs/usr/bin/$t" -done -if [ -n "$MAGREPO" ]; then - mkdir -p "$rootfs/usr/share/mag/repo" - cp -R "$MAGREPO/." "$rootfs/usr/share/mag/repo/" -fi -install -Dm644 "$here/../handbook/handbook.md" "$rootfs/usr/share/doc/chamesle/handbook.md" -install -Dm755 "$MAG" "$rootfs/usr/bin/mag" -vmlinuz=$(ls "$rootfs"/boot/vmlinuz-* | head -n 1) -kver=$(ls "$rootfs/lib/modules" | head -n 1) -[ -f "$vmlinuz" ] && [ -n "$kver" ] || die "no kernel in the root: boot/vmlinuz-* and lib/modules/* are missing" -cp "$vmlinuz" "$iso/boot/vmlinuz" +rm -rf "$rootfs"/var/cache/mag/pkg "$rootfs"/var/tmp/mag "$rootfs"/boot/initramfs-* -depmod -b "$rootfs" "$kver" +kver=$(ls "$rootfs/lib/modules" | head -n 1) +[ -f "$rootfs/boot/vmlinuz-lts" ] && [ -n "$kver" ] || die "no kernel in the root" +cp "$rootfs/boot/vmlinuz-lts" "$iso/boot/vmlinuz" "$here/mkinitramfs" -m "$profile/modules" "$rootfs" "$kver" "$iso/boot/initrd" -rm -f "$iso/LiveOS/rootfs.sfs" -mksquashfs "$rootfs" "$iso/LiveOS/rootfs.sfs" -all-root -comp zstd -Xcompression-level 19 -b 256K -noappend -no-progress >/dev/null +mksquashfs "$rootfs" "$iso/LiveOS/rootfs.sfs" -comp zstd -Xcompression-level 19 -b 256K -noappend -no-progress >/dev/null +LIMINE=$rootfs/usr/share/limine cp "$LIMINE"/limine-bios.sys "$LIMINE"/limine-bios-cd.bin "$LIMINE"/limine-uefi-cd.bin "$iso/boot/limine/" cp "$LIMINE"/BOOTX64.EFI "$iso/EFI/BOOT/" cp "$profile/limine.conf" "$iso/boot/limine/limine.conf" @@ -82,6 +54,7 @@ cp "$profile/limine.conf" "$iso/boot/limine/limine.conf" $MKISOFS -R -r -J -V CHAMESLE \ -b boot/limine/limine-bios-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table \ --efi-boot boot/limine/limine-uefi-cd.bin -efi-boot-part --efi-boot-image --protective-msdos-label \ - -o "$out" "$iso" >/dev/null 2>&1 || { echo "mkiso: $MKISOFS failed" >&2; exit 1; } -limine bios-install "$out" >/dev/null + -o "$out" "$iso" >/dev/null 2>&1 || die "$MKISOFS failed" +# the root's limine, so its stages match the limine-bios.sys on the ISO, run with the root's own musl +"$rootfs"/lib/ld-musl-*.so.1 --library-path "$rootfs/lib:$rootfs/usr/lib" "$rootfs/usr/bin/limine" bios-install "$out" >/dev/null echo "$out: $(du -h "$out" | cut -f1)" diff --git a/iso/profile/limine.conf b/iso/profile/limine.conf @@ -5,4 +5,4 @@ serial: yes protocol: linux path: boot():/boot/vmlinuz module_path: boot():/boot/initrd - cmdline: console=tty0 console=ttyS0,115200 + cmdline: console=tty0 console=ttyS0,115200 quiet diff --git a/iso/profile/overlay/etc/doas.conf b/iso/profile/overlay/etc/doas.conf @@ -1,2 +0,0 @@ -permit persist :wheel -permit nopass root diff --git a/iso/profile/overlay/etc/init.conf b/iso/profile/overlay/etc/init.conf @@ -0,0 +1,7 @@ +# the live system's: root is logged in on every tty +hostname = chamesle-live +boot-services = {udev,modules,dbus,iwd,network} +modules = {evdev,psmouse,i8042,atkbd,usbhid,hid_generic,hid_multitouch,i2c_hid_acpi,xhci_pci,virtio_net,e1000,e1000e,r8169,8139too,igb,iwlwifi} +ttys = {tty1,tty2,tty3,tty4,tty5,tty6,ttyS0} +getty = agetty --autologin root --noclear $tty linux +getty-ttyS0 = agetty --autologin root -L $tty 115200 vt100 diff --git a/iso/profile/overlay/etc/motd b/iso/profile/overlay/etc/motd @@ -1,4 +1,3 @@ - - Chamesle live system. The handbook is in /usr/share/doc/chamesle/handbook.md - (chapter 3 is the install). vim and mksh are here. + Chamesle live system. The handbook is /usr/share/doc/chamesle/handbook.md, chapter 3 is the install. + Network: dhcpcd on a cable, iwctl for wireless. diff --git a/iso/profile/overlay/usr/bin/sudo b/iso/profile/overlay/usr/bin/sudo @@ -1 +0,0 @@ -doas -\ No newline at end of file diff --git a/iso/profile/packages b/iso/profile/packages @@ -1,37 +1,20 @@ -# what goes into the live image -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-firmware/wireless-regdb -editors/vim -sys-fs/zfs -sys-kernel/zfs-module -devel/git-base -security/opendoas -x11/modular-xorg-server -x11/xinit -x11/libXft -x11/libXinerama -x11/xrandr -x11/xsetroot -x11/xauth -x11/setxkbmap -x11/xrdb -x11/xf86-video-vesa -x11/xf86-video-fbdev -dev-libs/libevdev -x11-drivers/xf86-input-evdev -fonts/dejavu-ttf -fonts/fontconfig +# what goes into the live image besides chamesle-base and the kernel +e2fsprogs +dosfstools +sfdisk +lsblk +blkid +mount +umount +cfdisk +util-linux-misc +limine +zfs +zfs-lts +iwd +wpa_supplicant +linux-firmware-none +linux-firmware-intel +curl +vim +less diff --git a/keys/alpine-devel@lists.alpinelinux.org-4a6a0840.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-4a6a0840.rsa.pub @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1yHJxQgsHQREclQu4Ohe +qxTxd1tHcNnvnQTu/UrTky8wWvgXT+jpveroeWWnzmsYlDI93eLI2ORakxb3gA2O +Q0Ry4ws8vhaxLQGC74uQR5+/yYrLuTKydFzuPaS1dK19qJPXB8GMdmFOijnXX4SA +jixuHLe1WW7kZVtjL7nufvpXkWBGjsfrvskdNA/5MfxAeBbqPgaq0QMEfxMAn6/R +L5kNepi/Vr4S39Xvf2DzWkTLEK8pcnjNkt9/aafhWqFVW7m3HCAII6h/qlQNQKSo +GuH34Q8GsFG30izUENV9avY7hSLq7nggsvknlNBZtFUcmGoQrtx3FmyYsIC8/R+B +ywIDAQAB +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-5243ef4b.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-5243ef4b.rsa.pub @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvNijDxJ8kloskKQpJdx+ +mTMVFFUGDoDCbulnhZMJoKNkSuZOzBoFC94omYPtxnIcBdWBGnrm6ncbKRlR+6oy +DO0W7c44uHKCFGFqBhDasdI4RCYP+fcIX/lyMh6MLbOxqS22TwSLhCVjTyJeeH7K +aA7vqk+QSsF4TGbYzQDDpg7+6aAcNzg6InNePaywA6hbT0JXbxnDWsB+2/LLSF2G +mnhJlJrWB1WGjkz23ONIWk85W4S0XB/ewDefd4Ly/zyIciastA7Zqnh7p3Ody6Q0 +sS2MJzo7p3os1smGjUF158s6m/JbVh4DN6YIsxwl2OjDOz9R0OycfJSDaBVIGZzg +cQIDAQAB +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-524d27bb.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-524d27bb.rsa.pub @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr8s1q88XpuJWLCZALdKj +lN8wg2ePB2T9aIcaxryYE/Jkmtu+ZQ5zKq6BT3y/udt5jAsMrhHTwroOjIsF9DeG +e8Y3vjz+Hh4L8a7hZDaw8jy3CPag47L7nsZFwQOIo2Cl1SnzUc6/owoyjRU7ab0p +iWG5HK8IfiybRbZxnEbNAfT4R53hyI6z5FhyXGS2Ld8zCoU/R4E1P0CUuXKEN4p0 +64dyeUoOLXEWHjgKiU1mElIQj3k/IF02W89gDj285YgwqA49deLUM7QOd53QLnx+ +xrIrPv3A+eyXMFgexNwCKQU9ZdmWa00MjjHlegSGK8Y2NPnRoXhzqSP9T9i2HiXL +VQIDAQAB +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-5261cecb.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-5261cecb.rsa.pub @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwlzMkl7b5PBdfMzGdCT0 +cGloRr5xGgVmsdq5EtJvFkFAiN8Ac9MCFy/vAFmS8/7ZaGOXoCDWbYVLTLOO2qtX +yHRl+7fJVh2N6qrDDFPmdgCi8NaE+3rITWXGrrQ1spJ0B6HIzTDNEjRKnD4xyg4j +g01FMcJTU6E+V2JBY45CKN9dWr1JDM/nei/Pf0byBJlMp/mSSfjodykmz4Oe13xB +Ca1WTwgFykKYthoLGYrmo+LKIGpMoeEbY1kuUe04UiDe47l6Oggwnl+8XD1MeRWY +sWgj8sF4dTcSfCMavK4zHRFFQbGp/YFJ/Ww6U9lA3Vq0wyEI6MCMQnoSMFwrbgZw +wwIDAQAB +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-58199dcc.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-58199dcc.rsa.pub @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3v8/ye/V/t5xf4JiXLXa +hWFRozsnmn3hobON20GdmkrzKzO/eUqPOKTpg2GtvBhK30fu5oY5uN2ORiv2Y2ht +eLiZ9HVz3XP8Fm9frha60B7KNu66FO5P2o3i+E+DWTPqqPcCG6t4Znk2BypILcit +wiPKTsgbBQR2qo/cO01eLLdt6oOzAaF94NH0656kvRewdo6HG4urbO46tCAizvCR +CA7KGFMyad8WdKkTjxh8YLDLoOCtoZmXmQAiwfRe9pKXRH/XXGop8SYptLqyVVQ+ +tegOD9wRs2tOlgcLx4F/uMzHN7uoho6okBPiifRX+Pf38Vx+ozXh056tjmdZkCaV +aQIDAQAB +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-58cbb476.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-58cbb476.rsa.pub @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoSPnuAGKtRIS5fEgYPXD +8pSGvKAmIv3A08LBViDUe+YwhilSHbYXUEAcSH1KZvOo1WT1x2FNEPBEFEFU1Eyc ++qGzbA03UFgBNvArurHQ5Z/GngGqE7IarSQFSoqewYRtFSfp+TL9CUNBvM0rT7vz +2eMu3/wWG+CBmb92lkmyWwC1WSWFKO3x8w+Br2IFWvAZqHRt8oiG5QtYvcZL6jym +Y8T6sgdDlj+Y+wWaLHs9Fc+7vBuyK9C4O1ORdMPW15qVSl4Lc2Wu1QVwRiKnmA+c +DsH/m7kDNRHM7TjWnuj+nrBOKAHzYquiu5iB3Qmx+0gwnrSVf27Arc3ozUmmJbLj +zQIDAQAB +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-58e4f17d.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-58e4f17d.rsa.pub @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvBxJN9ErBgdRcPr5g4hV +qyUSGZEKuvQliq2Z9SRHLh2J43+EdB6A+yzVvLnzcHVpBJ+BZ9RV30EM9guck9sh +r+bryZcRHyjG2wiIEoduxF2a8KeWeQH7QlpwGhuobo1+gA8L0AGImiA6UP3LOirl +I0G2+iaKZowME8/tydww4jx5vG132JCOScMjTalRsYZYJcjFbebQQolpqRaGB4iG +WqhytWQGWuKiB1A22wjmIYf3t96l1Mp+FmM2URPxD1gk/BIBnX7ew+2gWppXOK9j +1BJpo0/HaX5XoZ/uMqISAAtgHZAqq+g3IUPouxTphgYQRTRYpz2COw3NF43VYQrR +bQIDAQAB +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-5e69ca50.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-5e69ca50.rsa.pub @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwXEJ8uVwJPODshTkf2BH +pH5fVVDppOa974+IQJsZDmGd3Ny0dcd+WwYUhNFUW3bAfc3/egaMWCaprfaHn+oS +4ddbOFgbX8JCHdru/QMAAU0aEWSMybfJGA569c38fNUF/puX6XK/y0lD2SS3YQ/a +oJ5jb5eNrQGR1HHMAd0G9WC4JeZ6WkVTkrcOw55F00aUPGEjejreXBerhTyFdabo +dSfc1TILWIYD742Lkm82UBOPsOSdSfOdsMOOkSXxhdCJuCQQ70DHkw7Epy9r+X33 +ybI4r1cARcV75OviyhD8CFhAlapLKaYnRFqFxlA515e6h8i8ih/v3MSEW17cCK0b +QwIDAQAB +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-60ac2099.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-60ac2099.rsa.pub @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwR4uJVtJOnOFGchnMW5Y +j5/waBdG1u5BTMlH+iQMcV5+VgWhmpZHJCBz3ocD+0IGk2I68S5TDOHec/GSC0lv +6R9o6F7h429GmgPgVKQsc8mPTPtbjJMuLLs4xKc+viCplXc0Nc0ZoHmCH4da6fCV +tdpHQjVe6F9zjdquZ4RjV6R6JTiN9v924dGMAkbW/xXmamtz51FzondKC52Gh8Mo +/oA0/T0KsCMCi7tb4QNQUYrf+Xcha9uus4ww1kWNZyfXJB87a2kORLiWMfs2IBBJ +TmZ2Fnk0JnHDb8Oknxd9PvJPT0mvyT8DA+KIAPqNvOjUXP4bnjEHJcoCP9S5HkGC +IQIDAQAB +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-6165ee59.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-6165ee59.rsa.pub @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAutQkua2CAig4VFSJ7v54 +ALyu/J1WB3oni7qwCZD3veURw7HxpNAj9hR+S5N/pNeZgubQvJWyaPuQDm7PTs1+ +tFGiYNfAsiibX6Rv0wci3M+z2XEVAeR9Vzg6v4qoofDyoTbovn2LztaNEjTkB+oK +tlvpNhg1zhou0jDVYFniEXvzjckxswHVb8cT0OMTKHALyLPrPOJzVtM9C1ew2Nnc +3848xLiApMu3NBk0JqfcS3Bo5Y2b1FRVBvdt+2gFoKZix1MnZdAEZ8xQzL/a0YS5 +Hd0wj5+EEKHfOd3A75uPa/WQmA+o0cBFfrzm69QDcSJSwGpzWrD1ScH3AK8nWvoj +v7e9gukK/9yl1b4fQQ00vttwJPSgm9EnfPHLAtgXkRloI27H6/PuLoNvSAMQwuCD +hQRlyGLPBETKkHeodfLoULjhDi1K2gKJTMhtbnUcAA7nEphkMhPWkBpgFdrH+5z4 +Lxy+3ek0cqcI7K68EtrffU8jtUj9LFTUC8dERaIBs7NgQ/LfDbDfGh9g6qVj1hZl +k9aaIPTm/xsi8v3u+0qaq7KzIBc9s59JOoA8TlpOaYdVgSQhHHLBaahOuAigH+VI +isbC9vmqsThF2QdDtQt37keuqoda2E6sL7PUvIyVXDRfwX7uMDjlzTxHTymvq2Ck +htBqojBnThmjJQFgZXocHG8CAwEAAQ== +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-61666e3f.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-61666e3f.rsa.pub @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAlEyxkHggKCXC2Wf5Mzx4 +nZLFZvU2bgcA3exfNPO/g1YunKfQY+Jg4fr6tJUUTZ3XZUrhmLNWvpvSwDS19ZmC +IXOu0+V94aNgnhMsk9rr59I8qcbsQGIBoHzuAl8NzZCgdbEXkiY90w1skUw8J57z +qCsMBydAueMXuWqF5nGtYbi5vHwK42PffpiZ7G5Kjwn8nYMW5IZdL6ZnMEVJUWC9 +I4waeKg0yskczYDmZUEAtrn3laX9677ToCpiKrvmZYjlGl0BaGp3cxggP2xaDbUq +qfFxWNgvUAb3pXD09JM6Mt6HSIJaFc9vQbrKB9KT515y763j5CC2KUsilszKi3mB +HYe5PoebdjS7D1Oh+tRqfegU2IImzSwW3iwA7PJvefFuc/kNIijfS/gH/cAqAK6z +bhdOtE/zc7TtqW2Wn5Y03jIZdtm12CxSxwgtCF1NPyEWyIxAQUX9ACb3M0FAZ61n +fpPrvwTaIIxxZ01L3IzPLpbc44x/DhJIEU+iDt6IMTrHOphD9MCG4631eIdB0H1b +6zbNX1CXTsafqHRFV9XmYYIeOMggmd90s3xIbEujA6HKNP/gwzO6CDJ+nHFDEqoF +SkxRdTkEqjTjVKieURW7Swv7zpfu5PrsrrkyGnsRrBJJzXlm2FOOxnbI2iSL1B5F +rO5kbUxFeZUIDq+7Yv4kLWcCAwEAAQ== +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-616a9724.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-616a9724.rsa.pub @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnC+bR4bHf/L6QdU4puhQ +gl1MHePszRC38bzvVFDUJsmCaMCL2suCs2A2yxAgGb9pu9AJYLAmxQC4mM3jNqhg +/E7yuaBbek3O02zN/ctvflJ250wZCy+z0ZGIp1ak6pu1j14IwHokl9j36zNfGtfv +ADVOcdpWITFFlPqwq1qt/H3UsKVmtiF3BNWWTeUEQwKvlU8ymxgS99yn0+4OPyNT +L3EUeS+NQJtDS01unau0t7LnjUXn+XIneWny8bIYOQCuVR6s/gpIGuhBaUqwaJOw +7jkJZYF2Ij7uPb4b5/R3vX2FfxxqEHqssFSg8FFUNTZz3qNZs0CRVyfA972g9WkJ +hPfn31pQYil4QGRibCMIeU27YAEjXoqfJKEPh4UWMQsQLrEfdGfb8VgwrPbniGfU +L3jKJR3VAafL9330iawzVQDlIlwGl6u77gEXMl9K0pfazunYhAp+BMP+9ot5ckK+ +osmrqj11qMESsAj083GeFdfV3pXEIwUytaB0AKEht9DbqUfiE/oeZ/LAXgySMtVC +sbC4ESmgVeY2xSBIJdDyUap7FR49GGrw0W49NUv9gRgQtGGaNVQQO9oGL2PBC41P +iWF9GLoX30HIz1P8PF/cZvicSSPkQf2Z6TV+t0ebdGNS5DjapdnCrq8m9Z0pyKsQ +uxAL2a7zX8l5i1CZh1ycUGsCAwEAAQ== +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-616abc23.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-616abc23.rsa.pub @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0MfCDrhODRCIxR9Dep1s +eXafh5CE5BrF4WbCgCsevyPIdvTeyIaW4vmO3bbG4VzhogDZju+R3IQYFuhoXP5v +Y+zYJGnwrgz3r5wYAvPnLEs1+dtDKYOgJXQj+wLJBW1mzRDL8FoRXOe5iRmn1EFS +wZ1DoUvyu7/J5r0itKicZp3QKED6YoilXed+1vnS4Sk0mzN4smuMR9eO1mMCqNp9 +9KTfRDHTbakIHwasECCXCp50uXdoW6ig/xUAFanpm9LtK6jctNDbXDhQmgvAaLXZ +LvFqoaYJ/CvWkyYCgL6qxvMvVmPoRv7OPcyni4xR/WgWa0MSaEWjgPx3+yj9fiMA +1S02pFWFDOr5OUF/O4YhFJvUCOtVsUPPfA/Lj6faL0h5QI9mQhy5Zb9TTaS9jB6p +Lw7u0dJlrjFedk8KTJdFCcaGYHP6kNPnOxMylcB/5WcztXZVQD5WpCicGNBxCGMm +W64SgrV7M07gQfL/32QLsdqPUf0i8hoVD8wfQ3EpbQzv6Fk1Cn90bZqZafg8XWGY +wddhkXk7egrr23Djv37V2okjzdqoyLBYBxMz63qQzFoAVv5VoY2NDTbXYUYytOvG +GJ1afYDRVWrExCech1mX5ZVUB1br6WM+psFLJFoBFl6mDmiYt0vMYBddKISsvwLl +IJQkzDwtXzT2cSjoj3T5QekCAwEAAQ== +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-616ac3bc.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-616ac3bc.rsa.pub @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvaaoSLab+IluixwKV5Od +0gib2YurjPatGIbn5Ov2DLUFYiebj2oJINXJSwUOO+4WcuHFEqiL/1rya+k5hLZt +hnPL1tn6QD4rESznvGSasRCQNT2vS/oyZbTYJRyAtFkEYLlq0t3S3xBxxHWuvIf0 +qVxVNYpQWyM3N9RIeYBR/euXKJXileSHk/uq1I5wTC0XBIHWcthczGN0m9wBEiWS +0m3cnPk4q0Ea8mUJ91Rqob19qETz6VbSPYYpZk3qOycjKosuwcuzoMpwU8KRiMFd +5LHtX0Hx85ghGsWDVtS0c0+aJa4lOMGvJCAOvDfqvODv7gKlCXUpgumGpLdTmaZ8 +1RwqspAe3IqBcdKTqRD4m2mSg23nVx2FAY3cjFvZQtfooT7q1ItRV5RgH6FhQSl7 ++6YIMJ1Bf8AAlLdRLpg+doOUGcEn+pkDiHFgI8ylH1LKyFKw+eXaAml/7DaWZk1d +dqggwhXOhc/UUZFQuQQ8A8zpA13PcbC05XxN2hyP93tCEtyynMLVPtrRwDnHxFKa +qKzs3rMDXPSXRn3ZZTdKH3069ApkEjQdpcwUh+EmJ1Ve/5cdtzT6kKWCjKBFZP/s +91MlRrX2BTRdHaU5QJkUheUtakwxuHrdah2F94lRmsnQlpPr2YseJu6sIE+Dnx4M +CfhdVbQL2w54R645nlnohu8CAwEAAQ== +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-616adfeb.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-616adfeb.rsa.pub @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAq0BFD1D4lIxQcsqEpQzU +pNCYM3aP1V/fxxVdT4DWvSI53JHTwHQamKdMWtEXetWVbP5zSROniYKFXd/xrD9X +0jiGHey3lEtylXRIPxe5s+wXoCmNLcJVnvTcDtwx/ne2NLHxp76lyc25At+6RgE6 +ADjLVuoD7M4IFDkAsd8UQ8zM0Dww9SylIk/wgV3ZkifecvgUQRagrNUdUjR56EBZ +raQrev4hhzOgwelT0kXCu3snbUuNY/lU53CoTzfBJ5UfEJ5pMw1ij6X0r5S9IVsy +KLWH1hiO0NzU2c8ViUYCly4Fe9xMTFc6u2dy/dxf6FwERfGzETQxqZvSfrRX+GLj +/QZAXiPg5178hT/m0Y3z5IGenIC/80Z9NCi+byF1WuJlzKjDcF/TU72zk0+PNM/H +Kuppf3JT4DyjiVzNC5YoWJT2QRMS9KLP5iKCSThwVceEEg5HfhQBRT9M6KIcFLSs +mFjx9kNEEmc1E8hl5IR3+3Ry8G5/bTIIruz14jgeY9u5jhL8Vyyvo41jgt9sLHR1 +/J1TxKfkgksYev7PoX6/ZzJ1ksWKZY5NFoDXTNYUgzFUTOoEaOg3BAQKadb3Qbbq +XIrxmPBdgrn9QI7NCgfnAY3Tb4EEjs3ON/BNyEhUENcXOH6I1NbcuBQ7g9P73kE4 +VORdoc8MdJ5eoKBpO8Ww8HECAwEAAQ== +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-616ae350.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-616ae350.rsa.pub @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyduVzi1mWm+lYo2Tqt/0 +XkCIWrDNP1QBMVPrE0/ZlU2bCGSoo2Z9FHQKz/mTyMRlhNqTfhJ5qU3U9XlyGOPJ +piM+b91g26pnpXJ2Q2kOypSgOMOPA4cQ42PkHBEqhuzssfj9t7x47ppS94bboh46 +xLSDRff/NAbtwTpvhStV3URYkxFG++cKGGa5MPXBrxIp+iZf9GnuxVdST5PGiVGP +ODL/b69sPJQNbJHVquqUTOh5Ry8uuD2WZuXfKf7/C0jC/ie9m2+0CttNu9tMciGM +EyKG1/Xhk5iIWO43m4SrrT2WkFlcZ1z2JSf9Pjm4C2+HovYpihwwdM/OdP8Xmsnr +DzVB4YvQiW+IHBjStHVuyiZWc+JsgEPJzisNY0Wyc/kNyNtqVKpX6dRhMLanLmy+ +f53cCSI05KPQAcGj6tdL+D60uKDkt+FsDa0BTAobZ31OsFVid0vCXtsbplNhW1IF +HwsGXBTVcfXg44RLyL8Lk/2dQxDHNHzAUslJXzPxaHBLmt++2COa2EI1iWlvtznk +Ok9WP8SOAIj+xdqoiHcC4j72BOVVgiITIJNHrbppZCq6qPR+fgXmXa+sDcGh30m6 +9Wpbr28kLMSHiENCWTdsFij+NQTd5S47H7XTROHnalYDuF1RpS+DpQidT5tUimaT +JZDr++FjKrnnijbyNF8b98UCAwEAAQ== +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-616db30d.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-616db30d.rsa.pub @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnpUpyWDWjlUk3smlWeA0 +lIMW+oJ38t92CRLHH3IqRhyECBRW0d0aRGtq7TY8PmxjjvBZrxTNDpJT6KUk4LRm +a6A6IuAI7QnNK8SJqM0DLzlpygd7GJf8ZL9SoHSH+gFsYF67Cpooz/YDqWrlN7Vw +tO00s0B+eXy+PCXYU7VSfuWFGK8TGEv6HfGMALLjhqMManyvfp8hz3ubN1rK3c8C +US/ilRh1qckdbtPvoDPhSbTDmfU1g/EfRSIEXBrIMLg9ka/XB9PvWRrekrppnQzP +hP9YE3x/wbFc5QqQWiRCYyQl/rgIMOXvIxhkfe8H5n1Et4VAorkpEAXdsfN8KSVv +LSMazVlLp9GYq5SUpqYX3KnxdWBgN7BJoZ4sltsTpHQ/34SXWfu3UmyUveWj7wp0 +x9hwsPirVI00EEea9AbP7NM2rAyu6ukcm4m6ATd2DZJIViq2es6m60AE6SMCmrQF +wmk4H/kdQgeAELVfGOm2VyJ3z69fQuywz7xu27S6zTKi05Qlnohxol4wVb6OB7qG +LPRtK9ObgzRo/OPumyXqlzAi/Yvyd1ZQk8labZps3e16bQp8+pVPiumWioMFJDWV +GZjCmyMSU8V6MB6njbgLHoyg2LCukCAeSjbPGGGYhnKLm1AKSoJh3IpZuqcKCk5C +8CM1S15HxV78s9dFntEqIokCAwEAAQ== +-----END PUBLIC KEY----- diff --git a/keys/alpine-devel@lists.alpinelinux.org-66ba20fe.rsa.pub b/keys/alpine-devel@lists.alpinelinux.org-66ba20fe.rsa.pub @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtfB12w4ZgqsXWZDfUAV/ +6Y4aHUKIu3q4SXrNZ7CXF9nXoAVYrS7NAxJdAodsY3vPCN0g5O8DFXR+390LdOuQ ++HsGKCc1k5tX5ZXld37EZNTNSbR0k+NKhd9h6X3u6wqPOx7SIKxwAQR8qeeFq4pP +rt9GAGlxtuYgzIIcKJPwE0dZlcBCg+GnptCUZXp/38BP1eYC+xTXSL6Muq1etYfg +odXdb7Yl+2h1IHuOwo5rjgY5kpY7GcAs8AjGk3lDD/av60OTYccknH0NCVSmPoXK +vrxDBOn0LQRNBLcAfnTKgHrzy0Q5h4TNkkyTgxkoQw5ObDk9nnabTxql732yy9BY +s+hM9+dSFO1HKeVXreYSA2n1ndF18YAvAumzgyqzB7I4pMHXq1kC/8bONMJxwSkS +Ym6CoXKyavp7RqGMyeVpRC7tV+blkrrUml0BwNkxE+XnwDRB3xDV6hqgWe0XrifD +YTfvd9ScZQP83ip0r4IKlq4GMv/R5shcCRJSkSZ6QSGshH40JYSoiwJf5FHbj9ND +7do0UAqebWo4yNx63j/wb2ULorW3AClv0BCFSdPsIrCStiGdpgJDBR2P2NZOCob3 +G9uMj+wJD6JJg2nWqNJxkANXX37Qf8plgzssrhrgOvB0fjjS7GYhfkfmZTJ0wPOw +A8+KzFseBh4UFGgue78KwgkCAwEAAQ== +-----END PUBLIC KEY----- diff --git a/keys/chamesle-20261118.rsa.pub b/keys/chamesle-20261118.rsa.pub @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAuk2uLeY5FngV5mLZiodA +aHWxmSQFqIM8WVQY1gZDYoyOWx5+/xPPqgoMxOHaAyXL9pKF/HNcOb9zUAszy0Ix +9szZhnGVTvfN5gyEsU3ybTPuYlnAe3FH3ywhNx4pkDhds7OTiMJwXrZyWp9YpcJI +h8hHoZkQOCzZN1rBdn8+Gi6bEqLq3dl3E8IyC24+jELkzqIF40M79Pnj5ERjRMJw +0NtIMOxhk4ZT1uFTiGEy6NZWAq1PZyTQCz8kwtvwNOYCwQCR94+61i2ZxSL+a3CN +l6TWaG9WiUc+Vh0kce/JYY0/HyTASuZ71SRMQ9rUzSvym4iPEavx+4SPerEzP/BO +0GrjaKXXBYzdZNnBU8YsJ4qjg28l0MtSdAyZoswIq5NQhK9f2ZJbTCk+jqMuLAz1 +ROwCEsk7KVEaN0K/9hCAf/eARR1U08VsJDuY/z6ONh9PLZBq+Sz4LmUcOlBIGk0m +A/SDBZC9gTMp4VL02NbxlNL7w+PPSDZpKleXcPLbp1wzrS/lVrVNGcHv8J4Zo0nl +I30J7orkJrxwafAr4ZgNsCrjkOoIzgfm9XKwLRa15qKTBCyt29LnvHyC3NsRjLqS +Jisr0ErACvrt1d/8mz6G/8Es4vVAG5Q9xenu9gwanPdHcobZlBRYQzjRA0Yy9LRw +JOQHLEmPe7pXmMydSWR660ECAwEAAQ== +-----END PUBLIC KEY----- diff --git a/pkg/chamesle-base/issue b/pkg/chamesle-base/issue @@ -0,0 +1,2 @@ +Chamesle \r \l + diff --git a/pkg/chamesle-base/os-release b/pkg/chamesle-base/os-release @@ -0,0 +1,4 @@ +NAME="Chamesle" +ID=chamesle +PRETTY_NAME="Chamesle" +HOME_URL="https://chamesle.org" diff --git a/pkg/chamesle-base/post-install b/pkg/chamesle-base/post-install @@ -0,0 +1,8 @@ +#!/bin/sh +cat > /etc/motd <<M +Chamesle. The handbook is /usr/share/doc/chamesle/handbook.md, mag help says how to get more. + +M +sed -i 's|^root:\([^:]*\):0:0:\([^:]*\):/root:/bin/sh$|root:\1:0:0:\2:/root:/bin/mksh|' /etc/passwd +grep -qx /bin/mksh /etc/shells || echo /bin/mksh >> /etc/shells +exit 0 diff --git a/pkg/chamesle-base/repos b/pkg/chamesle-base/repos @@ -0,0 +1,3 @@ +https://chamesle.org/repo +https://dl-cdn.alpinelinux.org/alpine/v3.24/main +https://dl-cdn.alpinelinux.org/alpine/v3.24/community diff --git a/tools/chamesle-bootstrap b/tools/chamesle-bootstrap @@ -1,93 +1,44 @@ #!/bin/sh -# chamesle-bootstrap TARGET: makes a root file system in TARGET, like debootstrap does for Debian. -# the directories, init and its files from files/, the files in /etc, then every package of the base set built and installed there with mag. -# chamesle-bootstrap /mnt/root -# chamesle-bootstrap -r ~/repos/ports -s "shells/mksh editors/vim" /srv/chroot +# chamesle-bootstrap TARGET [PACKAGE]...: puts the Chamesle base into TARGET with mag, like debootstrap does for Debian. +# the repos and the keys are this system's, from /etc/mag. the base is chamesle-base, a kernel and what they need. +# chamesle-bootstrap /mnt +# chamesle-bootstrap -a x86 -n box /mnt vim set -e -here=$(cd "$(dirname "$0")" && pwd) usage() { - echo "usage: chamesle-bootstrap [-r REPOS] [-s PACKAGES] [-n HOSTNAME] TARGET" >&2 - echo " -r repos split by colons, what mag takes in MAG_REPO (default: \$MAG_REPO)" >&2 - echo " -s the packages to install instead of the base set" >&2 + echo "usage: chamesle-bootstrap [-a ARCH] [-n HOSTNAME] [-k KERNEL] [-f FIRMWARE] TARGET [PACKAGE]..." >&2 + echo " -a x86_64, x86 and so on (default: this machine's)" >&2 echo " -n host name of the new system (default chamesle)" >&2 + echo " -k the kernel package (default linux-lts), -f its firmware (default linux-firmware-none)" >&2 exit 2 } -base="sys-libs/musl devel/gmake lang/nawk 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" -name=chamesle -while getopts r:s:n: o; do +arch= name=chamesle kernel=linux-lts firmware=linux-firmware-none +while getopts a:n:k:f: o; do case $o in - r) MAG_REPO=$OPTARG;; - s) base=$OPTARG;; + a) arch=$OPTARG;; n) name=$OPTARG;; + k) kernel=$OPTARG;; + f) firmware=$OPTARG;; *) usage;; esac done shift $((OPTIND - 1)) -[ $# = 1 ] || usage +[ $# -ge 1 ] || usage target=$1 -[ -n "$MAG_REPO" ] || { echo "chamesle-bootstrap: no repos: give -r or set MAG_REPO" >&2; exit 1; } +shift +[ "$(id -u)" = 0 ] || { echo "chamesle-bootstrap: run it as root" >&2; exit 1; } command -v mag >/dev/null || { echo "chamesle-bootstrap: mag is not in PATH" >&2; exit 1; } -[ "$(id -u)" = 0 ] || echo "chamesle-bootstrap: not root, so files will belong to you and the device nodes are skipped" >&2 -mkdir -p "$target" -cd "$target" -for d in 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 usr/local/etc/services var/cache var/lib var/log var/tmp; do - mkdir -p "$d" -done -chmod 1777 tmp var/tmp -chmod 700 root -ln -sfn ../run var/run -files=$here/../files -put() { - for f in "$1"/*; do - d=${f#"$files"/} - if [ -d "$f" ]; then - mkdir -p "$d" - put "$f" - elif [ -x "$f" ]; then - install -m755 "$f" "$d" - elif [ "$d" = etc/init.conf ]; then - [ -e "$d" ] || while IFS= read -r l; do - case $l in hostname*) l="hostname = $name";; esac - echo "$l" - done < "$f" > "$d" - else - install -m644 "$f" "$d" - fi - done -} -put "$files" -[ -e etc/passwd ] || cat > etc/passwd <<P -root:x:0:0:root:/root:/usr/bin/mksh -dhcpcd:x:200:200:dhcpcd:/var/db/dhcpcd:/bin/false -dbus:x:81:81:system bus:/run/dbus:/bin/false -P -[ -e etc/group ] || printf 'root:x:0:\nbin:x:1:\ndaemon:x:2:\nsys:x:3:\nadm:x:4:\ntty:x:5:\ndisk:x:6:\nlp:x:7:\nmem:x:8:\nkmem:x:9:\nwheel:x:10:\nfloppy:x:11:\nmail:x:12:\nuucp:x:14:\nman:x:15:\naudio:x:18:\ncdrom:x:19:\ndialout:x:20:\ntape:x:26:\nvideo:x:27:\ninput:x:97:\nkvm:x:78:\nrender:x:105:\nclock:x:106:\nsgx:x:107:\nusers:x:100:\ndhcpcd:x:200:\ndbus:x:81:\n' > etc/group -[ -e etc/shells ] || printf '/bin/sh\n/usr/bin/mksh\n/usr/bin/ksh\n' > etc/shells -[ -e etc/fstab ] || printf '# device mount type options dump pass\nproc /proc proc defaults 0 0\nsysfs /sys sysfs defaults 0 0\ntmpfs /tmp tmpfs mode=1777 0 0\n' > etc/fstab -[ -e etc/profile ] || cat > etc/profile <<'P' -export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin -export EDITOR="sam -d" -export PAGER=less -umask 022 -P -[ -e etc/os-release ] || printf 'NAME=Chamesle\nID=chamesle\nPRETTY_NAME="Chamesle"\n' > etc/os-release -[ -e etc/mag.conf ] || printf '# read by mag, same syntax as pkgsrc mk.conf\nJOBS=%s\nCFLAGS=-O2 -std=gnu17 -include sys/sysmacros.h\nPKG_OPTIONS.tnftp=ssl\nCONFIGURE_ARGS.libtirpc=--disable-gssapi\nPKG_SYSCONFDIR.libressl=/etc/ssl\nMAKE.libunistring=gmake\nMAKE.sudo=gmake\nCONFIGURE_ARGS.gmp=--disable-assembly --disable-cxx --disable-fat\nPKG_OPTIONS.opendoas=persist\nCONFIGURE_ARGS.doas=--without-pam\n' "$(nproc 2>/dev/null || echo 4)" > etc/mag.conf -export MAG_ROOT=$PWD MAG_PREFIX=/usr MAG_REPO -echo "installing: $base" -mag install $base -for r in $(echo "$MAG_REPO" | tr : ' '); do - [ -f "$r/PROVIDES" ] || continue - mkdir -p usr/share/mag/repo - cp -R "$r/." usr/share/mag/repo/ - break -done -for t in chamesle-chroot chamesle-disk; do install -m755 "$here/$t" usr/bin/$t; done -for k in lib/modules/*; do - [ -d "$k" ] || continue - depmod -b "$PWD" "${k##*/}" -done -mkdir -p etc/ssl -for f in cert.pem openssl.cnf x509v3.cnf; do [ -e etc/ssl/$f ] || cp usr/libressl/share/examples/libressl/$f etc/ssl/ 2>/dev/null; done -[ -e usr/bin/sh ] || ln -s mksh usr/bin/sh -[ -e bin/sh ] || ln -s ../usr/bin/sh bin/sh -echo "done: $target" +[ -f /etc/mag/repos ] && [ -d /etc/mag/keys ] || { echo "chamesle-bootstrap: /etc/mag/repos and /etc/mag/keys are needed" >&2; exit 1; } + +mkdir -p "$target/etc/mag" "$target/dev" "$target/proc" "$target/sys" "$target/run" "$target/tmp" "$target/boot" +chmod 1777 "$target/tmp" +cp /etc/mag/repos "$target/etc/mag/repos" +cp -R /etc/mag/keys "$target/etc/mag/" +[ -n "$arch" ] && echo "$arch" > "$target/etc/mag/arch" +export MAG_ROOT=$target +mag update +# the kernel wants some firmware; the vendor packages do not count as that, so -none goes with them +case $firmware in linux-firmware|linux-firmware-none) ;; *) firmware="linux-firmware-none $firmware";; esac +mag install chamesle-base $firmware $kernel "$@" +sed -i "s/^hostname = .*/hostname = $name/" "$target/etc/init.conf" +echo +echo "the base is in $target. go on with the fstab, a password and the boot entry (handbook, 3.4)." diff --git a/tools/chamesle-chroot b/tools/chamesle-chroot @@ -7,7 +7,7 @@ dir=$1 shift [ -d "$dir" ] || { echo "chamesle-chroot: $dir is not a directory" >&2; exit 1; } [ "$(id -u)" = 0 ] || { echo "chamesle-chroot: needs root" >&2; exit 1; } -[ $# -gt 0 ] || set -- /usr/bin/mksh -l +[ $# -gt 0 ] || set -- /bin/mksh -l mounted= cleanup() { diff --git a/tools/mkapk b/tools/mkapk @@ -0,0 +1,71 @@ +#!/bin/sh +# mkapk: packs DIR into a package mag installs, signed with KEY, and leaves its index entry in OUT/.idx for mkrepo. +# mkapk -k KEY -n NAME -v VERSION -a ARCH -d DESC [-D DEPS] [-s SCRIPTS] [-o OUT] DIR +# SCRIPTS is a directory with any of post-install, pre-upgrade and the rest +set -e +# GNU tar, for --record-size and --sort +tar=$(command -v gtar || echo tar) +deps= scripts= out=. +while getopts k:n:v:a:d:D:s:o: o; do + case $o in + k) key=$OPTARG;; n) name=$OPTARG;; v) ver=$OPTARG;; a) arch=$OPTARG;; d) desc=$OPTARG;; + D) deps=$OPTARG;; s) scripts=$OPTARG;; o) out=$OPTARG;; + *) exit 2;; + esac +done +shift $((OPTIND - 1)) +dir=$1 +if [ -z "$key" ] || [ -z "$name" ] || [ -z "$ver" ] || [ -z "$arch" ] || [ ! -d "$dir" ]; then + echo "usage: mkapk -k KEY -n NAME -v VERSION -a ARCH -d DESC [-D DEPS] [-s SCRIPTS] [-o OUT] DIR" >&2 + exit 2 +fi +mkdir -p "$out/.idx" +tmp=$(mktemp -d "$out/.mkapk.XXXXXX") +trap 'rm -rf "$tmp"' EXIT +mkdir "$tmp/c" "$tmp/s" + +# the signature and the control part are tar without the two zero blocks at the end, so the pieces run on into each other +seg() { $tar --format=ustar --record-size=512 --owner=0 --group=0 --numeric-owner -C "$1" -cf - "$2" $3 | head -c -1024 | gzip -9n; } + +$tar --format=gnu --owner=0 --group=0 --numeric-owner --sort=name -C "$dir" -cf - . | gzip -9n > "$tmp/data.tar.gz" +{ + echo "pkgname = $name" + echo "pkgver = $ver" + echo "pkgdesc = $desc" + echo "url = https://chamesle.org" + echo "builddate = $(date +%s)" + echo "size = $(du -sb "$dir" | cut -f1)" + echo "arch = $arch" + echo "license = BSD-2-Clause" + for d in $deps; do echo "depend = $d"; done + echo "datahash = $(sha256sum "$tmp/data.tar.gz" | cut -d' ' -f1)" +} > "$tmp/c/.PKGINFO" +more= +for s in pre-install post-install pre-upgrade post-upgrade pre-deinstall post-deinstall trigger; do + [ -n "$scripts" ] && [ -f "$scripts/$s" ] || continue + install -m755 "$scripts/$s" "$tmp/c/.$s" + more="$more .$s" +done +seg "$tmp/c" .PKGINFO "$more" > "$tmp/control.tar.gz" + +kn=$(basename "$key").pub +openssl dgst -sha256 -sign "$key" -out "$tmp/s/.SIGN.RSA256.$kn" "$tmp/control.tar.gz" +seg "$tmp/s" ".SIGN.RSA256.$kn" > "$tmp/sig.tar.gz" + +old=$(cat "$out/.idx/$name" 2>/dev/null | sed -n "s/^V://p") +if [ -n "$old" ] && [ "$old" != "$ver" ]; then rm -f "$out/$name-$old.apk"; fi +cat "$tmp/sig.tar.gz" "$tmp/control.tar.gz" "$tmp/data.tar.gz" > "$out/$name-$ver.apk" +{ + echo "C:Q1$(openssl dgst -sha1 -binary "$tmp/control.tar.gz" | base64 -w0)" + echo "P:$name" + echo "V:$ver" + echo "A:$arch" + echo "S:$(wc -c < "$out/$name-$ver.apk")" + echo "I:$(du -sb "$dir" | cut -f1)" + echo "T:$desc" + echo "U:https://chamesle.org" + echo "L:BSD-2-Clause" + if [ -n "$deps" ]; then echo "D:$(echo $deps)"; fi + echo +} > "$out/.idx/$name" +echo "$out/$name-$ver.apk" diff --git a/tools/mkpkgs b/tools/mkpkgs @@ -0,0 +1,40 @@ +#!/bin/sh +# mkpkgs ARCH OUT: Chamesle's own packages for one arch, signed with KEY, and the index of OUT. +# KEY=~/.chamesle-keys/chamesle-20261118.rsa MAG=~/src/mag/mag RIFLE=~/src/rifle/rifle mkpkgs x86_64 repo/x86_64 +# RIFLE is left out where rifle does not build (it is x86_64 only for now). REL is the -rN of the base's version +set -e +here=$(cd "$(dirname "$0")/.." && pwd) +[ $# = 2 ] && [ -f "$KEY" ] && [ -x "$MAG" ] || { echo "usage: KEY=... MAG=... [RIFLE=...] mkpkgs ARCH OUT" >&2; exit 2; } +arch=$1 out=$2 +mkdir -p "$out" +tmp=$(mktemp -d "$out/.mkpkgs.XXXXXX") +trap 'rm -rf "$tmp"' EXIT +mkapk() { "$here/tools/mkapk" -k "$KEY" -a "$arch" -o "$out" "$@"; } + +mkdir -p "$tmp/mag/usr/bin" +install -m755 "$MAG" "$tmp/mag/usr/bin/mag" +mkapk -n mag -v "$("$MAG" --version | cut -d' ' -f2)" -d "the package manager" "$tmp/mag" + +deps="alpine-baselayout busybox busybox-binsh mksh agetty eudev kmod dhcpcd e2fsprogs dosfstools curl mag" +if [ -n "$RIFLE" ]; then + mkdir -p "$tmp/rifle/usr/bin" + install -m755 "$RIFLE" "$tmp/rifle/usr/bin/rifle" + for t in $("$RIFLE" --list); do ln -s rifle "$tmp/rifle/usr/bin/$t"; done + mkapk -n rifle -v "$("$RIFLE" --version | head -n 1 | cut -d' ' -f2)" -d "the coreutils, in one program" "$tmp/rifle" + deps="$deps rifle" +fi + +b=$tmp/base +cp -R "$here/files" "$b" +rm -f "$b/etc/hosts" "$b/etc/services" "$b/usr/bin/cc" "$b/usr/bin/zcat" +mkdir -p "$b/etc/mag/keys" "$b/etc/apk" "$b/usr/bin" "$b/usr/share/doc/chamesle" +cp "$here/keys/"*.pub "$b/etc/mag/keys/" +ln -s ../mag/keys "$b/etc/apk/keys" +cp "$here/pkg/chamesle-base/repos" "$b/etc/mag/repos" +cp "$here/pkg/chamesle-base/os-release" "$here/pkg/chamesle-base/issue" "$b/etc/" +for t in chamesle-bootstrap chamesle-chroot chamesle-disk; do install -m755 "$here/tools/$t" "$b/usr/bin/$t"; done +cp "$here/handbook/handbook.md" "$b/usr/share/doc/chamesle/handbook.md" +mkapk -n chamesle-base -v "$(date +%Y%m%d)-r${REL:-0}" -d "Winchester, the files in /etc and the tools of Chamesle" \ + -D "$deps" -s "$here/pkg/chamesle-base" "$b" + +"$here/tools/mkrepo" "$out" "$KEY" diff --git a/tools/mkrepo b/tools/mkrepo @@ -0,0 +1,18 @@ +#!/bin/sh +# mkrepo DIR KEY: the signed APKINDEX.tar.gz for the packages mkapk put in DIR +set -e +# GNU tar, for --record-size and --sort +tar=$(command -v gtar || echo tar) +[ $# = 2 ] && [ -d "$1/.idx" ] || { echo "usage: mkrepo DIR KEY" >&2; exit 2; } +dir=$1 key=$2 +tmp=$(mktemp -d "$dir/.mkrepo.XXXXXX") +trap 'rm -rf "$tmp"' EXIT +mkdir "$tmp/i" "$tmp/s" +cat "$dir"/.idx/* > "$tmp/i/APKINDEX" +echo "chamesle $(date +%Y%m%d)" > "$tmp/i/DESCRIPTION" +$tar --format=ustar --owner=0 --group=0 --numeric-owner -C "$tmp/i" -cf - DESCRIPTION APKINDEX | gzip -9n > "$tmp/index.tar.gz" +kn=$(basename "$key").pub +openssl dgst -sha256 -sign "$key" -out "$tmp/s/.SIGN.RSA256.$kn" "$tmp/index.tar.gz" +$tar --format=ustar --record-size=512 --owner=0 --group=0 --numeric-owner -C "$tmp/s" -cf - ".SIGN.RSA256.$kn" | head -c -1024 | gzip -9n > "$tmp/sig.tar.gz" +cat "$tmp/sig.tar.gz" "$tmp/index.tar.gz" > "$dir/APKINDEX.tar.gz" +echo "$dir/APKINDEX.tar.gz: $(grep -c '^P:' "$tmp/i/APKINDEX") packages"