chamesle

chamesle.org: the site of Chamesle, a small Linux distribution
git clone https://github.com/tortr-rs/chamesle
Log | Files | Refs | README

commit eecef3e32f7dfc37c2e5d58e547cc7c1617583ae
parent 8e30b09a30602c156ae47bab7fa34ceb1bac17b5
Author: torter <koubbamohamedrayan@gmail.com>
Date:   Mon, 16 Nov 2026 19:59:02 +0000

site: the handbook is eleven pages now, one for each chapter and a contents page, split from the handbook in the system repo

Diffstat:
Mdocs/docs.html | 192++++++++++++++-----------------------------------------------------------------
Adocs/handbook-about.html | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/handbook-base.html | 161+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/handbook-files.html | 118+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/handbook-installing.html | 184+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/handbook-iso.html | 116+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/handbook-kernel.html | 103+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/handbook-mag.html | 146+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/handbook-maintaining.html | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/handbook-preparing.html | 103+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/handbook-rifle.html | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdocs/sitemap.xml | 12+++++++++++-
12 files changed, 1253 insertions(+), 159 deletions(-)

diff --git a/docs/docs.html b/docs/docs.html @@ -4,12 +4,12 @@ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Handbook - Chamesle</title> -<meta name="description" content="The Chamesle handbook: getting a root file system, mag, the kernel, the live ISO and the files of the system."> +<meta name="description" content="The Chamesle handbook, chapter by chapter: preparing, installing by hand, mag, rifle, the base system, the kernel, the live ISO and the files of the system."> <link rel="canonical" href="https://chamesle.org/docs.html"> <meta property="og:type" content="website"> <meta property="og:site_name" content="Chamesle"> <meta property="og:title" content="Handbook - Chamesle"> -<meta property="og:description" content="The Chamesle handbook: getting a root file system, mag, the kernel, the live ISO and the files of the system."> +<meta property="og:description" content="The Chamesle handbook, chapter by chapter: preparing, installing by hand, mag, rifle, the base system, the kernel, the live ISO and the files of the system."> <meta property="og:url" content="https://chamesle.org/docs.html"> <link rel="stylesheet" href="style.css?13"> </head> @@ -36,163 +36,39 @@ <main> <h2>The handbook</h2> -<p><i>How to build and install Chamesle.</i></p> - -<p>The kernel is the only thing in it that comes from outside the Unix family. The C library is musl, the shell is -mksh, the packages come from NetBSD's pkgsrc and the package manager is <code>mag</code>.</p> -<p>You put Chamesle on a disk yourself, by hand, in <a href="#disk">chapter 5</a>. These pages describe the code as it is today. It changes.</p> -<div class="toc"> -<h4>Contents</h4> -<a href="#parts">What is in it</a> <a href="#root">1. Root file system</a> <a href="#mag">2. mag</a> -<a href="#kernel">3. The kernel</a> <a href="#iso">4. The live ISO</a> <a href="#disk">5. Installing by hand</a> -<a href="#files">6. Files</a> -</div> - -<h2 id="parts">What is in it</h2> -<table class="grid"> -<tr><th>part</th><th>what it is</th></tr> -<tr><td>kernel</td><td>Linux 6.18 LTS, prebuilt</td></tr> -<tr><td>musl</td><td>the C library</td></tr> -<tr><td>rifle</td><td>the coreutils, one C file</td></tr> -<tr><td>mag</td><td>the package manager, reads pkgsrc packages as they are</td></tr> -<tr><td>init</td><td>a shell script in the FreeBSD style, <code>/sbin/init</code> and <code>/etc/rc</code>, set up in <code>/etc/init.conf</code> (<code>boot-services</code>, scripts in <code>/etc/rc.d</code>, run with <code>service</code>)</td></tr> -<tr><td>mksh</td><td>the shell: login shell and <code>/bin/sh</code> (the MirBSD Korn shell)</td></tr> -<tr><td>vim</td><td>the editor, installed on the ISO</td></tr> -<tr><td>limine</td><td>the boot loader</td></tr> -<tr><td>ZFS</td><td>the root file system of an installed system, or ext4 if you prefer</td></tr> -</table> - -<h2 id="root">1. Getting a root file system</h2> -<p><code>tools/chamesle-bootstrap</code> is to Chamesle what debootstrap is to Debian. It makes the directories and the -files in <code>/etc</code>, then builds and installs the base packages into the directory you give it, with mag:</p> -<pre>MAG_REPO=$HOME/src/mag/repo:/usr/pkgsrc chamesle-bootstrap /mnt/root</pre> -<p>Building everything from source takes a while. LLVM is the long one. Packages are not built twice: the sources are -kept in <code>var/cache/mag</code> inside the target.</p> -<p><code>-s "shells/mksh editors/vim"</code> installs your own list. <code>-n name</code> sets the host name.</p> -<p>The base set has a compiler, <code>lang/clang</code> with <code>devel/lld</code>, <code>lang/compiler-rt</code> and -<code>lang/libunwind</code>, so a fresh install builds what you ask of mag by itself. It also has ZFS (<code>sys-fs/zfs</code> -and <code>sys-kernel/zfs-module</code>), and gets Chamesle's recipes in <code>/usr/share/mag/repo</code>.</p> - -<h2 id="mag">2. mag</h2> -<pre>mag install editors/vim fetch, check the checksum, build, install, dependencies first -mag remove vim -mag upgrade rebuild what has a newer version -mag search word | info pkg | files pkg | owns /path | deps pkg | list</pre> -<pre>mag sync fetch the pkgsrc tree into /usr/pkgsrc, again to bring it up to date</pre> -<p><code>MAG_REPO</code> is a list of repos split by colons, <code>/usr/share/mag/repo:/usr/pkgsrc</code> if you do not set it. Two kinds of package live in them and can be mixed:</p> -<ul> -<li>our own recipes, <code>category/name</code>, a file with <code>url</code>, <code>sha256</code>, <code>deps</code> and plain sh <code>steps</code></li> -<li>NetBSD pkgsrc packages: a directory with a <code>Makefile</code>, a <code>distinfo</code> and <code>patches/</code>, read without bmake</li> -</ul> -<p>A file called <code>PROVIDES</code> in a repo says which of our packages stands in for a pkgsrc one, so a pkgsrc package -gets our zlib and not a second one. It also lists the dependencies a pkgsrc Makefile forgets (<code>needs</code>). -Everything lands in <code>$MAG_ROOT</code>. Nothing is ever installed over a file another package owns, and -<code>/etc</code> files you changed stay.</p> - -<h3 id="magconf">/etc/mag.conf</h3> -<p>pkgsrc's <code>mk.conf</code> syntax: plain <code>VAR=value</code> lines, read from <code>$MAG_ROOT/etc/mag.conf</code>.</p> -<pre>JOBS=8 # $JOBS in the steps, make -j -CFLAGS=-O2 -pipe # also CXXFLAGS, CPPFLAGS, LDFLAGS, for every build -PKG_DEFAULT_OPTIONS=-http2 idn # options for every pkgsrc package that has them, a minus turns one off -PKG_OPTIONS.vim=python # the options of one package</pre> -<p><code>mag info net/tnftp</code> shows the options a package ends up with, and its dependencies change with them. -Packages of our own repo have no options. They only see <code>JOBS</code> and the flags. Environment wins over the -file (<code>MAG_JOBS</code>, <code>CFLAGS</code>).</p> - -<h2 id="kernel">3. The kernel</h2> -<p>Nobody here builds a kernel. <code>sys-kernel/linux</code> is a prebuilt Linux 6.18 LTS kernel and its modules -(a generic config, so it runs on nearly any machine). mag fetches it from -the binary mirror named in the recipe, checks the checksum and puts <code>vmlinuz</code>, <code>config</code>, <code>System.map</code> and the -modules into <code>/boot</code> and <code>/lib/modules</code>.</p> -<p>The mirror drops a package when a newer one comes out, so a new kernel is a new <code>version</code> and -<code>sha256</code> in <code>repo/sys-kernel/linux</code>. The firmware is <code>sys-kernel/linux-firmware</code>.</p> - -<h2 id="iso">4. The ISO</h2> -<p>The ISO is a live system to install from, nothing more. Chamesle is put on a disk by hand -(<a href="#disk">chapter 5</a>). It boots on BIOS and UEFI machines with limine, from a CD or a stick, and has mksh, -vim, mag with our recipes (<code>mag search</code> works before <code>mag sync</code>), <code>chamesle-bootstrap</code>, -<code>chamesle-chroot</code>, <code>chamesle-disk</code>, the disk tools (cfdisk, sfdisk, mkfs.ext4, mkfs.fat, zpool, zfs) and this handbook in -<code>/usr/share/doc/chamesle/</code>.</p> -<pre>iso/mkiso -r $HOME/src/mag/repo:/usr/pkgsrc</pre> -<p>What it does, in order:</p> -<ol> -<li><code>chamesle-bootstrap</code> builds a root from <code>iso/profile/packages</code>.</li> -<li>The files of <code>iso/profile/overlay</code>, the handbook, <code>mag</code> with its recipes, <code>chamesle-bootstrap</code>, <code>chamesle-chroot</code> and <code>chamesle-disk</code> are copied over it.</li> -<li><code>mkinitramfs</code> makes the initrd: a few static tools, the modules in <code>iso/profile/modules</code> with what they depend on, and <code>iso/init</code>.</li> -<li>The root becomes a zstd squashfs.</li> -<li><code>xorriso</code> writes the ISO with limine's BIOS and UEFI boot images.</li> -</ol> -<p><code>-R dir</code> uses a root you already have instead of building one. It is copied, not changed.</p> -<p>At boot, <code>init</code> looks for the medium that has <code>LiveOS/rootfs.sfs</code>, mounts it read-only, puts a tmpfs -overlay over it and switches into the result. The medium and the squashfs stay mounted under <code>/run/live/</code>.</p> -<p>Try an ISO without a machine:</p> -<pre>qemu-system-x86_64 -cpu max -m 1G -cdrom chamesle.iso -boot d -qemu-system-x86_64 -cpu max -m 1G -bios /usr/share/qemu/edk2-x86_64-code.fd -cdrom chamesle.iso # uefi</pre> -<p>mkiso needs <code>mksquashfs</code> (filesystems/squashfs), <code>xorriso</code> (sysutils/libisoburn), <code>zstd</code>, -<code>bsdcpio</code>, <code>limine</code> and <code>mag</code> on the machine that builds. <code>LIMINE</code> says where -limine's files are (default <code>/usr/share/limine</code>), <code>MAG</code> where mag is.</p> - -<h2 id="disk">5. Installing by hand</h2> -<p>Boot the ISO, log in as root, bring the network up (<code>dhcpcd</code>) and do this. <code>sda</code> is the -disk, change it. <code>chamesle-disk</code> only prepares the disk; the install itself stays by hand.</p> +<p><i>How to build, install and run Chamesle.</i></p> <ol> -<li>Partition and format with <code>chamesle-disk /dev/sda</code>. It asks you to type the disk name before it erases -anything, then starts <code>cfdisk</code>: make a GPT with a 1M BIOS boot partition, a 512M EFI partition and the rest -for <code>/</code>. Then say which partition is the boot partition and which is the root. The boot partition becomes -vfat, the root a ZFS pool <code>rpool</code> with the datasets <code>rpool/root</code>, <code>rpool/home</code> and -<code>rpool/var</code>. Everything is mounted under <code>/mnt</code> and <code>/mnt/etc/fstab</code> is written: the boot -partition by UUID, <code>proc</code>, <code>sysfs</code>, <code>tmpfs</code>, and nothing for ZFS, which mounts its own -datasets. limine cannot read ZFS, so the kernel, the initrd and <code>limine.conf</code> are on the vfat partition.</li> -<li>Or do it yourself, for a root on ext4: -<pre>sfdisk /dev/sda &lt;&lt;P -label: gpt -size=1M, type=21686148-6449-6E6F-744E-656564454649 -size=512M, type=U -type=L -P -mkfs.fat -F32 /dev/sda2 -mkfs.ext4 /dev/sda3 -mount /dev/sda3 /mnt -mkdir /mnt/boot -mount /dev/sda2 /mnt/boot</pre></li> -<li>Put the system in <code>/mnt</code>. Copy the live one, which is quick: -<pre>tar -C /run/live/rootfs --exclude ./etc/fstab -cf - . | tar -C /mnt -xpf - -[ -e /mnt/etc/fstab ] || cp /run/live/rootfs/etc/fstab /mnt/etc/fstab -cp /run/live/medium/boot/initrd /mnt/boot/initrd</pre> -Or build it from source on a machine with a compiler, with <code>chamesle-bootstrap -n yourhostname /mnt</code> -(<code>MAG_REPO</code> set), which takes a while.</li> -<li>Work in the new root with <code>chamesle-chroot /mnt</code>, or run one command there: -<code>chamesle-chroot /mnt mag install ...</code>. It mounts <code>proc</code>, <code>sys</code>, <code>dev</code> and -<code>run</code>, and unmounts them when it ends.</li> -<li>Set the password and the boot entry by hand. <code>blkid</code> gives the UUIDs. With a ZFS root fstab has -only the boot line already; with ext4 add the root line. -<pre>echo 'root:x:0:0:root:/root:/usr/bin/mksh' &gt; /mnt/etc/passwd # then put a hash in the second field -vim /mnt/etc/fstab -cp /mnt/usr/share/limine/BOOTX64.EFI /mnt/boot/EFI/BOOT/ -vim /mnt/boot/limine.conf</pre> -limine.conf: -<pre>timeout: 3 -/Chamesle - protocol: linux - path: boot():/vmlinuz-6.18.63-0-lts - module_path: boot():/initrd - cmdline: root=UUID=THE-ROOT-UUID rw</pre> -On ZFS the command line is <code>root=ZFS=rpool/root rw</code>.</li> -<li>Install limine for BIOS, unmount and reboot: <code>limine bios-install /dev/sda</code>, <code>umount -R /mnt</code>, -and on ZFS <code>zpool export rpool</code>.</li> -<li>On the new system run <code>mag sync</code>, and <code>mag install</code> builds anything from pkgsrc.</li> +<li><a href="handbook-about.html">About Chamesle</a> +<ul><li><a href="handbook-about.html#s1-1">1.1 What it is</a></li><li><a href="handbook-about.html#s1-2">1.2 The layout of the system</a></li><li><a href="handbook-about.html#s1-3">1.3 Where the sources are</a></li></ul> +</li> +<li><a href="handbook-preparing.html">Preparing</a> +<ul><li><a href="handbook-preparing.html#s2-1">2.1 What the build host needs</a></li><li><a href="handbook-preparing.html#s2-2">2.2 Building mag and rifle</a></li><li><a href="handbook-preparing.html#s2-3">2.3 Getting the pkgsrc tree</a></li><li><a href="handbook-preparing.html#s2-4">2.4 MAG_REPO</a></li><li><a href="handbook-preparing.html#s2-5">2.5 mag.conf</a></li></ul> +</li> +<li><a href="handbook-installing.html">Installing by hand</a> +<ul><li><a href="handbook-installing.html#s3-1">3.1 chamesle-disk</a></li><li><a href="handbook-installing.html#s3-2">3.2 Partitioning and file systems by hand</a></li><li><a href="handbook-installing.html#s3-3">3.3 Copying the live system</a></li><li><a href="handbook-installing.html#s3-4">3.4 Building the system from source, instead</a></li><li><a href="handbook-installing.html#s3-5">3.5 rifle</a></li><li><a href="handbook-installing.html#s3-6">3.6 fstab</a></li><li><a href="handbook-installing.html#s3-7">3.7 Host name, users, password</a></li><li><a href="handbook-installing.html#s3-8">3.8 The kernel and the boot entry</a></li><li><a href="handbook-installing.html#s3-9">3.9 First boot</a></li></ul> +</li> +<li><a href="handbook-mag.html">Using mag</a> +<ul><li><a href="handbook-mag.html#s4-1">4.1 The commands</a></li><li><a href="handbook-mag.html#s4-2">4.2 Installing and removing</a></li><li><a href="handbook-mag.html#s4-3">4.3 Finding things</a></li><li><a href="handbook-mag.html#s4-4">4.4 Installing somewhere else</a></li><li><a href="handbook-mag.html#s4-5">4.5 Other variables</a></li><li><a href="handbook-mag.html#s4-6">4.6 pkgsrc options</a></li><li><a href="handbook-mag.html#s4-7">4.7 Writing a recipe</a></li></ul> +</li> +<li><a href="handbook-rifle.html">rifle</a> +<ul><li><a href="handbook-rifle.html#s5-1">5.1 What it is</a></li><li><a href="handbook-rifle.html#s5-2">5.2 The tools</a></li><li><a href="handbook-rifle.html#s5-3">5.3 Building</a></li><li><a href="handbook-rifle.html#s5-4">5.4 Tests</a></li></ul> +</li> +<li><a href="handbook-base.html">The base system</a> +<ul><li><a href="handbook-base.html#s6-1">6.1 init</a></li><li><a href="handbook-base.html#s6-2">6.2 rc, init.conf and the services</a></li><li><a href="handbook-base.html#s6-3">6.3 Shutting down</a></li><li><a href="handbook-base.html#s6-4">6.4 The files in /etc</a></li><li><a href="handbook-base.html#s6-5">6.5 Users</a></li><li><a href="handbook-base.html#s6-6">6.6 udev and modules</a></li><li><a href="handbook-base.html#s6-7">6.7 Networking</a></li><li><a href="handbook-base.html#s6-8">6.8 Wireless</a></li><li><a href="handbook-base.html#s6-9">6.9 Mounting and disks</a></li></ul> +</li> +<li><a href="handbook-kernel.html">The kernel and firmware</a> +<ul><li><a href="handbook-kernel.html#s7-1">7.1 The kernel package</a></li><li><a href="handbook-kernel.html#s7-2">7.2 Updating</a></li><li><a href="handbook-kernel.html#s7-3">7.3 Modules</a></li><li><a href="handbook-kernel.html#s7-4">7.4 Firmware</a></li><li><a href="handbook-kernel.html#s7-5">7.5 An initramfs</a></li></ul> +</li> +<li><a href="handbook-iso.html">The live ISO</a> +<ul><li><a href="handbook-iso.html#s8-1">8.1 What it is</a></li><li><a href="handbook-iso.html#s8-2">8.2 Building</a></li><li><a href="handbook-iso.html#s8-3">8.3 The profile</a></li><li><a href="handbook-iso.html#s8-4">8.4 How it boots</a></li><li><a href="handbook-iso.html#s8-5">8.5 Trying it in qemu</a></li></ul> +</li> +<li><a href="handbook-maintaining.html">Maintaining</a> +<ul><li><a href="handbook-maintaining.html#s9-1">9.1 Updating packages</a></li><li><a href="handbook-maintaining.html#s9-2">9.2 Cleaning up</a></li><li><a href="handbook-maintaining.html#s9-3">9.3 C23 and CFLAGS</a></li><li><a href="handbook-maintaining.html#s9-4">9.4 The root&#x27;s compiler and mag relocate</a></li><li><a href="handbook-maintaining.html#s9-5">9.5 libtool</a></li><li><a href="handbook-maintaining.html#s9-6">9.6 Failures you will see</a></li><li><a href="handbook-maintaining.html#s9-7">9.7 Keeping a build</a></li></ul> +</li> +<li><a href="handbook-files.html">File reference</a> +<ul><li><a href="handbook-files.html#s10-1">10.1 On an installed system</a></li><li><a href="handbook-files.html#s10-2">10.2 In the sources</a></li><li><a href="handbook-files.html#s10-3">10.3 Commands in short</a></li></ul> +</li> </ol> -<p>The initrd from the ISO finds a root by <code>root=UUID=</code>, <code>root=ZFS=</code> or a device. For anything else, -RAID or an encrypted disk, build your own with <code>iso/mkinitramfs</code>.</p> - -<h2 id="files">6. Files</h2> -<table class="grid"> -<tr><td><code>/etc/profile</code></td><td>PATH, EDITOR=vim</td></tr> -<tr><td><code>/etc/ksh.kshrc</code></td><td>prompt and aliases of every ksh</td></tr> -<tr><td><code>/etc/fstab</code>, <code>hostname</code>, <code>passwd</code>, <code>group</code>, <code>shells</code></td><td>the usual</td></tr> -<tr><td><code>/var/lib/mag</code></td><td>what is installed, per package</td></tr> -<tr><td><code>/var/cache/mag</code></td><td>downloaded sources</td></tr> -</table> </main> <hr> @@ -201,7 +77,7 @@ Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> Chamesle is installed by hand, from the <a href="docs.html">handbook</a>.<br> <a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> <a href="#" id="edit-link">Edit text</a><br> -$Date: 2026-11-14 $ +$Date: 2026-11-16 $ </div> </div> diff --git a/docs/handbook-about.html b/docs/handbook-about.html @@ -0,0 +1,93 @@ +<!doctype html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>About Chamesle - Chamesle</title> +<meta name="description" content="Chamesle is a Linux distribution you build from source and put on a disk yourself. There is no installer: you"> +<link rel="canonical" href="https://chamesle.org/handbook-about.html"> +<meta property="og:type" content="website"> +<meta property="og:site_name" content="Chamesle"> +<meta property="og:title" content="About Chamesle - Chamesle"> +<meta property="og:description" content="Chamesle is a Linux distribution you build from source and put on a disk yourself. There is no installer: you"> +<meta property="og:url" content="https://chamesle.org/handbook-about.html"> +<link rel="stylesheet" href="style.css?13"> +</head> +<body> + +<div id="page"> + +<div id="top"> +<h1><a href="./">Chamesle</a></h1> +</div> + +<div id="nav"> +<a href="./">Home</a> | +<a href="download.html">Install</a> | +<b>Handbook</b> | +<a href="packages.html">Packages</a> | +<a href="new.html">News</a> | +<a href="board.html">Board</a> | +<a href="chat.html">Chat</a> | +<a href="source.html">Source</a> | +<a href="https://x22.chamesle.org/">X22</a> | +<a href="about.html">About</a> +</div> + +<main> +<p><a href="docs.html">Contents</a> | <a href="handbook-preparing.html">Preparing &rarr;</a></p> +<h2>1. About Chamesle</h2> +<h2 id="s1-1">1.1 What it is</h2> +<p>Chamesle is a Linux distribution you build from source and put on a disk yourself. There is no installer: you install the root file system, write the configuration and the boot entry by hand. <code>chamesle-disk</code> partitions and formats the disk for you if you want, and this handbook goes through every other step.</p> +<p>The parts:</p> +<table> +<tr><th>part</th><th>what it is</th></tr> +<tr><td>kernel</td><td>a prebuilt Linux 6.18 LTS kernel with its modules</td></tr> +<tr><td>musl</td><td>the C library</td></tr> +<tr><td>rifle</td><td>the coreutils, all in one C file; <code>cat</code>, <code>ls</code>, <code>cp</code> and the rest are links to one program</td></tr> +<tr><td>mag</td><td>the package manager; it reads NetBSD pkgsrc packages as they are, and recipes of its own</td></tr> +<tr><td>mksh</td><td>the shell, login shell and <code>/bin/sh</code></td></tr> +<tr><td>init</td><td><code>/sbin/init</code>, a shell script that runs under mksh, in the style of FreeBSD's: <code>/etc/rc</code>, <code>/etc/init.conf</code>, services</td></tr> +<tr><td>limine</td><td>the boot loader, BIOS and UEFI</td></tr> +</table> +<p>There is nothing from GNU in the system. Two exceptions are on the machine that builds: the kernel's own build tools, and <code>gmake</code>, which musl's Makefile needs.</p> +<p>The package repository is NetBSD's pkgsrc, read directly by <code>mag</code> without <code>bmake</code>. Chamesle adds hand-written recipes only for what pkgsrc does not have: musl, the kernel, its headers and firmware, limine, eudev, kmod, util-linux, iw, libnl, iproute2, usbutils, netbsd-curses, libtool and ZFS. Everything is built on the machine that installs it, so the first install takes a while (LLVM is the longest).</p> +<h2 id="s1-2">1.2 The layout of the system</h2> +<pre>/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/local/bin yours, first in PATH +/boot kernel, config, System.map, limine.conf (on the EFI partition) +/etc configuration +/lib/modules kernel modules, one directory per kernel version +/lib/firmware firmware for the hardware, zstd compressed +/var/lib/mag which package owns which file +/var/cache/mag downloaded sources +/run /tmp tmpfs, made new at every boot</pre> +<p>The PATH of a login shell is <code>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</code>. Packages install into <code>/usr</code>.</p> +<h2 id="s1-3">1.3 Where the sources are</h2> +<table> +<tr><th>directory</th><th>what is in it</th></tr> +<tr><td><code>system/</code></td><td><code>tools/</code> (<code>chamesle-bootstrap</code>, <code>chamesle-chroot</code>, <code>chamesle-disk</code>), <code>files/</code> (init, rc and the services), <code>iso/</code>, this handbook</td></tr> +<tr><td><code>mag/</code></td><td><code>mag.c</code>, <code>build.sh</code>, <code>tests/run.sh</code>, <code>repo/</code> with the hand recipes and <code>PROVIDES</code></td></tr> +<tr><td><code>rifle/</code></td><td><code>rifle.c</code>, <code>build.sh</code>, <code>tests/run.sh</code></td></tr> +<tr><td>pkgsrc</td><td>NetBSD's package tree, which you fetch yourself (chapter 2)</td></tr> +</table> +<p>The commands in this book assume the three source trees are in <code>$HOME/src/system</code>, <code>$HOME/src/mag</code> and <code>$HOME/src/rifle</code>. Change the paths if yours are elsewhere.</p> +<hr> +<p><a href="docs.html">Contents</a> | <a href="handbook-preparing.html">Preparing &rarr;</a></p> +</main> + +<hr> +<div id="foot"> +Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> +Chamesle is installed by hand, from the <a href="docs.html">handbook</a>.<br> +<a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> +<a href="#" id="edit-link">Edit text</a><br> +$Date: 2026-11-16 $ +</div> + +</div> + +<script src="edit.js"></script> +</body> +</html> diff --git a/docs/handbook-base.html b/docs/handbook-base.html @@ -0,0 +1,161 @@ +<!doctype html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>The base system - Chamesle</title> +<meta name="description" content="/sbin/init is a mksh script, and it works the way FreeBSD&#x27;s init does: the kernel starts it as process 1, it runs"> +<link rel="canonical" href="https://chamesle.org/handbook-base.html"> +<meta property="og:type" content="website"> +<meta property="og:site_name" content="Chamesle"> +<meta property="og:title" content="The base system - Chamesle"> +<meta property="og:description" content="/sbin/init is a mksh script, and it works the way FreeBSD&#x27;s init does: the kernel starts it as process 1, it runs"> +<meta property="og:url" content="https://chamesle.org/handbook-base.html"> +<link rel="stylesheet" href="style.css?13"> +</head> +<body> + +<div id="page"> + +<div id="top"> +<h1><a href="./">Chamesle</a></h1> +</div> + +<div id="nav"> +<a href="./">Home</a> | +<a href="download.html">Install</a> | +<b>Handbook</b> | +<a href="packages.html">Packages</a> | +<a href="new.html">News</a> | +<a href="board.html">Board</a> | +<a href="chat.html">Chat</a> | +<a href="source.html">Source</a> | +<a href="https://x22.chamesle.org/">X22</a> | +<a href="about.html">About</a> +</div> + +<main> +<p><a href="handbook-rifle.html">&larr; rifle</a> | <a href="docs.html">Contents</a> | <a href="handbook-kernel.html">The kernel and firmware &rarr;</a></p> +<h2>6. The base system</h2> +<h2 id="s6-1">6.1 init</h2> +<p><code>/sbin/init</code> is a mksh script, and it works the way FreeBSD's init does: the kernel starts it as process 1, it runs <code>/etc/rc</code>, then it keeps a getty on every tty and waits for a signal. The files are in <code>files/</code> in the sources and <code>chamesle-bootstrap</code> copies them into the root. Step by step:</p> +<ol> +<li><code>PATH</code> is set to <code>/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin</code>. <code>proc</code>, <code>sysfs</code> and <code>devtmpfs</code> are mounted if they are not yet, and what init prints goes to <code>/dev/console</code>.</li> +<li>If <code>single</code> is on the kernel command line, init runs <code>sulogin</code> first.</li> +<li><code>/etc/rc autoboot</code> runs (6.2). If it fails, init runs <code>sulogin</code> and goes on when you leave it.</li> +<li>For every name in <code>ttys</code> of <code>init.conf</code> that has a node in <code>/dev</code>, init starts a loop that runs the getty command again whenever it exits. A getty that dies within five seconds is run again after a pause of five.</li> +<li>init waits. A signal ends the wait:</li> +</ol> +<table> +<tr><th>signal</th><th>what it does</th></tr> +<tr><td><code>INT</code>, <code>TERM</code></td><td>reboot</td></tr> +<tr><td><code>USR1</code></td><td>halt: stop everything and stay stopped</td></tr> +<tr><td><code>USR2</code></td><td>power off</td></tr> +</table> +<ol> +<li>Then it runs <code>/etc/rc.shutdown</code>, sends <code>TERM</code> to every process, <code>KILL</code> two seconds later, runs <code>sync</code>, <code>umount -a -r</code> and does the last step through <code>/proc/sysrq-trigger</code> (<code>b</code> or <code>o</code>). That needs <code>CONFIG_MAGIC_SYSRQ</code> in the kernel; the base set has no <code>reboot</code> program of its own that calls the kernel.</li> +</ol> +<h2 id="s6-2">6.2 rc, init.conf and the services</h2> +<p><code>/etc/rc</code> mounts the system. In order: <code>/</code> is remounted read-write; with <code>autoboot</code>, <code>fsck -A -R -p</code> checks the other file systems; <code>devpts</code> and <code>/dev/shm</code> are mounted; a tmpfs goes on <code>/run</code> (not on the live ISO, where <code>/run/live</code> is already there); <code>mount -a</code> mounts <code>/etc/fstab</code>; <code>swapon -a</code>; <code>/tmp</code> is emptied if it is not a mount and set to mode 1777; the host name is set; <code>dmesg</code> is saved in <code>/var/log/dmesg.boot</code>. Then every service in <code>boot-services</code> is started, in the order it is written.</p> +<p><code>/etc/init.conf</code> is the one configuration file. One setting per line, <code>key = value</code>, <code>#</code> starts a comment, blank lines are ignored, spaces around <code>=</code> are free. A list is in braces and may go over several lines:</p> +<pre>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} +getty = agetty --noclear $tty linux +getty-ttyS0 = agetty -L $tty 115200 vt100</pre> +<table> +<tr><th>key</th><th>meaning</th></tr> +<tr><td><code>hostname</code></td><td>the host name</td></tr> +<tr><td><code>boot-services</code></td><td>the services started at boot, in order; shutdown stops them in reverse</td></tr> +<tr><td><code>modules</code></td><td>kernel modules the <code>modules</code> service loads with <code>modprobe</code></td></tr> +<tr><td><code>ttys</code></td><td>the ttys that get a getty</td></tr> +<tr><td><code>getty</code></td><td>the getty command; <code>$tty</code> is the tty name</td></tr> +<tr><td><code>getty-NAME</code></td><td>the getty command for that tty alone</td></tr> +</table> +<p>The parser is <code>conf</code> in <code>/etc/init.sh</code>; <code>conf KEY</code> prints the value, with a list separated by spaces. A change to <code>ttys</code> or <code>getty</code> takes effect at the next boot.</p> +<p>A service is an executable file in <code>/etc/rc.d</code> (or <code>/usr/local/etc/rc.d</code>, for the ones you add) that takes <code>start</code>, <code>stop</code>, <code>restart</code> or <code>status</code>. The base set has three: <code>udev</code> (starts <code>udevd</code>, replays the devices and waits for them), <code>modules</code> and <code>network</code> (<code>dhcpcd</code>). A name in <code>boot-services</code> without a script is skipped with one line saying so.</p> +<p><code>service</code> is the way to run them:</p> +<pre>service -l every service +service -e the services of boot-services, as paths +service network restart +service udev status</pre> +<p>To add a service, write the script, make it executable, and put its name in <code>boot-services</code>. With <code>/etc/rc.subr</code> it is short. Set <code>procname</code> to the name the process shows in <code>/proc/PID/comm</code>, write <code>svc_start</code>, and finish with <code>run "$1"</code>; <code>stop</code> then kills that process, <code>status</code> looks for it and <code>start</code> refuses to start it twice. Override <code>svc_stop</code> and <code>svc_status</code> if the defaults do not fit:</p> +<pre>#!/bin/sh +. /etc/rc.subr +procname=chronyd +svc_start() { chronyd; } +run &quot;$1&quot;</pre> +<h2 id="s6-3">6.3 Shutting down</h2> +<p><code>reboot</code>, <code>halt</code> and <code>poweroff</code> send <code>INT</code>, <code>USR1</code> and <code>USR2</code> to init. <code>shutdown -r</code>, <code>-h</code> or <code>-p</code> does the same, at once (<code>now</code>) or after <code>+minutes</code>, with an optional message sent through <code>wall</code>:</p> +<pre>shutdown -r now +shutdown -p +10 back in ten minutes</pre> +<h2 id="s6-4">6.4 The files in /etc</h2> +<table> +<tr><th>file</th><th>what it holds</th></tr> +<tr><td><code>passwd</code>, <code>group</code></td><td>accounts and groups; no shadow file, the hash is in <code>passwd</code></td></tr> +<tr><td><code>shells</code></td><td><code>/bin/sh</code>, <code>/usr/bin/mksh</code>, <code>/usr/bin/ksh</code></td></tr> +<tr><td><code>init.conf</code></td><td>host name, boot services, modules, ttys (6.2)</td></tr> +<tr><td><code>fstab</code></td><td><code>proc</code>, <code>sysfs</code>, <code>tmpfs</code> on <code>/tmp</code>, plus the lines you add</td></tr> +<tr><td><code>profile</code></td><td><code>PATH</code>, <code>EDITOR=vim</code>, <code>PAGER=less</code>, <code>umask 022</code></td></tr> +<tr><td><code>os-release</code></td><td><code>NAME=Chamesle</code>, <code>ID=chamesle</code></td></tr> +<tr><td><code>mag.conf</code></td><td><code>JOBS</code> and <code>CFLAGS</code> for mag</td></tr> +<tr><td><code>skel/</code></td><td>empty directory for the files new homes start from</td></tr> +</table> +<p>The login shell is mksh and <code>/etc/profile</code> is read by login shells. For a prompt and aliases make <code>~/.mkshrc</code> and set <code>ENV=$HOME/.mkshrc</code> in <code>/etc/profile</code>.</p> +<h2 id="s6-5">6.5 Users</h2> +<p>There is no <code>useradd</code>. To add <code>alice</code>:</p> +<pre>echo &#x27;alice:HASH:1000:1000:alice:/home/alice:/usr/bin/mksh&#x27; &gt;&gt; /etc/passwd +echo &#x27;alice:x:1000:&#x27; &gt;&gt; /etc/group +mkdir /home/alice +chown 1000:1000 /home/alice</pre> +<p><code>HASH</code> comes from <code>openssl passwd -6</code> on a machine that has it. To put alice in <code>wheel</code>, add her name to the last field of the <code>wheel:x:10:</code> line.</p> +<h2 id="s6-6">6.6 udev and modules</h2> +<p>eudev is the udev. <code>udevd</code> gives devices their nodes in <code>/dev</code> and loads the modules the hardware needs. eudev is built without the hardware database (<code>--disable-hwdb</code>).</p> +<p>kmod provides <code>modprobe</code>, <code>insmod</code>, <code>rmmod</code>, <code>lsmod</code>, <code>modinfo</code> and <code>depmod</code>. A kernel's modules are in <code>/lib/modules/VERSION</code>. To load one by hand: <code>modprobe name</code>. To load one at every boot, put its name in <code>modules</code> of <code>/etc/init.conf</code>. To keep one from loading, put <code>blacklist name</code> in a file in <code>/etc/modprobe.d/</code>.</p> +<h2 id="s6-7">6.7 Networking</h2> +<p><code>dhcpcd</code> is the DHCP client and is in the base set. For a wired interface:</p> +<pre>dhcpcd eth0</pre> +<p><code>dhcpcd</code> without arguments takes every interface. It is the <code>network</code> service, in <code>boot-services</code> by default, so it is up at boot. <code>/sys/class/net/</code> lists the interfaces. For <code>ip</code>, install iproute2 from Chamesle's repo:</p> +<pre>mag install net-misc/iproute2</pre> +<p>A static address:</p> +<pre>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 &#x27;nameserver 192.168.1.1&#x27; &gt; /etc/resolv.conf</pre> +<h2 id="s6-8">6.8 Wireless</h2> +<p><code>iw</code> talks to the kernel's nl80211. It is in Chamesle's repo, with libnl:</p> +<pre>mag install net-wireless/iw +iw dev the wireless interfaces +ip link set wlan0 up +iw dev wlan0 scan | grep SSID</pre> +<p><code>sys-firmware/wireless-regdb</code> (in the base set) has the regulatory database, and the card's firmware is in <code>/lib/firmware</code> from <code>sys-kernel/linux-firmware</code>. If <code>dmesg</code> says a firmware file failed to load, check that it is there.</p> +<p>For an open network <code>iw dev wlan0 connect NAME</code> is enough. For WPA the connection needs <code>wpa_supplicant</code>; if your pkgsrc tree has it (<code>mag search wpa</code>), install it, give it a configuration file with the <code>ssid</code> and the <code>psk</code>, and run it on the interface. Then <code>dhcpcd wlan0</code>.</p> +<h2 id="s6-9">6.9 Mounting and disks</h2> +<pre>mount /dev/sdb1 /mnt/usb +mount -t vfat -o ro /dev/sdb1 /mnt/usb +umount /mnt/usb</pre> +<p><code>mount</code>, <code>umount</code>, <code>lsblk</code>, <code>blkid</code>, <code>sfdisk</code>, <code>fdisk</code> and <code>cfdisk</code> are util-linux's, <code>zpool</code> and <code>zfs</code> are OpenZFS's, <code>mkfs.ext4</code> and <code>fsck.ext4</code> are e2fsprogs', <code>mkfs.fat</code> is dosfstools'.</p> +<p>On a ZFS root, <code>/etc/rc</code> runs <code>zfs mount -a</code> right after <code>mount -a</code>, which mounts <code>rpool/home</code> and <code>rpool/var</code>; the root itself was mounted by the initramfs.</p> +<hr> +<p><a href="handbook-rifle.html">&larr; rifle</a> | <a href="docs.html">Contents</a> | <a href="handbook-kernel.html">The kernel and firmware &rarr;</a></p> +</main> + +<hr> +<div id="foot"> +Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> +Chamesle is installed by hand, from the <a href="docs.html">handbook</a>.<br> +<a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> +<a href="#" id="edit-link">Edit text</a><br> +$Date: 2026-11-16 $ +</div> + +</div> + +<script src="edit.js"></script> +</body> +</html> diff --git a/docs/handbook-files.html b/docs/handbook-files.html @@ -0,0 +1,118 @@ +<!doctype html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>File reference - Chamesle</title> +<meta name="description" content="File reference"> +<link rel="canonical" href="https://chamesle.org/handbook-files.html"> +<meta property="og:type" content="website"> +<meta property="og:site_name" content="Chamesle"> +<meta property="og:title" content="File reference - Chamesle"> +<meta property="og:description" content="File reference"> +<meta property="og:url" content="https://chamesle.org/handbook-files.html"> +<link rel="stylesheet" href="style.css?13"> +</head> +<body> + +<div id="page"> + +<div id="top"> +<h1><a href="./">Chamesle</a></h1> +</div> + +<div id="nav"> +<a href="./">Home</a> | +<a href="download.html">Install</a> | +<b>Handbook</b> | +<a href="packages.html">Packages</a> | +<a href="new.html">News</a> | +<a href="board.html">Board</a> | +<a href="chat.html">Chat</a> | +<a href="source.html">Source</a> | +<a href="https://x22.chamesle.org/">X22</a> | +<a href="about.html">About</a> +</div> + +<main> +<p><a href="handbook-maintaining.html">&larr; Maintaining</a> | <a href="docs.html">Contents</a></p> +<h2>10. File reference</h2> +<h2 id="s10-1">10.1 On an installed system</h2> +<table> +<tr><th>path</th><th>what</th></tr> +<tr><td><code>/sbin/init</code>, <code>/etc/rc</code>, <code>/etc/rc.shutdown</code></td><td>init, the boot script, the shutdown script, all run by mksh</td></tr> +<tr><td><code>/etc/init.conf</code></td><td>host name, boot services, modules, ttys</td></tr> +<tr><td><code>/etc/rc.d/</code>, <code>/usr/local/etc/rc.d/</code></td><td>the service scripts</td></tr> +<tr><td><code>/etc/services</code>, <code>/etc/hosts</code></td><td>port names and the local host name, the libc reads them</td></tr> +<tr><td><code>/etc/profile</code></td><td><code>PATH</code>, <code>EDITOR</code>, <code>PAGER</code>, <code>umask</code></td></tr> +<tr><td><code>/etc/passwd</code>, <code>/etc/group</code>, <code>/etc/shells</code></td><td>accounts, groups, login shells</td></tr> +<tr><td><code>/etc/fstab</code></td><td>file systems</td></tr> +<tr><td><code>/etc/os-release</code></td><td><code>NAME=Chamesle</code>, <code>ID=chamesle</code></td></tr> +<tr><td><code>/etc/mag.conf</code></td><td>mag's build settings: <code>JOBS</code>, <code>CFLAGS</code>, <code>PKG_DEFAULT_OPTIONS</code>, <code>PKG_OPTIONS.name</code></td></tr> +<tr><td><code>/boot/limine.conf</code></td><td>the boot entries</td></tr> +<tr><td><code>/boot/limine-bios.sys</code></td><td>limine's BIOS stage</td></tr> +<tr><td><code>/boot/EFI/BOOT/BOOTX64.EFI</code></td><td>limine for UEFI</td></tr> +<tr><td><code>/boot/vmlinuz-V</code>, <code>config-V</code>, <code>System.map-V</code></td><td>the kernel</td></tr> +<tr><td><code>/lib/modules/V/</code></td><td>its modules</td></tr> +<tr><td><code>/lib/firmware/</code></td><td>firmware</td></tr> +<tr><td><code>/var/lib/mag/</code></td><td>the file list of each installed package</td></tr> +<tr><td><code>/var/cache/mag/</code></td><td>downloaded sources</td></tr> +<tr><td><code>/usr/share/limine/</code></td><td>limine's boot files, for installing it</td></tr> +<tr><td><code>/usr/share/doc/chamesle/handbook.md</code></td><td>this book, on the live ISO</td></tr> +<tr><td><code>/usr/share/mag/repo/</code></td><td>Chamesle's recipes</td></tr> +<tr><td><code>/usr/pkgsrc/</code></td><td>the pkgsrc tree, from <code>mag sync</code></td></tr> +</table> +<h2 id="s10-2">10.2 In the sources</h2> +<table> +<tr><th>path</th><th>what</th></tr> +<tr><td><code>system/tools/chamesle-bootstrap</code></td><td>makes a root file system and builds the base set into it</td></tr> +<tr><td><code>system/tools/chamesle-chroot</code></td><td>chroot with the pseudo file systems mounted</td></tr> +<tr><td><code>system/tools/chamesle-disk</code></td><td>cfdisk, vfat boot partition, ZFS root, mounted on <code>/mnt</code></td></tr> +<tr><td><code>system/files/</code></td><td>init, rc, <code>service</code>, <code>init.conf</code> and the service scripts that go into every root</td></tr> +<tr><td><code>system/iso/mkiso</code></td><td>builds the live ISO</td></tr> +<tr><td><code>system/iso/mkinitramfs</code></td><td>builds an initramfs</td></tr> +<tr><td><code>system/iso/init</code></td><td>the first process in the initramfs</td></tr> +<tr><td><code>system/iso/profile/packages</code></td><td>what is in the live root</td></tr> +<tr><td><code>system/iso/profile/modules</code></td><td>what the initramfs loads</td></tr> +<tr><td><code>system/iso/profile/limine.conf</code></td><td>the live boot menu</td></tr> +<tr><td><code>system/iso/profile/overlay/</code></td><td>files copied over the live root</td></tr> +<tr><td><code>system/handbook/handbook.md</code></td><td>this book</td></tr> +<tr><td><code>mag/mag.c</code>, <code>mag/build.sh</code>, <code>mag/c.h</code></td><td>the package manager and its libc</td></tr> +<tr><td><code>mag/tests/run.sh</code></td><td>tests on a fake repo: install, upgrade, remove in a scratch root</td></tr> +<tr><td><code>mag/repo/PROVIDES</code></td><td>pkgsrc packages replaced or skipped, and dependencies added</td></tr> +<tr><td><code>mag/repo/sys-libs/musl</code></td><td>the libc</td></tr> +<tr><td><code>mag/repo/sys-kernel/{linux,linux-headers,linux-firmware,zfs-module}</code></td><td>kernel, headers, firmware, the ZFS module</td></tr> +<tr><td><code>mag/repo/sys-fs/zfs</code></td><td>ZFS userland: <code>zpool</code>, <code>zfs</code></td></tr> +<tr><td><code>mag/repo/sys-boot/limine</code></td><td>the boot loader</td></tr> +<tr><td><code>mag/repo/sys-apps/{eudev,kmod,util-linux,usbutils}</code></td><td>udev, module tools, the basics, usb tools</td></tr> +<tr><td><code>mag/repo/net-libs/libnl</code>, <code>net-wireless/iw</code>, <code>net-misc/iproute2</code></td><td>network tools</td></tr> +<tr><td><code>mag/repo/sys-firmware/{sof-firmware,wireless-regdb}</code></td><td>firmware extras</td></tr> +<tr><td><code>mag/repo/dev-libs/netbsd-curses</code>, <code>dev-build/libtool</code></td><td>curses and libtool</td></tr> +<tr><td><code>rifle/rifle.c</code>, <code>rifle/c.h</code>, <code>rifle/build.sh</code></td><td>the coreutils</td></tr> +<tr><td><code>rifle/tests/run.sh</code>, <code>rifle/tests/cases</code></td><td>the comparison tests</td></tr> +</table> +<h2 id="s10-3">10.3 Commands in short</h2> +<pre>chamesle-bootstrap [-r REPOS] [-s PACKAGES] [-n HOSTNAME] TARGET +mkiso [-p profile] [-r repos] [-R rootfs] [-w workdir] [-o out.iso] +mkinitramfs [-m modules] ROOTFS KVER OUT +mag [-nfk] install|remove|upgrade|autoremove|list|info|search|files|owns|deps|rdeps|fetch|build|sync|relocate|hash +rifle --install DIR | --list +limine bios-install DEVICE</pre> +<hr> +<p><a href="handbook-maintaining.html">&larr; Maintaining</a> | <a href="docs.html">Contents</a></p> +</main> + +<hr> +<div id="foot"> +Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> +Chamesle is installed by hand, from the <a href="docs.html">handbook</a>.<br> +<a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> +<a href="#" id="edit-link">Edit text</a><br> +$Date: 2026-11-16 $ +</div> + +</div> + +<script src="edit.js"></script> +</body> +</html> diff --git a/docs/handbook-installing.html b/docs/handbook-installing.html @@ -0,0 +1,184 @@ +<!doctype html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>Installing by hand - Chamesle</title> +<meta name="description" content="Follow the BIOS or the UEFI variant where they differ. The disk here is /dev/sda; change it to yours. Everything below"> +<link rel="canonical" href="https://chamesle.org/handbook-installing.html"> +<meta property="og:type" content="website"> +<meta property="og:site_name" content="Chamesle"> +<meta property="og:title" content="Installing by hand - Chamesle"> +<meta property="og:description" content="Follow the BIOS or the UEFI variant where they differ. The disk here is /dev/sda; change it to yours. Everything below"> +<meta property="og:url" content="https://chamesle.org/handbook-installing.html"> +<link rel="stylesheet" href="style.css?13"> +</head> +<body> + +<div id="page"> + +<div id="top"> +<h1><a href="./">Chamesle</a></h1> +</div> + +<div id="nav"> +<a href="./">Home</a> | +<a href="download.html">Install</a> | +<b>Handbook</b> | +<a href="packages.html">Packages</a> | +<a href="new.html">News</a> | +<a href="board.html">Board</a> | +<a href="chat.html">Chat</a> | +<a href="source.html">Source</a> | +<a href="https://x22.chamesle.org/">X22</a> | +<a href="about.html">About</a> +</div> + +<main> +<p><a href="handbook-preparing.html">&larr; Preparing</a> | <a href="docs.html">Contents</a> | <a href="handbook-mag.html">Using mag &rarr;</a></p> +<h2>3. Installing by hand</h2> +<p>Follow the BIOS or the UEFI variant where they differ. The disk here is <code>/dev/sda</code>; 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.</p> +<p>There are two ways through 3.1 and 3.2: <code>chamesle-disk</code> 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: <code>chamesle-disk</code> is only a helper.</p> +<h2 id="s3-1">3.1 chamesle-disk</h2> +<pre>chamesle-disk /dev/sda</pre> +<p>It lists the disk and asks you to type its name before it touches anything. Then it starts <code>cfdisk</code> so you lay out the partitions. Three of them work for BIOS and UEFI both:</p> +<table> +<tr><th>partition</th><th>size</th><th>type</th><th>use</th></tr> +<tr><td>1</td><td>1M</td><td>BIOS boot</td><td>limine's BIOS code, not used on UEFI</td></tr> +<tr><td>2</td><td>512M</td><td>EFI System</td><td><code>/boot</code>, FAT32</td></tr> +<tr><td>3</td><td>the rest</td><td>Linux filesystem</td><td><code>/</code>, ZFS</td></tr> +</table> +<p>Write the table and quit cfdisk. chamesle-disk lists the partitions and asks which one is the boot partition and which is the root. Then it does, in this order:</p> +<pre>mkfs.fat -F32 BOOT +zpool create -f -o ashift=12 -O compression=zstd -O acltype=posixacl -O xattr=sa -O mountpoint=none -R /mnt rpool ROOT +zfs create -o mountpoint=/ -o canmount=noauto rpool/root +zfs create -o mountpoint=/home rpool/home +zfs create -o mountpoint=/var rpool/var +zpool set bootfs=rpool/root rpool</pre> +<p>and mounts <code>rpool/root</code>, <code>rpool/home</code> and <code>rpool/var</code> under <code>/mnt</code> and the boot partition on <code>/mnt/boot</code>. It also writes <code>/mnt/etc/fstab</code> with the boot partition by UUID and the <code>proc</code>, <code>sysfs</code> and <code>tmpfs</code> lines (an existing one is left alone). It writes nothing else: no <code>limine.conf</code>, no host name, no password. Those are 3.7 and 3.8.</p> +<p>ZFS mounts its own datasets, so the fstab does not list them. limine cannot read ZFS: the kernel, the initrd and <code>limine.conf</code> live on the FAT partition, which is <code>/boot</code>, and the initramfs imports the pool (3.8).</p> +<h2 id="s3-2">3.2 Partitioning and file systems by hand</h2> +<p>For a root on ext4. The layout is the one in 3.1, <code>sda1</code> to <code>sda3</code>:</p> +<pre>sfdisk /dev/sda &lt;&lt;P +label: gpt +size=1M, type=21686148-6449-6E6F-744E-656564454649 +size=512M, type=U +type=L +P</pre> +<p>On an NVMe disk the partitions are <code>/dev/nvme0n1p1</code> and so on. Replace <code>sda1</code>, <code>sda2</code> and <code>sda3</code> throughout.</p> +<pre>mkfs.fat -F32 /dev/sda2 +mkfs.ext4 /dev/sda3 +mount /dev/sda3 /mnt +mkdir /mnt/boot +mount /dev/sda2 /mnt/boot</pre> +<p>The FAT partition is <code>/boot</code>. The kernel and <code>limine.conf</code> end up there, where limine looks for them on both BIOS and UEFI. The root can be ZFS by hand as well: the <code>zpool</code> and <code>zfs</code> lines of 3.1 are all there is to it.</p> +<h2 id="s3-3">3.3 Copying the live system</h2> +<p>The live ISO has no compiler, so on a machine booted from it the system is not built, it is copied. The read-only root of the ISO is mounted on <code>/run/live/rootfs</code> and the ISO itself on <code>/run/live/medium</code>:</p> +<pre>tar -C /run/live/rootfs --exclude ./etc/fstab -cf - . | tar -C /mnt -xpf - +[ -e /mnt/etc/fstab ] || cp /run/live/rootfs/etc/fstab /mnt/etc/fstab +cp /run/live/medium/boot/initrd /mnt/boot/initrd</pre> +<p>That is the whole base system, kernel, modules and ZFS included, as it was when the ISO was made. The copy keeps the fstab chamesle-disk wrote. The firmware for wifi and some network cards is not on the ISO. Add it with mag once the new system runs (section 4), or build everything instead (3.4), which needs a machine with a compiler.</p> +<p>Work inside the new root with <code>chamesle-chroot</code>:</p> +<pre>chamesle-chroot /mnt +chamesle-chroot /mnt passwd root</pre> +<p>It mounts <code>proc</code>, <code>sys</code>, <code>dev</code>, <code>dev/pts</code> and a tmpfs on <code>run</code> under the directory, copies <code>/etc/resolv.conf</code> into it, runs <code>chroot</code> with an empty environment (<code>HOME=/root</code>, <code>TERM</code>, <code>PATH</code>) and takes the mounts away again when the command ends. Without a command it starts <code>/usr/bin/mksh -l</code>.</p> +<p>Then go on with 3.6 (fstab) and the rest. rifle (3.5) is on the ISO already, skip it. The kernel is in <code>/mnt/boot</code> already.</p> +<h2 id="s3-4">3.4 Building the system from source, instead</h2> +<p>Point mag at the repositories (section 2.4) and run chamesle-bootstrap:</p> +<pre>export MAG_REPO=$HOME/src/mag/repo:/usr/pkgsrc +$HOME/src/system/tools/chamesle-bootstrap -n yourhostname /mnt</pre> +<p>Its usage:</p> +<pre>chamesle-bootstrap [-r REPOS] [-s PACKAGES] [-n HOSTNAME] TARGET</pre> +<ul> +<li><code>-r</code> sets the repositories, instead of <code>MAG_REPO</code></li> +<li><code>-s</code> is the list of packages to install instead of the base set</li> +<li><code>-n</code> is the host name, <code>chamesle</code> if not given</li> +</ul> +<p>It makes the directories (<code>bin boot dev etc/skel home lib lib/firmware mnt proc root run sbin srv sys tmp usr/bin usr/lib usr/sbin usr/share usr/local/bin var/cache var/lib var/log var/tmp</code>, with <code>tmp</code> and <code>var/tmp</code> mode 1777 and <code>root</code> mode 700), installs everything in <code>files/</code> (init, rc, the services, <code>init.conf</code>), writes the first <code>/etc</code> files (<code>passwd</code>, <code>group</code>, <code>shells</code>, <code>fstab</code>, <code>profile</code>, <code>os-release</code>, <code>mag.conf</code>), and builds the base set into the target with <code>mag</code>:</p> +<pre>sys-libs/musl devel/gmake archivers/libarchive app-arch/bsdtar archivers/pigz shells/mksh sys-apps/util-linux +sys-apps/kmod sys-apps/eudev net/dhcpcd net/tnftp sysutils/e2fsprogs sysutils/dosfstools sys-boot/limine +sys-kernel/linux sys-kernel/linux-firmware sys-firmware/sof-firmware sys-firmware/wireless-regdb editors/vim +sys-fs/zfs sys-kernel/zfs-module lang/clang devel/lld lang/compiler-rt lang/libunwind</pre> +<p><code>lang/clang</code> (with <code>lang/llvm</code> under it), <code>devel/lld</code>, <code>lang/compiler-rt</code> and <code>lang/libunwind</code> are the compiler of the new system: it builds what <code>mag install</code> asks for after <code>mag sync</code>, so no other machine is needed. They are the longest part of the bootstrap. It also copies the recipes of the first repo that has a <code>PROVIDES</code> file into <code>/usr/share/mag/repo</code>, installs <code>chamesle-chroot</code> and <code>chamesle-disk</code>, and runs <code>depmod</code>.</p> +<p>The sources go in <code>/mnt/var/cache/mag</code> and are not fetched twice. An existing file in <code>/etc</code> is never overwritten, so the script can be run again after a failure. A build that fails stops and names the directory it left behind.</p> +<p>Once musl is in the new root, every later package is built with clang aimed at it, with the loader and library paths pointing into <code>/mnt</code>. That lets the programs run on the host while they are built. They need their real paths before you boot the new system:</p> +<pre>MAG_ROOT=/mnt mag relocate</pre> +<p>Run <code>mag relocate</code> again after every <code>MAG_ROOT=/mnt mag install</code> that adds programs (section 9.4).</p> +<h2 id="s3-5">3.5 rifle</h2> +<p>The base set has no coreutils: they come from rifle. Install it into the new root:</p> +<pre>install -m755 $HOME/src/rifle/rifle /mnt/usr/bin/rifle +$HOME/src/rifle/rifle --install /mnt/usr/bin</pre> +<p><code>rifle --install DIR</code> makes a link for each of its tools in <code>DIR</code>. rifle is built static, so it runs from the host as it is.</p> +<p>Add the packages you want now, or after the first boot:</p> +<pre>MAG_ROOT=/mnt mag install editors/vim +MAG_ROOT=/mnt mag relocate</pre> +<h2 id="s3-6">3.6 fstab</h2> +<p>If you used chamesle-disk the file is written. Look at it: the boot partition by UUID on <code>/boot</code>, then <code>proc</code>, <code>sysfs</code> and <code>tmpfs</code>, and nothing for the ZFS datasets, because ZFS mounts them itself.</p> +<p>By hand, <code>blkid</code> prints the UUIDs:</p> +<pre>blkid /dev/sda2 /dev/sda3</pre> +<p>Open <code>/mnt/etc/fstab</code> and add the root and boot lines under the <code>proc</code>, <code>sysfs</code> and <code>tmpfs</code> lines already there:</p> +<pre>UUID=ROOT-UUID / ext4 defaults 0 1 +UUID=BOOT-UUID /boot vfat defaults 0 2</pre> +<p>A root on ZFS gets only the boot line. Check that the UUID is the one <code>blkid</code> shows for the boot partition.</p> +<h2 id="s3-7">3.7 Host name, users, password</h2> +<p>The host name is already in <code>/mnt/etc/init.conf</code> from <code>-n</code>. The root account is in <code>/mnt/etc/passwd</code> with an <code>x</code> 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:</p> +<pre>openssl passwd -6</pre> +<p>Put the output in the second field of the root line:</p> +<pre>root:$6$salt$hash:0:0:root:/root:/usr/bin/mksh</pre> +<p>musl's <code>crypt</code> reads <code>$6$</code> hashes. An empty field means no password at all.</p> +<p>The groups are <code>root</code>, <code>wheel</code> (10) and <code>users</code> (100). More accounts are lines in <code>passwd</code> and <code>group</code> and a home directory you make (section 6.5).</p> +<h2 id="s3-8">3.8 The kernel and the boot entry</h2> +<p>The kernel package put these in <code>/mnt/boot</code> (the version number is whatever the recipe carries):</p> +<pre>ls /mnt/boot +config-6.18.63-0-lts System.map-6.18.63-0-lts vmlinuz-6.18.63-0-lts</pre> +<p>Write <code>/mnt/boot/limine.conf</code> with the file name you see and the UUID of the root partition:</p> +<pre>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</pre> +<p>For a root on ZFS the command line names the dataset, there is no UUID:</p> +<pre> cmdline: root=ZFS=rpool/root rw console=tty0</pre> +<p><code>boot()</code> is the partition <code>limine.conf</code> is on, which is <code>/boot</code>; 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 (<code>/mnt/boot/initrd</code>, copied in 3.3) finds the root by <code>root=UUID=</code> or <code>root=ZFS=</code> and loads the modules in <code>iso/profile/modules</code>. Section 7.5 says how to make your own.</p> +<p>limine's files are in <code>/mnt/usr/share/limine</code>.</p> +<h3 id="bios">BIOS</h3> +<pre>cp /mnt/usr/share/limine/limine-bios.sys /mnt/boot/ +limine bios-install /dev/sda</pre> +<p><code>limine bios-install</code> writes the loader to the start of the disk and into the BIOS boot partition. <code>limine-bios.sys</code> on the FAT partition is the part it loads.</p> +<h3 id="uefi">UEFI</h3> +<pre>mkdir -p /mnt/boot/EFI/BOOT +cp /mnt/usr/share/limine/BOOTX64.EFI /mnt/boot/EFI/BOOT/</pre> +<p>The firmware starts <code>EFI/BOOT/BOOTX64.EFI</code> of the EFI System partition by itself.</p> +<p>Do both and the disk boots either way.</p> +<h2 id="s3-9">3.9 First boot</h2> +<pre>umount -R /mnt +zpool export rpool +reboot</pre> +<p>Leave out <code>zpool export</code> if the root is not on ZFS.</p> +<p>Take out the installation medium. limine shows the entry for three seconds and boots the kernel. <code>init</code> runs <code>/etc/rc</code>, which mounts the file systems and starts the services of <code>init.conf</code>, and puts a login on the ttys. Log in as root.</p> +<p>Then:</p> +<ol> +<li>Bring the network up (section 6.7).</li> +<li><code>mag sync</code> fetches the pkgsrc tree (section 2.3). Mag's own recipes are in <code>/usr/share/mag/repo</code> already and the default <code>MAG_REPO</code> covers both, so <code>mag install name</code> works from then on, and the compiler is in the base set.</li> +<li><code>mag list</code> shows what the bootstrap put on the machine.</li> +</ol> +<hr> +<p><a href="handbook-preparing.html">&larr; Preparing</a> | <a href="docs.html">Contents</a> | <a href="handbook-mag.html">Using mag &rarr;</a></p> +</main> + +<hr> +<div id="foot"> +Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> +Chamesle is installed by hand, from the <a href="docs.html">handbook</a>.<br> +<a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> +<a href="#" id="edit-link">Edit text</a><br> +$Date: 2026-11-16 $ +</div> + +</div> + +<script src="edit.js"></script> +</body> +</html> diff --git a/docs/handbook-iso.html b/docs/handbook-iso.html @@ -0,0 +1,116 @@ +<!doctype html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>The live ISO - Chamesle</title> +<meta name="description" content="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"> +<link rel="canonical" href="https://chamesle.org/handbook-iso.html"> +<meta property="og:type" content="website"> +<meta property="og:site_name" content="Chamesle"> +<meta property="og:title" content="The live ISO - Chamesle"> +<meta property="og:description" content="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"> +<meta property="og:url" content="https://chamesle.org/handbook-iso.html"> +<link rel="stylesheet" href="style.css?13"> +</head> +<body> + +<div id="page"> + +<div id="top"> +<h1><a href="./">Chamesle</a></h1> +</div> + +<div id="nav"> +<a href="./">Home</a> | +<a href="download.html">Install</a> | +<b>Handbook</b> | +<a href="packages.html">Packages</a> | +<a href="new.html">News</a> | +<a href="board.html">Board</a> | +<a href="chat.html">Chat</a> | +<a href="source.html">Source</a> | +<a href="https://x22.chamesle.org/">X22</a> | +<a href="about.html">About</a> +</div> + +<main> +<p><a href="handbook-kernel.html">&larr; The kernel and firmware</a> | <a href="docs.html">Contents</a> | <a href="handbook-maintaining.html">Maintaining &rarr;</a></p> +<h2>8. The live ISO</h2> +<h2 id="s8-1">8.1 What it is</h2> +<p>The ISO is a live system to work from. It boots on BIOS and UEFI machines with limine, from a disc or a stick, and has mksh, vim, mag with Chamesle's recipes (<code>mag search</code> and <code>mag info</code> work before <code>mag sync</code>), <code>chamesle-bootstrap</code>, <code>chamesle-chroot</code>, <code>chamesle-disk</code>, the disk tools (<code>cfdisk</code>, <code>sfdisk</code>, <code>mkfs.ext4</code>, <code>mkfs.fat</code>, <code>zpool</code>, <code>zfs</code>) and this handbook in <code>/usr/share/doc/chamesle/handbook.md</code>. It is where you do chapter 3 on a machine that has nothing on it.</p> +<h2 id="s8-2">8.2 Building</h2> +<p>The machine that builds needs <code>mksquashfs</code> (filesystems/squashfs), <code>xorriso</code> (sysutils/libisoburn), <code>zstd</code>, <code>bsdcpio</code>, <code>limine</code> and <code>mag</code>, plus what chamesle-bootstrap needs.</p> +<pre>$HOME/src/system/iso/mkiso -r $HOME/src/mag/repo:/usr/pkgsrc</pre> +<p>The usage:</p> +<pre>chamesle-chroot DIR [COMMAND...] +chamesle-disk DISK +mkiso [-p profile] [-r repos] [-R rootfs] [-w workdir] [-o out.iso]</pre> +<ul> +<li><code>-p</code> is the profile directory (default <code>iso/profile</code>)</li> +<li><code>-r</code> is <code>MAG_REPO</code></li> +<li><code>-R</code> uses a root you have already built, copied and not changed, instead of building one</li> +<li><code>-w</code> is the work directory (default <code>./work</code>)</li> +<li><code>-o</code> is the file to write (default <code>chamesle.iso</code>)</li> +</ul> +<p>Environment: <code>LIMINE</code> is where limine's files are (default <code>/usr/share/limine</code>), <code>MKISOFS</code> is the command that makes the ISO (default <code>xorriso -as mkisofs</code>), <code>MAG</code> is the mag to put into the image, <code>MAGREPO</code> the repo whose recipes it carries in <code>/usr/share/mag/repo</code> (default: the <code>repo</code> next to a mag checkout, else the first <code>MAG_REPO</code> entry with a <code>PROVIDES</code> file).</p> +<p>In order:</p> +<ol> +<li><code>chamesle-bootstrap</code> builds a root from <code>profile/packages</code>, with the host name <code>chamesle-live</code>.</li> +<li><code>profile/overlay</code> is copied over it.</li> +<li><code>chamesle-bootstrap</code>, <code>chamesle-chroot</code>, <code>chamesle-disk</code>, the handbook, <code>mag</code> and its recipes are put into it.</li> +<li>The kernel from <code>boot/vmlinuz-*</code> is copied to the ISO, and <code>depmod</code> runs on the root.</li> +<li><code>mkinitramfs</code> makes <code>boot/initrd</code> from <code>profile/modules</code>.</li> +<li>The root is written as a zstd squashfs, <code>LiveOS/rootfs.sfs</code>.</li> +<li>limine's boot files are copied and <code>profile/limine.conf</code> becomes <code>boot/limine/limine.conf</code>.</li> +<li><code>xorriso</code> writes the ISO with the BIOS and UEFI boot images and <code>limine bios-install</code> makes it bootable on BIOS.</li> +</ol> +<p>A root built that way still has its build-time loader paths (section 4.4). To relocate it, and to put rifle in it, build the root yourself and hand it over:</p> +<pre>MAG_REPO=$HOME/src/mag/repo:/usr/pkgsrc $HOME/src/system/tools/chamesle-bootstrap \ + -s &quot;$(grep -v &#x27;^#&#x27; $HOME/src/system/iso/profile/packages | tr &#x27;\n&#x27; &#x27; &#x27;)&quot; -n chamesle-live /srv/rootfs +MAG_ROOT=/srv/rootfs mag relocate +install -m755 $HOME/src/rifle/rifle /srv/rootfs/usr/bin/rifle +$HOME/src/rifle/rifle --install /srv/rootfs/usr/bin +$HOME/src/system/iso/mkiso -R /srv/rootfs -o chamesle.iso</pre> +<h2 id="s8-3">8.3 The profile</h2> +<pre>iso/profile/packages packages of the live root, one per line, # for comments +iso/profile/modules modules the initramfs loads to find the medium +iso/profile/limine.conf boot menu +iso/profile/overlay/ files copied over the root: etc/motd</pre> +<p><code>packages</code> is the base set of chapter 3. <code>modules</code> lists <code>squashfs overlay loop isofs sr_mod cdrom sd_mod usb_storage uas xhci_pci ehci_pci ahci ata_piix ata_generic pata_acpi virtio_blk nvme virtio_pci virtio_scsi ext4 vfat nls_cp437 nls_iso8859_1</code>, one per line, then a <code>[zfs]</code> line and <code>zfs</code>, which only a root on ZFS loads. The boot entry:</p> +<pre>timeout: 3 + +/Chamesle live + protocol: linux + path: boot():/boot/vmlinuz + module_path: boot():/boot/initrd + cmdline: quiet</pre> +<h2 id="s8-4">8.4 How it boots</h2> +<p><code>iso/init</code> looks through <code>/dev/sr*</code>, <code>/dev/sd*</code>, <code>/dev/nvme*n*p*</code>, <code>/dev/vd*</code> and <code>/dev/mmcblk*</code> until it finds one that mounts and has <code>LiveOS/rootfs.sfs</code>. It mounts that squashfs read-only, puts a tmpfs overlay over it, moves the medium and the squashfs to <code>/run/live/medium</code> and <code>/run/live/rootfs</code>, and runs <code>switch_root</code> into the result. Whatever you change in the live system is gone at shutdown.</p> +<h2 id="s8-5">8.5 Trying it in qemu</h2> +<p>BIOS:</p> +<pre>qemu-system-x86_64 -cpu max -m 1G -cdrom chamesle.iso -boot d</pre> +<p>UEFI, with the firmware of your qemu (<code>edk2-x86_64-code.fd</code>; the path differs between systems):</p> +<pre>qemu-system-x86_64 -cpu max -m 1G -bios /usr/share/qemu/edk2-x86_64-code.fd -cdrom chamesle.iso</pre> +<p>Add <code>-enable-kvm</code> for speed. To go through all of chapter 3 in a virtual machine, give it a disk:</p> +<pre>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</pre> +<p>To write the ISO to a stick: <code>dd if=chamesle.iso of=/dev/sdX bs=4M conv=fsync</code>.</p> +<hr> +<p><a href="handbook-kernel.html">&larr; The kernel and firmware</a> | <a href="docs.html">Contents</a> | <a href="handbook-maintaining.html">Maintaining &rarr;</a></p> +</main> + +<hr> +<div id="foot"> +Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> +Chamesle is installed by hand, from the <a href="docs.html">handbook</a>.<br> +<a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> +<a href="#" id="edit-link">Edit text</a><br> +$Date: 2026-11-16 $ +</div> + +</div> + +<script src="edit.js"></script> +</body> +</html> diff --git a/docs/handbook-kernel.html b/docs/handbook-kernel.html @@ -0,0 +1,103 @@ +<!doctype html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>The kernel and firmware - Chamesle</title> +<meta name="description" content="Nobody builds a kernel in Chamesle. sys-kernel/linux is a prebuilt Linux 6.18 LTS kernel with its modules, taken from a"> +<link rel="canonical" href="https://chamesle.org/handbook-kernel.html"> +<meta property="og:type" content="website"> +<meta property="og:site_name" content="Chamesle"> +<meta property="og:title" content="The kernel and firmware - Chamesle"> +<meta property="og:description" content="Nobody builds a kernel in Chamesle. sys-kernel/linux is a prebuilt Linux 6.18 LTS kernel with its modules, taken from a"> +<meta property="og:url" content="https://chamesle.org/handbook-kernel.html"> +<link rel="stylesheet" href="style.css?13"> +</head> +<body> + +<div id="page"> + +<div id="top"> +<h1><a href="./">Chamesle</a></h1> +</div> + +<div id="nav"> +<a href="./">Home</a> | +<a href="download.html">Install</a> | +<b>Handbook</b> | +<a href="packages.html">Packages</a> | +<a href="new.html">News</a> | +<a href="board.html">Board</a> | +<a href="chat.html">Chat</a> | +<a href="source.html">Source</a> | +<a href="https://x22.chamesle.org/">X22</a> | +<a href="about.html">About</a> +</div> + +<main> +<p><a href="handbook-base.html">&larr; The base system</a> | <a href="docs.html">Contents</a> | <a href="handbook-iso.html">The live ISO &rarr;</a></p> +<h2>7. The kernel and firmware</h2> +<h2 id="s7-1">7.1 The kernel package</h2> +<p>Nobody builds a kernel in Chamesle. <code>sys-kernel/linux</code> 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</p> +<pre>/boot/vmlinuz-VERSION +/boot/config-VERSION +/boot/System.map-VERSION +/lib/modules/VERSION/</pre> +<p><code>VERSION</code> is the one the package carries, such as <code>6.18.63-0-lts</code>. <code>sys-kernel/linux-headers</code> has the headers the libc and util-linux build against.</p> +<h2 id="s7-2">7.2 Updating</h2> +<p>The mirror drops a package when a newer one comes out, so a new kernel is a new <code>version</code> and <code>sha256</code> in the recipe. Edit <code>repo/sys-kernel/linux</code>:</p> +<pre>version: 6.18.64 +sha256: the new one</pre> +<p>Download the file the <code>url</code> names with the new version filled in, and take the checksum:</p> +<pre>ftp -o FILE URL +mag hash FILE</pre> +<p>Then:</p> +<pre>mag install sys-kernel/linux</pre> +<p>and add an entry in <code>/boot/limine.conf</code> for the new <code>vmlinuz-VERSION</code>. Keep the old one until the new one has booted:</p> +<pre>/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</pre> +<p>After a reboot, <code>uname -r</code> says what runs.</p> +<h2 id="s7-3">7.3 Modules</h2> +<p>Modules are <code>.ko</code> files in <code>/lib/modules/VERSION</code>. <code>lsmod</code> shows what is loaded, <code>modprobe name</code> loads a module with what it needs, <code>modinfo name</code> 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.</p> +<h2 id="s7-4">7.4 Firmware</h2> +<pre>mag install sys-kernel/linux-firmware</pre> +<p>puts the firmware for wifi, graphics, ethernet and the rest, compressed with zstd, into <code>/lib/firmware</code>. <code>sys-firmware/sof-firmware</code> has the sound firmware of newer Intel machines. Both are in the base set. A new firmware release is a new <code>version</code> and <code>sha256</code> in <code>repo/sys-kernel/linux-firmware</code>, the same way as the kernel's.</p> +<h2 id="s7-5">7.5 An initramfs</h2> +<p>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.</p> +<p><code>iso/mkinitramfs</code> makes one, and the live ISO uses it:</p> +<pre>mkinitramfs [-m modules-file] ROOTFS KVER OUT</pre> +<p><code>ROOTFS</code> is the root whose <code>/lib/modules</code> and programs are used, <code>KVER</code> the name of the kernel's directory in <code>/lib/modules</code>, <code>OUT</code> the file to write. It puts in a few tools (<code>sh mount umount switch_root insmod mkdir sleep blkid</code>, and <code>zpool</code> when the root has it, with the libraries they need), the modules named in the modules file together with what they depend on, and <code>iso/init</code>. The names after a <code>[zfs]</code> line of the modules file go into a second list, which <code>iso/init</code> loads only for <code>root=ZFS=</code>. The result is a zstd compressed cpio.</p> +<pre>$HOME/src/system/iso/mkinitramfs -m modules /mnt 6.18.63-0-lts /mnt/boot/initrd</pre> +<p><code>iso/init</code> mounts <code>proc</code>, <code>sysfs</code> and <code>devtmpfs</code>, loads the modules, reads <code>root=</code> from the command line (<code>root=UUID=...</code> or a device), waits up to 15 seconds for the device, mounts it read-only at <code>/mnt/root</code>, and runs <code>switch_root /mnt/root /sbin/init</code>. With <code>root=ZFS=rpool/root</code> it loads the zfs modules, runs <code>zpool import -N -d /dev rpool</code> (until it works, 15 seconds at most) and mounts the dataset with <code>mount -o zfsutil -t zfs</code>. If anything fails it prints why and drops into a shell.</p> +<p>Name the initrd in <code>limine.conf</code>:</p> +<pre>/Chamesle + protocol: linux + path: boot():/vmlinuz-6.18.63-0-lts + module_path: boot():/initrd + cmdline: root=UUID=ROOT-UUID rw</pre> +<p>On ZFS the command line is <code>root=ZFS=rpool/root rw</code>. The ZFS module is <code>sys-kernel/zfs-module</code>, for the kernel of <code>sys-kernel/linux</code>: when one is updated the other has to be too, and <code>depmod</code> has to run after installing it.</p> +<hr> +<p><a href="handbook-base.html">&larr; The base system</a> | <a href="docs.html">Contents</a> | <a href="handbook-iso.html">The live ISO &rarr;</a></p> +</main> + +<hr> +<div id="foot"> +Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> +Chamesle is installed by hand, from the <a href="docs.html">handbook</a>.<br> +<a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> +<a href="#" id="edit-link">Edit text</a><br> +$Date: 2026-11-16 $ +</div> + +</div> + +<script src="edit.js"></script> +</body> +</html> diff --git a/docs/handbook-mag.html b/docs/handbook-mag.html @@ -0,0 +1,146 @@ +<!doctype html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>Using mag - Chamesle</title> +<meta name="description" content="add is install and del is remove. mag relocate is the one command not in the usage text: it puts the real"> +<link rel="canonical" href="https://chamesle.org/handbook-mag.html"> +<meta property="og:type" content="website"> +<meta property="og:site_name" content="Chamesle"> +<meta property="og:title" content="Using mag - Chamesle"> +<meta property="og:description" content="add is install and del is remove. mag relocate is the one command not in the usage text: it puts the real"> +<meta property="og:url" content="https://chamesle.org/handbook-mag.html"> +<link rel="stylesheet" href="style.css?13"> +</head> +<body> + +<div id="page"> + +<div id="top"> +<h1><a href="./">Chamesle</a></h1> +</div> + +<div id="nav"> +<a href="./">Home</a> | +<a href="download.html">Install</a> | +<b>Handbook</b> | +<a href="packages.html">Packages</a> | +<a href="new.html">News</a> | +<a href="board.html">Board</a> | +<a href="chat.html">Chat</a> | +<a href="source.html">Source</a> | +<a href="https://x22.chamesle.org/">X22</a> | +<a href="about.html">About</a> +</div> + +<main> +<p><a href="handbook-installing.html">&larr; Installing by hand</a> | <a href="docs.html">Contents</a> | <a href="handbook-rifle.html">rifle &rarr;</a></p> +<h2>4. Using mag</h2> +<h2 id="s4-1">4.1 The commands</h2> +<pre>Usage: mag [-nfk] COMMAND [PACKAGE]... + +install PKG... fetch, build and install, dependencies first +remove PKG... take a package off +upgrade reinstall what the repos have a newer version of +autoremove remove what was only installed as a dependency and is not needed now +list what is installed +info PKG what a recipe says, and whether it is installed +search WORD recipes whose name or desc has WORD +files PKG the files a package put on the system +owns PATH which package a file came from +deps PKG its dependencies, rdeps PKG for what needs it +fetch PKG... only download and check the sources +build PKG build into a stage directory, install nothing +sync download the pkgsrc tree to /usr/pkgsrc +hash FILE... sha256 of files, for writing recipes + +-n only say what would happen -f go on when files clash or something needs the package +-k keep the build directory</pre> +<p><code>add</code> is <code>install</code> and <code>del</code> is <code>remove</code>. <code>mag relocate</code> is the one command not in the usage text: it puts the real loader and library paths into what was built in a <code>MAG_ROOT</code> (section 4.4). <code>mag --version</code> and <code>mag --help</code> do what they say.</p> +<h2 id="s4-2">4.2 Installing and removing</h2> +<pre>mag install shells/mksh +mag install editors/vim net/tnftp +mag -n install net/tnftp what would be built, nothing is done +mag remove vim</pre> +<p>Packages are named as in the repo, <code>category/name</code>. <code>install</code> takes the dependencies first, downloads the source, checks its sha256 against the recipe or the pkgsrc <code>distinfo</code>, builds into a staging directory, and then installs.</p> +<p>What <code>mag</code> guarantees when it installs:</p> +<ul> +<li>every file is checked against what other packages own before anything is touched; a clash stops it (<code>-f</code> goes on)</li> +<li>files are put in place with a rename, so a running program is never half written</li> +<li>a file under <code>/etc</code> that is already there stays, and the package's version is written next to it as <code>.new</code></li> +<li>each package keeps its file list in <code>var/lib/mag</code>, which is all <code>remove</code>, <code>files</code>, <code>owns</code> and <code>autoremove</code> use</li> +</ul> +<p><code>remove</code> stops when another package needs the one you remove; <code>-f</code> goes on. <code>autoremove</code> takes off the packages that were installed only as dependencies and that nothing needs any more.</p> +<h2 id="s4-3">4.3 Finding things</h2> +<pre>mag search editor names and descriptions +mag info net/tnftp the recipe, its version, whether it is installed, its options +mag deps net/tnftp what it needs +mag rdeps sys-libs/musl what needs it +mag files vim what an installed package put on the disk +mag owns /usr/bin/vim which package a file belongs to +mag list everything installed</pre> +<h2 id="s4-4">4.4 Installing somewhere else</h2> +<p><code>MAG_ROOT=/mnt mag install ...</code> installs and records in <code>/mnt</code> instead of <code>/</code>. This is how a new system is built (chapter 3), and how the root of an ISO is built (chapter 8). The <code>etc/mag.conf</code> inside that root is the one used.</p> +<p>Once the root has musl, mag aims clang at it so that what is built can run on the host (section 9.4). <code>mag relocate</code> puts the real paths back:</p> +<pre>MAG_ROOT=/mnt mag relocate</pre> +<h2 id="s4-5">4.5 Other variables</h2> +<table> +<tr><th>variable</th><th>meaning</th><th>default</th></tr> +<tr><td><code>MAG_ROOT</code></td><td>where to install</td><td><code>/</code></td></tr> +<tr><td><code>MAG_REPO</code></td><td>repositories, split by colons</td><td><code>/usr/share/mag/repo:/usr/pkgsrc</code></td></tr> +<tr><td><code>MAG_SYNC_URL</code></td><td>the file <code>mag sync</code> fetches</td><td>NetBSD's <code>pkgsrc.tar.xz</code></td></tr> +<tr><td><code>MAG_FETCH</code></td><td>the download command, given a file and a URL</td><td><code>ftp -o</code></td></tr> +<tr><td><code>MAG_PREFIX</code></td><td><code>$PREFIX</code> in the steps</td><td><code>/usr</code></td></tr> +<tr><td><code>MAG_JOBS</code></td><td><code>$JOBS</code> in the steps</td><td><code>JOBS</code> of mag.conf, else 4</td></tr> +<tr><td><code>MAG_SH</code></td><td>the shell the steps run under</td><td><code>/bin/sh</code></td></tr> +</table> +<p>mag does not speak https itself; <code>MAG_FETCH</code> does, so <code>ftp</code> has to be on the machine.</p> +<h2 id="s4-6">4.6 pkgsrc options</h2> +<p>Many pkgsrc packages have options (<code>PKG_OPTIONS</code>). mag works them out the way pkgsrc does: the package's suggested options, then <code>PKG_DEFAULT_OPTIONS</code>, then <code>PKG_OPTIONS.name</code>, each word adding an option, or taking it off when it has a minus. Put them in <code>/etc/mag.conf</code>:</p> +<pre>PKG_DEFAULT_OPTIONS=-http2 idn +PKG_OPTIONS.vim=python</pre> +<p><code>mag info net/tnftp</code> shows the options a package ends up with, and its dependencies change with them. The recipes of Chamesle's own repo have no options; they see <code>JOBS</code> and the flags only.</p> +<h2 id="s4-7">4.7 Writing a recipe</h2> +<p>If pkgsrc does not have what you want, write a recipe. It is a file called <code>category/name</code> in a repository that comes before pkgsrc in <code>MAG_REPO</code>. It can also be a directory with a file called <code>recipe</code> in it, when there are patches or other files to carry: <code>$RECIPE_DIR</code> is that directory (<code>repo/dev-build/libtool</code> is one).</p> +<pre>desc: nl80211 wireless configuration tool +version: 6.17 +url: https://cdn.kernel.org/pub/software/network/iw/iw-${version}.tar.xz +sha256: 7d182e498289ab39b257da6780d562e415377107f50358ee5b55b8cfe40b1e33 +deps: net-libs/libnl devel/pkgconf +steps: + make -j$JOBS + make PREFIX=$PREFIX DESTDIR=$DESTDIR install</pre> +<p>The fields:</p> +<ul> +<li><code>desc</code> is the line <code>mag search</code> matches and shows</li> +<li><code>version</code> is also <code>${version}</code> inside <code>url</code></li> +<li><code>url</code> is the source archive; it is unpacked with its first directory stripped</li> +<li><code>sha256</code> is the checksum of that archive; <code>mag hash file.tar.xz</code> prints it</li> +<li><code>deps</code> are other packages, split by spaces, built first</li> +<li><code>steps:</code> is a block of lines that start with a tab, run as a plain <code>sh -e</code> script in the unpacked source</li> +</ul> +<p>The steps see <code>$DESTDIR</code> (everything has to be installed there, never into the real root), <code>$PREFIX</code> (<code>/usr</code>), <code>$JOBS</code>, <code>$NAME</code>, <code>$VERSION</code>, <code>$SRC</code> and <code>$RECIPE_DIR</code>. The package is made from what ends up in <code>$DESTDIR</code>.</p> +<p>Try it without installing:</p> +<pre>mag build net-wireless/iw builds, says where the files are +mag -k build net-wireless/iw keeps the build directory too</pre> +<p>and when it is right:</p> +<pre>mag install net-wireless/iw</pre> +<hr> +<p><a href="handbook-installing.html">&larr; Installing by hand</a> | <a href="docs.html">Contents</a> | <a href="handbook-rifle.html">rifle &rarr;</a></p> +</main> + +<hr> +<div id="foot"> +Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> +Chamesle is installed by hand, from the <a href="docs.html">handbook</a>.<br> +<a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> +<a href="#" id="edit-link">Edit text</a><br> +$Date: 2026-11-16 $ +</div> + +</div> + +<script src="edit.js"></script> +</body> +</html> diff --git a/docs/handbook-maintaining.html b/docs/handbook-maintaining.html @@ -0,0 +1,93 @@ +<!doctype html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>Maintaining - Chamesle</title> +<meta name="description" content="The first says what would be rebuilt, the second reinstalls whatever the repos have a newer version of. pkgsrc itself is"> +<link rel="canonical" href="https://chamesle.org/handbook-maintaining.html"> +<meta property="og:type" content="website"> +<meta property="og:site_name" content="Chamesle"> +<meta property="og:title" content="Maintaining - Chamesle"> +<meta property="og:description" content="The first says what would be rebuilt, the second reinstalls whatever the repos have a newer version of. pkgsrc itself is"> +<meta property="og:url" content="https://chamesle.org/handbook-maintaining.html"> +<link rel="stylesheet" href="style.css?13"> +</head> +<body> + +<div id="page"> + +<div id="top"> +<h1><a href="./">Chamesle</a></h1> +</div> + +<div id="nav"> +<a href="./">Home</a> | +<a href="download.html">Install</a> | +<b>Handbook</b> | +<a href="packages.html">Packages</a> | +<a href="new.html">News</a> | +<a href="board.html">Board</a> | +<a href="chat.html">Chat</a> | +<a href="source.html">Source</a> | +<a href="https://x22.chamesle.org/">X22</a> | +<a href="about.html">About</a> +</div> + +<main> +<p><a href="handbook-iso.html">&larr; The live ISO</a> | <a href="docs.html">Contents</a> | <a href="handbook-files.html">File reference &rarr;</a></p> +<h2>9. Maintaining</h2> +<h2 id="s9-1">9.1 Updating packages</h2> +<pre>mag -n upgrade +mag upgrade</pre> +<p>The first says what would be rebuilt, the second reinstalls whatever the repos have a newer version of. pkgsrc itself is updated with <code>mag sync</code> (section 2.3). One package: <code>mag install name</code>. When you work with <code>MAG_ROOT</code> set, run <code>mag relocate</code> afterwards.</p> +<h2 id="s9-2">9.2 Cleaning up</h2> +<pre>mag autoremove dependencies nothing needs any more +rm -rf /var/cache/mag/* downloaded sources; they are fetched again when needed</pre> +<h2 id="s9-3">9.3 C23 and CFLAGS</h2> +<p>clang compiles C as C23 by default. Older programs written for C89 or C99 stop with errors about <code>bool</code>, <code>true</code> or <code>false</code> used as names, or about functions declared as <code>int f()</code> and called with arguments. <code>CFLAGS=-O2 -std=gnu17</code> in <code>mag.conf</code> makes the compiler use C17 for every build. It is in the file chamesle-bootstrap writes; if you wrote your own <code>mag.conf</code> without it, add it.</p> +<p>To see the error of a failed build, run <code>mag -k install name</code>: the build directory is kept, and the error is above the line that says <code>the steps failed, left in ...</code>.</p> +<h2 id="s9-4">9.4 The root's compiler and mag relocate</h2> +<p>When <code>MAG_ROOT</code> has musl in it (<code>usr/lib/crt1.o</code> and <code>usr/lib/libc.so</code>), mag makes a <code>cc</code> script in the build directory and puts it first in <code>PATH</code>, with <code>gcc</code>, <code>clang</code> and <code>c99</code> as links to it. It runs the clang of the host with <code>--target=x86_64-linux-musl</code>, <code>--sysroot</code> and <code>-isystem</code> pointed at the root, lld, compiler-rt, and the loader and library paths set to the ones in the root, so that what was built runs on the host. <code>-lgcc</code>, <code>-lgcc_s</code> and <code>-lgcc_eh</code> are dropped from the command line because compiler-rt replaces them.</p> +<p>A program built that way names <code>/mnt/usr/lib/libc.so</code> as its loader and <code>/mnt/usr/lib</code> as its library path. On the real system neither exists, and running the program says "not found" although the file is there. <code>mag relocate</code> goes through <code>usr</code>, <code>bin</code>, <code>sbin</code> and <code>lib</code> in the root and puts back <code>/lib/ld-musl-x86_64.so.1</code> and <code>/usr/lib</code>. Run it before the first boot and after every install into a <code>MAG_ROOT</code>.</p> +<p>If there is no <code>clang</code> in <code>PATH</code> outside the root, mag stops with "no clang in PATH: it is the compiler for a musl root".</p> +<h2 id="s9-5">9.5 libtool</h2> +<p>pkgsrc packages that use libtool expect a <code>libtool</code> script. <code>dev-build/libtool</code> is a small one of Chamesle's that compiles, links and installs shared and static libraries; kmod, for example, is built with <code>LIBTOOL=libtool</code>. If a package fails at a libtool step, read <code>repo/dev-build/libtool/libtool</code>, and for a package that insists on its own libtool pass <code>LIBTOOL=libtool</code> to its <code>make</code>.</p> +<h2 id="s9-6">9.6 Failures you will see</h2> +<table> +<tr><th>what you see</th><th>why, and what to do</th></tr> +<tr><td><code>no recipe for NAME</code></td><td>the name is in no repo of <code>MAG_REPO</code>; try <code>mag search</code>, and check the pkgsrc path is in <code>MAG_REPO</code></td></tr> +<tr><td>a checksum mismatch</td><td>the download is not the one the recipe names; for the kernel see section 7.2</td></tr> +<tr><td><code>no clang in PATH</code></td><td>the build host has no clang outside the new root; install one</td></tr> +<tr><td>a program says <code>not found</code> though the file is there</td><td>its loader path is the one of the build: <code>MAG_ROOT=... mag relocate</code></td></tr> +<tr><td>files clash, or a package cannot be removed</td><td>another package owns the file or needs the package; read what mag says, <code>-f</code> goes on</td></tr> +<tr><td>errors on <code>bool</code>, <code>true</code>, <code>false</code> or on old declarations</td><td>C23; <code>CFLAGS=-O2 -std=gnu17</code> (section 9.3)</td></tr> +<tr><td>musl's build fails</td><td><code>gmake</code> is missing on the host</td></tr> +<tr><td>"root device not found" at boot</td><td>the kernel cannot see the disk or the file system: it needs a module, use an initramfs (section 7.5)</td></tr> +<tr><td>the machine boots to a limine prompt</td><td><code>limine.conf</code> is not found, or its <code>path:</code> does not name a file in <code>/boot</code>; check with <code>ls /boot</code></td></tr> +<tr><td>a BIOS machine does not boot</td><td><code>limine bios-install /dev/sda</code> was not run, or <code>limine-bios.sys</code> is not in <code>/boot</code></td></tr> +<tr><td>a UEFI machine does not boot</td><td><code>EFI/BOOT/BOOTX64.EFI</code> is not on the EFI partition, or the partition is not of type EFI System</td></tr> +<tr><td>a login without a password</td><td>the password field of <code>passwd</code> is empty</td></tr> +<tr><td>no devices in <code>/dev</code></td><td>udev did not start; check that <code>udevd</code> is installed with <code>mag list</code></td></tr> +</table> +<h2 id="s9-7">9.7 Keeping a build</h2> +<pre>mag -k install name</pre> +<p>keeps the build directory. <code>mag fetch name</code> downloads and checks the sources without building, and <code>mag build name</code> builds into a staging directory and prints where the files are.</p> +<hr> +<p><a href="handbook-iso.html">&larr; The live ISO</a> | <a href="docs.html">Contents</a> | <a href="handbook-files.html">File reference &rarr;</a></p> +</main> + +<hr> +<div id="foot"> +Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> +Chamesle is installed by hand, from the <a href="docs.html">handbook</a>.<br> +<a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> +<a href="#" id="edit-link">Edit text</a><br> +$Date: 2026-11-16 $ +</div> + +</div> + +<script src="edit.js"></script> +</body> +</html> diff --git a/docs/handbook-preparing.html b/docs/handbook-preparing.html @@ -0,0 +1,103 @@ +<!doctype html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>Preparing - Chamesle</title> +<meta name="description" content="Chamesle is built from a running Linux machine: any distribution, or the live ISO of chapter 8. The host needs:"> +<link rel="canonical" href="https://chamesle.org/handbook-preparing.html"> +<meta property="og:type" content="website"> +<meta property="og:site_name" content="Chamesle"> +<meta property="og:title" content="Preparing - Chamesle"> +<meta property="og:description" content="Chamesle is built from a running Linux machine: any distribution, or the live ISO of chapter 8. The host needs:"> +<meta property="og:url" content="https://chamesle.org/handbook-preparing.html"> +<link rel="stylesheet" href="style.css?13"> +</head> +<body> + +<div id="page"> + +<div id="top"> +<h1><a href="./">Chamesle</a></h1> +</div> + +<div id="nav"> +<a href="./">Home</a> | +<a href="download.html">Install</a> | +<b>Handbook</b> | +<a href="packages.html">Packages</a> | +<a href="new.html">News</a> | +<a href="board.html">Board</a> | +<a href="chat.html">Chat</a> | +<a href="source.html">Source</a> | +<a href="https://x22.chamesle.org/">X22</a> | +<a href="about.html">About</a> +</div> + +<main> +<p><a href="handbook-about.html">&larr; About Chamesle</a> | <a href="docs.html">Contents</a> | <a href="handbook-installing.html">Installing by hand &rarr;</a></p> +<h2>2. Preparing</h2> +<h2 id="s2-1">2.1 What the build host needs</h2> +<p>Chamesle is built from a running Linux machine: any distribution, or the live ISO of chapter 8. The host needs:</p> +<ul> +<li><code>clang</code> and <code>lld</code>: <code>mag</code> and <code>rifle</code> are built with them, and so is everything in the new system</li> +<li><code>gmake</code>, for musl</li> +<li><code>ftp</code> (tnftp), which mag uses for downloads (<code>MAG_FETCH</code>)</li> +<li><code>tar</code> and a POSIX <code>sh</code></li> +<li><code>sfdisk</code>, <code>mkfs.ext4</code> and <code>mkfs.fat</code> to prepare the disk</li> +<li><code>blkid</code> to read UUIDs</li> +</ul> +<p>Plan for about 20 GB of free disk space for the sources and build directories of a first install, and a network connection.</p> +<h2 id="s2-2">2.2 Building mag and rifle</h2> +<p>Both are a single C file with no libc under it:</p> +<pre>cd $HOME/src/mag &amp;&amp; ./build.sh +cd $HOME/src/rifle &amp;&amp; ./build.sh</pre> +<p><code>mag/build.sh</code> leaves <code>./mag</code>. <code>rifle/build.sh</code> leaves <code>./rifle</code> and a <code>bin/</code> directory with a link for every tool. Put <code>mag</code> in your PATH:</p> +<pre>install -m755 $HOME/src/mag/mag /usr/local/bin/mag</pre> +<h2 id="s2-3">2.3 Getting the pkgsrc tree</h2> +<p>Let mag fetch a pkgsrc tree from NetBSD and unpack it into <code>/usr/pkgsrc</code>:</p> +<pre>mag sync</pre> +<p><code>sync</code> downloads <code>https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.xz</code> and replaces the tree with it, so it is also how the tree is brought up to date. <code>MAG_SYNC_URL</code> names another file, and under <code>MAG_ROOT</code> the tree goes into <code>$MAG_ROOT/usr/pkgsrc</code>. By hand it is the same thing:</p> +<pre>cd /usr +ftp -o pkgsrc.tar.xz https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.xz +tar -xf pkgsrc.tar.xz</pre> +<p>pkgsrc has a directory per category (<code>shells</code>, <code>editors</code>, <code>www</code>, ...) and a directory per package inside it (<code>shells/mksh</code>). <code>mag</code> reads the package's <code>Makefile</code>, <code>distinfo</code> and <code>patches/</code> itself.</p> +<h2 id="s2-4">2.4 MAG_REPO</h2> +<p><code>MAG_REPO</code> is a list of repositories separated by colons. Chamesle's own recipes come first, so they win over pkgsrc when both have a package of the same name:</p> +<pre>export MAG_REPO=$HOME/src/mag/repo:/usr/pkgsrc</pre> +<p>If <code>MAG_REPO</code> is not set, mag looks in <code>/usr/share/mag/repo</code> (Chamesle's own recipes, which the live ISO and every bootstrapped root carry) and then in <code>/usr/pkgsrc</code>, where <code>mag sync</code> puts the tree. <code>MAG_ROOT</code> says where to install; it is the new root during an installation (chapter 3) and unset on a running system.</p> +<p>A file called <code>PROVIDES</code> in a repo tells mag how our recipes meet pkgsrc's. Its lines are:</p> +<pre>pkgsrc/package our/package our package stands in for the pkgsrc one +pkgsrc/package - nothing is needed, the dependency is dropped +needs pkgsrc/package dep a dependency the pkgsrc Makefile forgets</pre> +<p>For example <code>converters/libiconv -</code> (musl has iconv) and <code>needs editors/vim dev-libs/netbsd-curses</code>.</p> +<h2 id="s2-5">2.5 mag.conf</h2> +<p><code>$MAG_ROOT/etc/mag.conf</code> holds the build settings. It uses the syntax of pkgsrc's <code>mk.conf</code>: plain <code>VAR=value</code> lines. <code>chamesle-bootstrap</code> writes a first one for the new system. For the host you build from, make one yourself:</p> +<pre>JOBS=8 +CFLAGS=-O2 -std=gnu17</pre> +<ul> +<li><code>JOBS</code> is <code>$JOBS</code> in the build steps, the number to give <code>make -j</code>. Without it mag uses 4</li> +<li><code>CFLAGS</code>, <code>CXXFLAGS</code>, <code>CPPFLAGS</code> and <code>LDFLAGS</code> are set for every build</li> +<li><code>PKG_DEFAULT_OPTIONS</code> and <code>PKG_OPTIONS.name</code> set pkgsrc options (section 4.6)</li> +<li><code>CONFIGURE_ARGS.name</code> adds arguments to the <code>configure</code> of one pkgsrc package, such as <code>CONFIGURE_ARGS.libtirpc=--disable-gssapi</code></li> +</ul> +<p>The environment wins over the file: <code>MAG_JOBS</code>, <code>CFLAGS</code> and the others, when set, are used as they are.</p> +<p><code>-std=gnu17</code> matters. clang defaults to C23 now, and a lot of older source does not compile under it (section 9.3).</p> +<hr> +<p><a href="handbook-about.html">&larr; About Chamesle</a> | <a href="docs.html">Contents</a> | <a href="handbook-installing.html">Installing by hand &rarr;</a></p> +</main> + +<hr> +<div id="foot"> +Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> +Chamesle is installed by hand, from the <a href="docs.html">handbook</a>.<br> +<a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> +<a href="#" id="edit-link">Edit text</a><br> +$Date: 2026-11-16 $ +</div> + +</div> + +<script src="edit.js"></script> +</body> +</html> diff --git a/docs/handbook-rifle.html b/docs/handbook-rifle.html @@ -0,0 +1,91 @@ +<!doctype html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>rifle - Chamesle</title> +<meta name="description" content="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"> +<link rel="canonical" href="https://chamesle.org/handbook-rifle.html"> +<meta property="og:type" content="website"> +<meta property="og:site_name" content="Chamesle"> +<meta property="og:title" content="rifle - Chamesle"> +<meta property="og:description" content="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"> +<meta property="og:url" content="https://chamesle.org/handbook-rifle.html"> +<link rel="stylesheet" href="style.css?13"> +</head> +<body> + +<div id="page"> + +<div id="top"> +<h1><a href="./">Chamesle</a></h1> +</div> + +<div id="nav"> +<a href="./">Home</a> | +<a href="download.html">Install</a> | +<b>Handbook</b> | +<a href="packages.html">Packages</a> | +<a href="new.html">News</a> | +<a href="board.html">Board</a> | +<a href="chat.html">Chat</a> | +<a href="source.html">Source</a> | +<a href="https://x22.chamesle.org/">X22</a> | +<a href="about.html">About</a> +</div> + +<main> +<p><a href="handbook-mag.html">&larr; Using mag</a> | <a href="docs.html">Contents</a> | <a href="handbook-base.html">The base system &rarr;</a></p> +<h2>5. rifle</h2> +<h2 id="s5-1">5.1 What it is</h2> +<p>rifle is the coreutils of Chamesle in one C file, <code>rifle.c</code>, on <code>c.h</code>, 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.</p> +<p>There is one program. <code>cat</code>, <code>ls</code>, <code>cp</code> and the other commands are links to it, and it runs whichever name it was called by. You type <code>cat</code>, not <code>rifle cat</code>.</p> +<h2 id="s5-2">5.2 The tools</h2> +<pre>[ arch base32 base64 basename cat chgrp chmod chown chroot cksum comm cp cut date dd df dirname du echo env +expand expr factor false fold groups head hostid hostname id install join link ln logname ls md5sum mkdir +mkfifo mknod mktemp mv nice nl nohup nproc od paste printenv printf pwd readlink realpath rm rmdir seq +sha1sum sha224sum sha256sum sha384sum sha512sum shuf sleep sort split stat sum sync tac tail tee test +timeout touch tr true truncate tsort tty uname unexpand uniq unlink wc whoami yes</pre> +<p>By what they do:</p> +<table> +<tr><th>group</th><th>tools</th></tr> +<tr><td>files and directories</td><td><code>cp mv rm ln link unlink mkdir rmdir mkfifo mknod mktemp touch install truncate dd sync</code></td></tr> +<tr><td>permissions and owners</td><td><code>chmod chown chgrp</code></td></tr> +<tr><td>looking at files</td><td><code>ls stat du df cat tac head tail od nl wc cksum sum</code></td></tr> +<tr><td>text</td><td><code>cut paste join comm sort uniq tr fold expand unexpand split shuf tsort tee</code></td></tr> +<tr><td>checksums and encodings</td><td><code>md5sum sha1sum sha224sum sha256sum sha384sum sha512sum base32 base64</code></td></tr> +<tr><td>names and paths</td><td><code>basename dirname pwd readlink realpath</code></td></tr> +<tr><td>scripts and processes</td><td><code>echo printf printenv env test [ expr seq true false yes sleep nice nohup timeout chroot</code></td></tr> +<tr><td>system and users</td><td><code>arch uname hostname hostid id groups whoami logname date nproc tty</code></td></tr> +<tr><td>numbers</td><td><code>factor</code> (up to 64 bits)</td></tr> +</table> +<p>Not there yet: <code>stty</code>, <code>who</code> and friends, <code>fmt</code>, <code>pr</code>, <code>csplit</code>, <code>numfmt</code>, <code>shred</code>, <code>stdbuf</code>, <code>ptx</code>, <code>pathchk</code>, <code>dircolors</code>.</p> +<h2 id="s5-3">5.3 Building</h2> +<pre>cd $HOME/src/rifle +./build.sh</pre> +<p>builds <code>rifle</code> with clang and lld (<code>CC</code> overrides <code>cc</code>) and makes the links in <code>bin/</code>. To put the links anywhere:</p> +<pre>rifle --install /usr/bin +rifle --list the names it knows</pre> +<h2 id="s5-4">5.4 Tests</h2> +<pre>tests/run.sh all the cases +tests/run.sh sort the cases that have `sort` in them</pre> +<p>Each case in <code>tests/cases</code> runs once under GNU coreutils and once under rifle, and what they print and how they exit are compared. The machine that runs the tests therefore has GNU coreutils for the comparison; the installed system does not. <code>./build.sh</code> has to have run first. A case that starts with <code>@ro</code> runs with the whole file system read-only under <code>bwrap</code>, and is skipped when <code>bwrap</code> is missing.</p> +<p>mag has a test of its own: <code>mag/tests/run.sh</code> builds a fake repo with local tarballs and goes through install, upgrade and remove in a scratch root. It needs ftp, tar and the rifle tools in PATH.</p> +<hr> +<p><a href="handbook-mag.html">&larr; Using mag</a> | <a href="docs.html">Contents</a> | <a href="handbook-base.html">The base system &rarr;</a></p> +</main> + +<hr> +<div id="foot"> +Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> +Chamesle is installed by hand, from the <a href="docs.html">handbook</a>.<br> +<a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> +<a href="#" id="edit-link">Edit text</a><br> +$Date: 2026-11-16 $ +</div> + +</div> + +<script src="edit.js"></script> +</body> +</html> diff --git a/docs/sitemap.xml b/docs/sitemap.xml @@ -4,7 +4,17 @@ <url><loc>https://chamesle.org/download.html</loc><lastmod>2026-11-14</lastmod></url> <url><loc>https://chamesle.org/new.html</loc><lastmod>2026-11-14</lastmod></url> <url><loc>https://chamesle.org/about.html</loc><lastmod>2026-11-14</lastmod></url> - <url><loc>https://chamesle.org/docs.html</loc><lastmod>2026-11-14</lastmod></url> + <url><loc>https://chamesle.org/docs.html</loc><lastmod>2026-11-16</lastmod></url> + <url><loc>https://chamesle.org/handbook-about.html</loc><lastmod>2026-11-16</lastmod></url> + <url><loc>https://chamesle.org/handbook-preparing.html</loc><lastmod>2026-11-16</lastmod></url> + <url><loc>https://chamesle.org/handbook-installing.html</loc><lastmod>2026-11-16</lastmod></url> + <url><loc>https://chamesle.org/handbook-mag.html</loc><lastmod>2026-11-16</lastmod></url> + <url><loc>https://chamesle.org/handbook-rifle.html</loc><lastmod>2026-11-16</lastmod></url> + <url><loc>https://chamesle.org/handbook-base.html</loc><lastmod>2026-11-16</lastmod></url> + <url><loc>https://chamesle.org/handbook-kernel.html</loc><lastmod>2026-11-16</lastmod></url> + <url><loc>https://chamesle.org/handbook-iso.html</loc><lastmod>2026-11-16</lastmod></url> + <url><loc>https://chamesle.org/handbook-maintaining.html</loc><lastmod>2026-11-16</lastmod></url> + <url><loc>https://chamesle.org/handbook-files.html</loc><lastmod>2026-11-16</lastmod></url> <url><loc>https://chamesle.org/packages.html</loc><lastmod>2026-11-14</lastmod></url> <url><loc>https://chamesle.org/source.html</loc><lastmod>2026-11-14</lastmod></url> <url><loc>https://chamesle.org/chess.html</loc><lastmod>2026-11-14</lastmod></url>