handbook.md (48693B)
1 # The Chamesle Handbook 2 3 1. About Chamesle 4 2. Preparing 5 3. Installing 6 4. mag 7 5. rifle 8 6. The base system 9 7. The kernel and firmware 10 8. The live ISO 11 9. Maintaining 12 10. File reference 13 14 15 ## 1. About Chamesle 16 17 ### 1.1 What it is 18 19 Chamesle is a small Linux distribution on musl, installed from the ISO. Nothing is compiled: `chamesle-bootstrap` puts 20 the base into an empty root with the package manager. `chamesle-install` does the whole install from a few questions, 21 or you do it by hand, writing the fstab, the password and the boot entry yourself. This handbook goes through every step. 22 23 The parts: 24 25 | part | what it is | 26 |--------|------------| 27 | kernel | a prebuilt Linux LTS kernel with its modules | 28 | musl | the C library | 29 | mag | the package manager, binary packages only, in one C file | 30 | rifle | the coreutils, all in one C file; `cat`, `ls`, `cp` and the rest are links to one program | 31 | mksh | the login shell; `/bin/sh` is busybox's ash | 32 | init | OpenRC, the services come with their packages | 33 | limine | the boot loader, BIOS and UEFI | 34 35 Chamesle is made to be the most UNIX distribution possible, and to run on almost anything: the same base goes on a new 36 laptop and on a Pentium 4 with 256 MB of memory. It is a system for the tty first. Anything else is a `mag install` away. 37 38 ### 1.2 Where the packages come from 39 40 mag reads two kinds of repository, both signed: 41 42 * Chamesle's own, at `https://chamesle.org/repo`: `chamesle-base` (the files in `/etc`, the tools of this 43 book and the keys), `mag` and `rifle` 44 * a large musl repository with everything else: the kernel, the firmware, the libraries, editors, compilers, X, about 45 28,000 packages for x86_64 46 47 Both are in `/etc/mag/repos`. A package is checked against the keys in `/etc/mag/keys` before anything of it is unpacked. 48 49 ### 1.3 The glibc Chamesle 50 51 There is a second Chamesle on glibc, for what musl cannot run: NVIDIA's driver, Steam, programs that only come built for 52 glibc. It is the same idea on other packages. mag, rifle, the tools and OpenRC are the same; the packages are Artix's 53 and Arch's, about 25,000, and anything else comes from the AUR, built here. `chamesle-install` asks which one you want, 54 `chamesle-bootstrap -l glibc` makes it by hand (3.12). 55 56 | part | musl Chamesle | glibc Chamesle | 57 |--------|---------------|----------------| 58 | kernel | Linux LTS | Linux, latest (`linux-lts` and `linux-zen` are there too) | 59 | initramfs | mkinitfs | mkinitcpio | 60 | file systems | ZFS, btrfs, ext4 | btrfs, ext4 | 61 | login shell | mksh | bash | 62 | packages | ~28,000 | ~25,000, and the AUR | 63 64 On glibc, coreutils owns `/usr/bin/ls` and the rest, so rifle's links are in `/usr/lib/rifle/bin`, which a login shell 65 puts first in PATH (`/etc/profile.d/rifle.sh`). 66 67 ### 1.4 The layout of the system 68 69 /bin /sbin /lib /lib holds the musl loader and the firmware 70 /usr/bin /usr/sbin programs, /usr/lib libraries, /usr/share data 71 /usr/local/bin yours, first in PATH 72 /boot kernel, initramfs, limine.conf (on the EFI partition) 73 /etc configuration; /etc/mag is mag's 74 /lib/modules kernel modules, one directory per kernel version 75 /lib/firmware firmware for the hardware 76 /var/lib/mag which package owns which file 77 /var/cache/mag downloaded indexes and packages 78 /run /tmp tmpfs, made new at every boot 79 80 ### 1.5 Where the sources are 81 82 | directory | what is in it | 83 |-----------|---------------| 84 | `system/` | `tools/` (`chamesle-bootstrap`, `chamesle-disk`, `chamesle-boot`, and `mkapk`, `mkrepo`, `mkpkgs` for the repo), `files/` (init, rc and the services), `pkg/`, `keys/`, `iso/`, this handbook | 85 | `mag/` | `mag.c`, `c.h`, `build.sh` | 86 | `rifle/` | `rifle.c`, `build.sh`, `tests/run.sh` | 87 88 They are on github.com/tortr-rs. 89 90 91 ## 2. Preparing 92 93 ### 2.1 What you need 94 95 * the ISO, from chamesle.org, written to a stick or a disc (chapter 8). It has everything chapter 3 uses 96 * a network connection: the packages come from the repositories 97 * about 1 GB of disk for a base system with a kernel, more for what you add 98 * 256 MB of memory is enough to install and to run 99 100 The CPU can be x86_64, or a 32-bit x86 one from the Pentium 4 on (section 3.10). 101 102 ### 2.2 From another Linux 103 104 The ISO is the easy way, but any Linux machine can install Chamesle. It needs `mag`, the keys and the repos: 105 106 curl -LO https://chamesle.org/repo/x86_64/mag-0.3.apk 107 tar -xzf mag-0.3.apk usr/bin/mag 108 mkdir -p /etc/mag 109 cp -R keys /etc/mag/keys 110 cp pkg/chamesle-base/repos /etc/mag/repos 111 install -m755 usr/bin/mag /usr/local/bin/mag 112 113 `keys/` and `pkg/chamesle-base/repos` are in `system/` of the sources. The `tar` line warns about the signature and 114 control parts it does not know; the program comes out all the same. mag is static, so it runs on any distribution. 115 From there chapter 3 is the same, without the live system. 116 117 ### 2.3 Getting on the network 118 119 On the live system a cable works by itself: `dhcpcd` runs at boot. Check it with 120 121 ip addr 122 ping -c 3 chamesle.org 123 124 For wireless, `iwctl` (iwd runs at boot on the ISO): 125 126 iwctl device list 127 iwctl station wlan0 scan 128 iwctl station wlan0 get-networks 129 iwctl station wlan0 connect NAME 130 131 It asks for the passphrase. dhcpcd gives the interface an address once it is connected. 132 133 134 ## 3. Installing 135 136 The live system has `chamesle-install`, which asks for the keyboard (loaded right away, and set for the console and X 137 on the new system), the disk, on x86_64 musl or glibc (and on glibc the kernel: linux-lts, or linux for the newest 138 hardware), the file system (ZFS, btrfs or ext4), the bootloader 139 (limine or GRUB), the firmware (what the machine has is ticked), wifi, the host name, the root password and a user, and 140 then does this chapter on the whole disk. The log is `/var/log/chamesle-install.log`, and a copy is kept on the new 141 system. The rest of the chapter is the same install by hand, for another layout or to know what it did. 142 143 Follow the BIOS or the UEFI variant where they differ. The disk here is `/dev/sda`; change it to yours. Everything below 144 is run as root on the live system, and it erases the disk. 145 146 There are two ways through 3.1 and 3.2: `chamesle-disk` does the partitioning and the file systems, or you do both 147 yourself. From 3.3 on the steps are the same, and they are yours: 148 `chamesle-disk` is only a helper. 149 150 ### 3.1 chamesle-disk 151 152 chamesle-disk /dev/sda 153 chamesle-disk -t btrfs /dev/sda 154 chamesle-disk -t ext4 -y /dev/sda 155 156 `-t` is the file system of the root: `zfs` (the default), `btrfs` or `ext4`. btrfs gets the subvolumes `@` for `/` 157 and `@home` for `/home`, mounted with `compress=zstd`. `-y` asks nothing and lays out the whole disk as in the table 158 below. 159 160 It lists the disk and asks you to type its name before it touches anything. Then it starts `cfdisk` so you lay out the 161 partitions. Three of them work for BIOS and UEFI both: 162 163 | partition | size | type | use | 164 |-----------|------|------|-----| 165 | 1 | 1M | BIOS boot | limine's BIOS code, not used on UEFI | 166 | 2 | 512M | EFI System | `/boot`, FAT32 | 167 | 3 | the rest | Linux filesystem | `/`, ZFS | 168 169 On a machine that boots by BIOS, a GPT disk needs the 1M BIOS boot partition; without it chamesle-disk and 170 chamesle-boot stop and say so. A dos label works too. 171 172 Write the table and quit cfdisk. chamesle-disk lists the partitions and asks which one is the boot partition and which is 173 the root. Then it does, in this order: 174 175 mkfs.fat -F32 BOOT 176 zpool create -f -o ashift=12 -O compression=zstd -O acltype=posixacl -O xattr=sa -O mountpoint=none -R /mnt rpool ROOT 177 zfs create -o mountpoint=/ -o canmount=noauto rpool/root 178 zfs mount rpool/root 179 zfs create -o mountpoint=/home rpool/home 180 zfs create -o mountpoint=/var rpool/var 181 zpool set bootfs=rpool/root rpool 182 183 and mounts `rpool/root`, `rpool/home` and `rpool/var` under `/mnt` and the boot partition on `/mnt/boot`. It also writes 184 `/mnt/etc/fstab` with the boot partition by UUID and the `proc`, `sysfs` and `tmpfs` lines. It writes nothing else. 185 186 ZFS mounts its own datasets, so the fstab does not list them. limine cannot read ZFS: the kernel, the initramfs and 187 `limine.conf` live on the FAT partition, which is `/boot`. 188 189 ZFS on a machine with little memory is slow; on the 256 MB machine use ext4 (3.2). 190 191 ### 3.2 Partitioning and file systems by hand 192 193 For a root on ext4. The layout is the one in 3.1, `sda1` to `sda3`: 194 195 sfdisk /dev/sda <<P 196 label: gpt 197 size=1M, type=21686148-6449-6E6F-744E-656564454649 198 size=512M, type=U 199 type=L 200 P 201 202 On an NVMe disk the partitions are `/dev/nvme0n1p1` and so on. Replace `sda1`, `sda2` and `sda3` throughout. 203 204 mkfs.fat -F32 /dev/sda2 205 mkfs.ext4 /dev/sda3 206 mount /dev/sda3 /mnt 207 mkdir /mnt/boot 208 mount /dev/sda2 /mnt/boot 209 210 The FAT partition is `/boot`. The kernel and `limine.conf` end up there, where limine looks for them on both BIOS and 211 UEFI. 212 213 ### 3.3 chamesle-bootstrap 214 215 chamesle-bootstrap /mnt 216 217 That is the whole base. It copies `/etc/mag/repos` and `/etc/mag/keys` of the live system into `/mnt`, runs 218 `mag update` there, and installs `chamesle-base`, the kernel (`linux-lts`) and its firmware with everything they need. The 219 kernel package writes `vmlinuz-lts` and `initramfs-lts` into `/mnt/boot`. It takes as long as the download, a few minutes. 220 221 chamesle-bootstrap [-a ARCH] [-n HOSTNAME] [-k KERNEL] [-f FIRMWARE] TARGET [PACKAGE]... 222 223 | option | what | 224 |--------|------| 225 | `-n` | the host name, `chamesle` if not given | 226 | `-f` | the firmware package. The default, `linux-firmware-none`, has no firmware; take the one your hardware needs (7.4) | 227 | `-k` | the kernel package, `linux-lts` if not given | 228 | `-a` | the architecture, the machine's own if not given (3.10) | 229 230 Packages after the target go in too. A ThinkPad with Intel wireless and graphics, with an editor: 231 232 chamesle-bootstrap -n t480 -f linux-firmware-intel /mnt vim 233 234 What `chamesle-base` brings: OpenRC and the files of chapter 6, mag, rifle, mksh, busybox for the tools rifle does not 235 have, bash, `agetty`, eudev, kmod, dhcpcd, e2fsprogs, curl and `arch-chroot`. 236 237 ### 3.4 Working inside the new root 238 239 arch-chroot /mnt 240 arch-chroot /mnt passwd root 241 242 `arch-chroot` is Arch's, the same script. It mounts `proc`, `sys`, `dev`, `dev/pts`, `dev/shm`, `run` and `tmp` under 243 the directory, puts the live system's `/etc/resolv.conf` in it, and takes the mounts away again when the command ends. 244 Without a command it starts bash. Inside, `mag install name` works as on the finished system. 245 246 ### 3.5 fstab 247 248 If you used chamesle-disk the file is written. Look at it: the boot partition by UUID on `/boot`, then `proc`, `sysfs` 249 and `tmpfs`, and nothing for the ZFS datasets, because ZFS mounts them itself. 250 251 By hand, `blkid` prints the UUIDs: 252 253 blkid /dev/sda2 /dev/sda3 254 255 Write `/mnt/etc/fstab`: 256 257 UUID=ROOT-UUID / ext4 defaults 0 1 258 UUID=BOOT-UUID /boot vfat defaults 0 2 259 proc /proc proc defaults 0 0 260 sysfs /sys sysfs defaults 0 0 261 tmpfs /tmp tmpfs nosuid,nodev 0 0 262 263 A root on ZFS gets no root line. 264 265 ### 3.6 Host name and password 266 267 The host name is in `/mnt/etc/hostname`, from `-n`. Set the root password: 268 269 arch-chroot /mnt passwd root 270 271 The hash goes into `/etc/shadow`. The login shell of root is mksh. 272 273 ### 3.7 The boot entry 274 275 chamesle-boot /mnt 276 chamesle-boot -b grub /mnt 277 278 `-b grub` installs GRUB instead of limine, for UEFI and for BIOS, and writes `/boot/grub/grub.cfg` the same way. 279 280 It looks at what is mounted on `/mnt` and `/mnt/boot` and 281 282 * installs `limine` into the new root, so its boot files and its `limine` are the same version 283 * for a root on ZFS, installs `zfs` and `zfs-lts`, adds `zfs` to the initramfs (7.5) and `zfs-import` and 284 `zfs-mount` to the sysinit runlevel; for btrfs, installs `btrfs-progs`, adds `btrfs` to the initramfs and puts the 285 subvolume on the kernel command line 286 * writes `/mnt/boot/limine.conf` with an entry for every kernel in `/mnt/boot`, the root by UUID, or by dataset on ZFS 287 * copies `BOOTX64.EFI` to `EFI/BOOT/` on the boot partition, for UEFI 288 * runs `limine bios-install` on the disk, for BIOS; on a GPT disk only when it has a BIOS boot partition, else it says 289 the disk boots by UEFI only 290 291 An old `limine.conf` is kept as `limine.conf.old`. If `/boot` is not FAT, limine cannot read it; chamesle-boot then 292 writes nothing and prints an entry for the GRUB of the system already on the machine (3.11). 293 294 What it does by hand follows; skip to 3.8 if it said nothing went wrong. 295 296 ls /mnt/boot 297 System.map-7.3.5-0-lts config-7.3.5-0-lts initramfs-lts vmlinuz-lts 298 299 The names stay the same when the kernel is updated, so `limine.conf` is written once. `/mnt/boot/limine.conf`, with 300 the UUID of the root partition: 301 302 timeout: 3 303 304 /Chamesle 305 protocol: linux 306 path: boot():/vmlinuz-lts 307 module_path: boot():/initramfs-lts 308 cmdline: root=UUID=ROOT-UUID modules=sd-mod,usb-storage,nvme,ext4 rootfstype=ext4 quiet 309 310 `boot()` is the partition `limine.conf` is on, which is `/boot`. The initramfs finds the root, loads the modules on the 311 command line and starts `/sbin/init`. Take `quiet` out to see the kernel's messages. For a serial console add 312 `console=ttyS0,115200`. 313 314 A root on ZFS names the dataset; the initramfs needs the zfs module, which is section 7.5: 315 316 cmdline: root=ZFS=rpool/root rootfstype=zfs quiet 317 318 Install limine into the new root, and use its files, not the ones of the live system; the two can differ in version, and 319 limine's BIOS stage only works with a `limine-bios.sys` of its own version: 320 321 arch-chroot /mnt mag install limine 322 323 #### BIOS 324 325 cp /mnt/usr/share/limine/limine-bios.sys /mnt/boot/ 326 arch-chroot /mnt limine bios-install /dev/sda 327 328 `limine bios-install` writes the loader to the start of the disk and into the BIOS boot partition, which a GPT disk 329 needs (3.1). `limine-bios.sys` on the FAT partition is the part it loads. 330 331 #### UEFI 332 333 mkdir -p /mnt/boot/EFI/BOOT 334 cp /mnt/usr/share/limine/BOOTX64.EFI /mnt/boot/EFI/BOOT/ 335 336 The firmware starts `EFI/BOOT/BOOTX64.EFI` of the EFI System partition by itself. 337 338 Do both and the disk boots either way. 339 340 ### 3.8 First boot 341 342 umount -R /mnt 343 zpool export rpool 344 reboot 345 346 Leave out `zpool export` if the root is not on ZFS. 347 348 Take out the installation medium. limine shows the entry for three seconds and boots the kernel. OpenRC mounts the 349 file systems, starts the services of the runlevels and puts a login on the ttys. Log in as root. `dhcpcd` brings up a 350 cable at boot; for wireless see section 6.8. 351 352 ### 3.9 What to install next 353 354 mag install vim htop tmux 355 mag search irc 356 357 Chapter 4 has the rest, chapter 10 a graphical desktop. 358 359 ### 3.10 32-bit machines 360 361 On a 32-bit PC (Pentium 4, Athlon XP and the like) boot the ISO on another machine, or install from any Linux there 362 (2.2), and give the architecture: 363 364 chamesle-bootstrap -a x86 /mnt 365 366 The x86 repository has the same packages, built for i686 with SSE2. `-a x86` is written to `/mnt/etc/mag/arch`, and mag 367 keeps to it from then on. `rifle` is only built for x86_64, so on x86 busybox gives the coreutils. limine boots 32-bit 368 BIOS machines as well; the entry is the same. 369 370 371 ### 3.11 Next to another system 372 373 To keep a Linux that is already on the disk, Chamesle goes on a partition of its own and the other system's GRUB boots 374 both. The other system is not changed, except for one GRUB entry. Make a backup first; shrinking a file system that is 375 in use is not possible, so it is done from the ISO. 376 377 Say the disk has an EFI partition `nvme0n1p1` and the other system's ext4 root `nvme0n1p2`, 238G with 100G free. 378 Shrink it to 170G and make the file system fit its partition again: 379 380 e2fsck -f /dev/nvme0n1p2 381 resize2fs /dev/nvme0n1p2 170G 382 cfdisk /dev/nvme0n1 383 384 In cfdisk resize `nvme0n1p2` to 171G (a little more than the file system, never less), make `nvme0n1p3` in the free 385 space, write and quit. Then 386 387 resize2fs /dev/nvme0n1p2 388 mkfs.ext4 /dev/nvme0n1p3 389 mount /dev/nvme0n1p3 /mnt 390 391 Leave the EFI partition alone and do not mount anything on `/mnt/boot`: the kernel stays in `/boot` on the ext4 root, 392 where GRUB reads it. Go on with 3.3 to 3.6. `chamesle-boot /mnt` then prints a GRUB entry; boot the other system, put 393 the entry at the end of its `/etc/grub.d/40_custom` and run `grub-mkconfig -o /boot/grub/grub.cfg`. 394 395 To use the same home in both, mount the other root in Chamesle and bind its `/home`, in `/etc/fstab`: 396 397 UUID=OTHER-ROOT-UUID /old ext4 defaults 0 2 398 /old/home /home none bind 0 0 399 400 and make your user with the same name, user number and group number as there (`id` on the other system says them): 401 402 mkdir /old 403 addgroup -g 1000 alice 404 adduser -H -u 1000 -G alice alice 405 406 `-H` makes no home, since the other system's is used: the files, the dotfiles and the settings of the programs are the 407 same in both systems. 408 409 ### 3.12 The glibc Chamesle 410 411 The install is the same, with `-l glibc` for chamesle-bootstrap. ZFS is not there: neither Artix nor Arch carries it, so 412 the root is btrfs or ext4. 413 414 chamesle-disk -t btrfs -y /dev/sda 415 chamesle-bootstrap -l glibc -n box -f "linux-firmware-intel linux-firmware-realtek" /mnt networkmanager networkmanager-openrc 416 417 The repos and keyrings come from `/usr/share/chamesle/glibc` on the live system. `-k` is the kernel (`linux-lts`, or 418 `linux`, `linux-zen`); `-f` the firmware, split by vendor as in Arch (`linux-firmware-amdgpu`, `-nvidia`, 419 `-atheros`, `-broadcom`, `-mediatek`, or `linux-firmware` for all of it). For an NVIDIA card, add `nvidia-open-lts 420 nvidia-utils` (`nvidia-open` with `linux`). Users are made with `useradd`, services have their names from Artix (`NetworkManager`, `iwd`): 421 422 echo root:PASSWORD | arch-chroot /mnt chpasswd 423 arch-chroot /mnt useradd -m -G wheel,video,input,audio alice 424 arch-chroot /mnt passwd alice 425 arch-chroot /mnt rc-update del dhcpcd default 426 arch-chroot /mnt rc-update add NetworkManager default 427 chamesle-boot /mnt 428 429 chamesle-boot sees the glibc system and writes the entries for mkinitcpio's `initramfs-linux-lts.img`. 430 The base keeps the name Chamesle where Artix's packages would put theirs: os-release, the release files, GRUB's 431 menu and the line OpenRC boots with (`/usr/lib/chamesle/brand`, run again by a hook when those packages come). 432 433 434 ## 4. mag 435 436 mag is the package manager. It installs binary packages from the repositories in `/etc/mag/repos`, checks every index 437 and every package against `/etc/mag/keys`, and keeps what it installed in `/var/lib/mag`. It is one C file and runs 438 nothing but the download command, and bash when it builds from a source tree (4.6, 4.7). 439 440 ### 4.1 The commands 441 442 mag update get the index of every repo 443 mag install PKG... install, with what they need 444 mag build PKG... build them from a source tree: CRUX, Void or Exherbo (4.6, 4.7) 445 mag remove PKG... take packages off 446 mag upgrade install what the repos have a newer version of 447 mag autoremove remove what was only a dependency and is not needed now 448 mag list what is installed 449 mag info PKG version, size, description, and whether it is installed 450 mag search WORD names and descriptions 451 mag files PKG the files a package put on the system 452 mag owns PATH which package a file came from 453 mag deps PKG what it needs; rdeps PKG for what needs it 454 mag fetch PKG... only download them 455 456 Before it installs or removes anything it lists the packages, where they come from and their sizes, and asks. 457 `-n` says what would happen and does nothing, `-f` goes on when files clash or something still needs a package. `-y` 458 or `MAG_YES=1` answers yes, for scripts. 459 `MAG_ROOT=/mnt mag ...` works on another root, which is what chamesle-bootstrap does. 460 461 ### 4.2 Installing and removing 462 463 mag install vim 464 mag -n install xorg-server what would come with it 465 mag remove vim 466 467 Before it unpacks anything, mag checks each file against what other packages own and stops if two packages want the same 468 file. A file under `/etc` that you changed stays, and the new one is written next to it as `NAME.new`. Packages carry 469 scripts that run after they are installed, and triggers that run when a directory they watch changes, like the one 470 that makes the initramfs when a kernel is installed. 471 472 A name can also be what a package provides: `mag install cmd:htop` installs the package that has the command. 473 474 ### 4.3 Where it keeps things 475 476 | what | where | 477 |------|-------| 478 | the repositories | `/etc/mag/repos`, one URL a line | 479 | the keys | `/etc/mag/keys` | 480 | the architecture | `/etc/mag/arch` | 481 | installed packages | `/var/lib/mag/NAME/`: `version`, `files`, `deps`, `explicit` and the scripts | 482 | indexes and downloads | `/var/cache/mag` | 483 484 ### 4.4 Repositories 485 486 https://chamesle.org/repo 487 https://dl-cdn.alpinelinux.org/alpine/edge/main 488 https://dl-cdn.alpinelinux.org/alpine/edge/community 489 490 Each line is the URL above the directory of the architecture: mag adds `/x86_64/APKINDEX.tar.gz`. A repository you 491 add needs its key in `/etc/mag/keys`. `mag update` after any change. 492 493 ### 4.5 Making a package 494 495 `tools/mkapk` packs a directory, signs it and leaves its index entry; `tools/mkrepo` signs the index of a directory of 496 them: 497 498 mkapk -k KEY -n hello -v 1.0 -a x86_64 -d "says hello" -D "musl" -o repo/x86_64 ./root 499 mkrepo repo/x86_64 KEY 500 501 Put the public half of KEY in `/etc/mag/keys` and the repo's URL in `/etc/mag/repos`. `tools/mkpkgs` is how Chamesle's 502 own repo is made. 503 504 ### 4.6 CRUX ports 505 506 mag also builds from CRUX's port trees. A line that starts with `crux` is a tree of ports, and its key goes next to the 507 others: 508 509 echo 'crux https://crux.nu/ports/crux-3.8/opt' >> /etc/mag/repos 510 curl -o /etc/mag/keys/opt.pub https://crux.nu/ports/crux-3.8/core/ports/opt.pub 511 mag update 512 mag build foo 513 514 `mag update` gets only the ports that changed, as httpup does, into `/var/cache/mag`. Every port's `.signature` is 515 checked with the key, then its sources against the signature, and its `build()` runs with bash. `core`, `xorg` and 516 `contrib` work the same way, with `core.pub`, `xorg.pub` and `contrib.pub`. 517 518 A package the binary repos have wins over a port of the same name: `mag install` takes a port only when nothing has it 519 built, `mag build` always takes the port. A port brings build-base, pkgconf and bash with it, and the `-dev` package of 520 every dependency that comes built. The flags go in `/etc/mag/build.conf`, otherwise it is `-O2 -pipe` and one job per 521 core: 522 523 CFLAGS="-O2 -pipe -march=native" 524 MAKEFLAGS="-j4" 525 526 What a port installs is a package like any other: `mag files`, `mag remove` and `mag upgrade` work on it. 527 528 ### 4.7 Void and Exherbo 529 530 mag builds Void's templates and Exherbo's exheres too, from their git trees: 531 532 echo 'void https://github.com/void-linux/void-packages' >> /etc/mag/repos 533 echo 'exherbo https://gitlab.exherbo.org/exherbo/arbor' >> /etc/mag/repos 534 mag update 535 mag build tmux 536 537 `mag update` gets the whole tree as one tarball, about 9 MB for Void and 2 MB for arbor, and indexes it. Neither tree 538 is signed: what you get is what GitHub or Exherbo's GitLab sent over https. A Void template has the sha256 of each of 539 its sources, and mag checks them. An exheres has none, so its sources are as good as the connection they came over. 540 541 A Void template runs with the helpers in the tree's `common/`, the way xbps-src runs it: the build style 542 (`gnu-configure`, `cmake`, `meson` and the others), `vinstall`, `vmove` and the rest, and Void's patches. What Void 543 splits into subpackages stays in one package here: `mag build libzstd` builds zstd. A `-devel` it needs is the `-dev` 544 of the binary repos. 545 546 An exheres runs on a small exheres-0 of mag's own, with the exlibs of the tree. Options are what Exherbo's profile turns 547 on, without systemd and pam. Exherbo puts programs in `/usr/x86_64-...-musl/bin`; mag builds them there and moves them 548 to `/usr` afterwards. Arbor is Exherbo's main tree, about 1000 packages; the others are on the same GitLab and work the 549 same way. 550 551 When two trees have a package, `mag build` takes the newer version. A package the binary repos split differently, 552 like xz with its `xz-libs`, clashes with what is installed, and mag stops; `-f` writes over it. 553 554 ### 4.8 pacman repos and the AUR 555 556 The glibc Chamesle (1.3) runs on pacman repos, which mag reads natively. Its `/etc/mag/repos`: 557 558 https://chamesle.org/repo/glibc 559 pacman https://mirrors.dotsrc.org/artix-linux/repos/system/os 560 pacman https://mirrors.dotsrc.org/artix-linux/repos/world/os 561 pacman https://mirrors.dotsrc.org/artix-linux/repos/galaxy/os 562 pacman https://mirrors.dotsrc.org/artix-linux/repos/lib32/os 563 pacman https://geo.mirror.pkgbuild.com/extra/os 564 pacman https://geo.mirror.pkgbuild.com/multilib/os 565 aur https://aur.archlinux.org 566 567 A `pacman` line is the URL above the architecture's directory; the database is named after the last part before `os` 568 (`system.db`). As in pacman, a package that two repos have comes from the first one, so Artix's OpenRC builds win over 569 Arch's systemd ones. Any other mirror of the same repos works the same. 570 571 Packages are checked against their sha256 in the database and their OpenPGP signature, with the keyrings of 572 `artix-keyring` and `archlinux-keyring` in `/usr/share/pacman/keyrings` (RSA and ed25519, without the revoked keys), 573 and any `*.gpg` in `/etc/mag/keys`. A package's `.INSTALL` runs as its scripts, and after every run mag runs the hooks 574 in `/usr/share/libalpm/hooks` and `/etc/pacman.d/hooks`, the way pacman does: they make the initramfs, the system 575 users, the linker cache and the other caches. mag decompresses zstd itself. 576 577 The `aur` line makes the AUR one more repo. `mag update` gets the metadata of every AUR package (15 MB), and 578 `mag install` builds what is not in the binary repos: 579 580 mag install spotify 581 582 mag installs `base-devel`, `git` and what the PKGBUILD needs to build, gets the snapshot into 583 `/var/cache/mag/aur/NAME`, and runs makepkg there as nobody; the package it makes is installed like any other. Keys 584 the PKGBUILD lists in `validpgpkeys` are fetched from keyserver.ubuntu.com for the build. A PKGBUILD is written by 585 whoever uploaded it and nobody else read it: look at it first (`/var/cache/mag/aur/NAME/PKGBUILD` stays after the build) 586 if you do not trust the package. 587 588 589 ## 5. rifle 590 591 ### 5.1 What it is 592 593 rifle is the coreutils of Chamesle on x86_64 in one C file, `rifle.c`, on `c.h`, a one-file libc. It has no GNU code in it and no 594 libc under it. It sorts and compares by bytes, always; there are no locales. 595 596 There is one program. `cat`, `ls`, `cp` and the other commands are links to it, and it runs whichever name it was 597 called by. You type `cat`, not `rifle cat`. 598 599 ### 5.2 The tools 600 601 [ arch base32 base64 basename cat chgrp chmod chown chroot cksum comm cp cut date dd df dirname du echo env 602 expand expr factor false fold groups head hostid hostname id install join link ln logname ls md5sum mkdir 603 mkfifo mknod mktemp mv nice nl nohup nproc od paste printenv printf pwd readlink realpath rm rmdir seq 604 sha1sum sha224sum sha256sum sha384sum sha512sum shuf sleep sort split stat sum sync tac tail tee test 605 timeout touch tr true truncate tsort tty uname unexpand uniq unlink wc whoami yes 606 607 By what they do: 608 609 | group | tools | 610 |-------|-------| 611 | files and directories | `cp mv rm ln link unlink mkdir rmdir mkfifo mknod mktemp touch install truncate dd sync` | 612 | permissions and owners | `chmod chown chgrp` | 613 | looking at files | `ls stat du df cat tac head tail od nl wc cksum sum` | 614 | text | `cut paste join comm sort uniq tr fold expand unexpand split shuf tsort tee` | 615 | checksums and encodings | `md5sum sha1sum sha224sum sha256sum sha384sum sha512sum base32 base64` | 616 | names and paths | `basename dirname pwd readlink realpath` | 617 | scripts and processes | `echo printf printenv env test [ expr seq true false yes sleep nice nohup timeout chroot` | 618 | system and users | `arch uname hostname hostid id groups whoami logname date nproc tty` | 619 | numbers | `factor` (up to 64 bits) | 620 621 Not there yet: `stty`, `who` and friends, `fmt`, `pr`, `csplit`, `numfmt`, `shred`, `stdbuf`, `ptx`, `pathchk`, 622 `dircolors`. 623 624 ### 5.3 Building 625 626 The `rifle` package has it built. From the sources: 627 628 cd $HOME/src/rifle 629 ./build.sh 630 631 builds `rifle` with clang and lld (`CC` overrides `cc`) and makes the links in `bin/`. To put the links anywhere: 632 633 rifle --install /usr/bin 634 rifle --list the names it knows 635 636 ### 5.4 Tests 637 638 tests/run.sh all the cases 639 tests/run.sh sort the cases that have `sort` in them 640 641 Each case in `tests/cases` runs once under GNU coreutils and once under rifle, and what they print and how they exit 642 are compared. The machine that runs the tests therefore has GNU coreutils for the comparison; the installed system does 643 not. `./build.sh` has to have run first. A case that starts with `@ro` runs with the whole file system read-only under 644 `bwrap`, and is skipped when `bwrap` is missing. 645 646 647 ## 6. The base system 648 649 ### 6.1 init 650 651 The init is OpenRC. `/sbin/init` is busybox init, which reads `/etc/inittab`: it runs `openrc sysinit`, `openrc boot` 652 and `openrc default` in turn, then puts a login on `tty1` to `tty6`. OpenRC starts the services of each runlevel, each 653 after what it needs, and stops them in order when the machine goes down. 654 655 A runlevel is a directory in `/etc/runlevels` with links to the services in `/etc/init.d`. A fresh install has: 656 657 | runlevel | services | 658 |---|---| 659 | sysinit | `devfs`, `dmesg`, `udev`, `udev-trigger`, `udev-settle` | 660 | boot | `modules`, `hwclock`, `sysctl`, `hostname`, `bootmisc`, `syslog`, `seedrng`, `swap` | 661 | default | `udev-postmount`, `dhcpcd` | 662 | shutdown | `killprocs`, `mount-ro`, `savecache` | 663 664 `fsck`, `root` and `localmount` come in because the boot ones need them: the file systems are checked, `/` is remounted 665 read-write and `/etc/fstab` is mounted. On ZFS, `zfs-import` and `zfs-mount` are in sysinit too. 666 667 ### 6.2 Services 668 669 Every package with a daemon has its service next to it, in a package called after it with `-openrc` on the end. mag 670 installs that one by itself once OpenRC and the daemon are both there, so `mag install lightdm` brings `lightdm-openrc` 671 too. Then: 672 673 rc-update add lightdm start it at every boot 674 rc-update del dhcpcd not at boot any more 675 rc-service iwd start 676 rc-service iwd stop 677 rc-service dhcpcd restart 678 rc-status what runs, by runlevel 679 rc-update what starts at boot, and in which runlevel 680 681 `rc-update add` puts a service in the default runlevel unless you name another. `service NAME start` works too. The 682 service files are in `/etc/init.d` and their settings in `/etc/conf.d/NAME`. `openrc-run(8)` has the rest. 683 684 Chamesle before base r20 ran dinit, and before r18 Winchester. The upgrade to r20 moves you over by itself: what was 685 enabled there (`/etc/dinit.d/boot.d`, or `boot-services` of `/etc/init.conf`) is added to the default runlevel. dinit 686 is still process 1 until the next boot, so reboot that once with `dinit-reboot`. 687 688 ### 6.3 Shutting down 689 690 `reboot`, `halt` and `poweroff` ask init to stop. `openrc shutdown` stops the services, the ones others need last, 691 sends `TERM` and then `KILL` to what is left, turns swap off and remounts the file systems read-only. 692 693 ### 6.4 The files in /etc 694 695 | file | what it holds | 696 |------|---------------| 697 | `passwd`, `shadow`, `group` | accounts, password hashes, groups | 698 | `shells` | the login shells; `/bin/mksh` is one | 699 | `hostname` | the host name | 700 | `init.d/`, `runlevels/` | the services, and the ones started at boot (6.2) | 701 | `modules` | kernel modules loaded at boot, one a line | 702 | `fstab` | the file systems (3.5) | 703 | `profile` | `PATH`, `PAGER`, `umask 022`, and `/etc/profile.d/*.sh` | 704 | `os-release` | `NAME=Chamesle`, `ID=chamesle` | 705 | `mag/` | the repos, the keys and the architecture (4.3) | 706 | `skel/` | the files new homes start from | 707 708 The login shell is mksh and `/etc/profile` is read by login shells. For a prompt and aliases make `~/.mkshrc` and set 709 `ENV=$HOME/.mkshrc` in `/etc/profile`. 710 711 ### 6.5 Users 712 713 adduser alice 714 adduser alice wheel 715 adduser alice video 716 adduser alice input 717 718 `adduser` makes the account, the group and the home, and asks for the password; `passwd alice` changes it. 719 `deluser alice` takes the account away. 720 721 `wheel` may use `doas`, which is in the base with `permit persist :wheel` in `/etc/doas.d/wheel.conf`. `video` opens 722 `/dev/dri`, the graphics, and `input` the keyboard and mouse under `/dev/input`. There is no logind to hand them out, so 723 whoever runs X or a Wayland compositor needs both, or Xorg stops with `open /dev/dri/card0: Permission denied` and 724 `no screens found`. Groups count from the next login. 725 726 ### 6.6 udev and modules 727 728 eudev is the udev. `udevd` gives devices their nodes in `/dev` and loads the modules the hardware needs. 729 730 kmod provides `modprobe`, `insmod`, `rmmod`, `lsmod`, `modinfo` and `depmod`. A kernel's modules are in 731 `/lib/modules/VERSION`. To load one by hand: `modprobe name`. To load one at every boot, put its name on a line of `/etc/modules`. The base loads the input and network drivers of `/usr/lib/modules-load.d/chamesle.conf` too. To keep one from loading, put `blacklist name` in a file in `/etc/modprobe.d/`. 732 733 ### 6.7 Networking 734 735 `dhcpcd` is the DHCP client and is in the base set. It is the `dhcpcd` service, enabled by default, and takes 736 every interface, so a cable is up at boot. `ip` lists them: 737 738 ip addr 739 ip link set eth0 up 740 741 A static address: 742 743 ip addr add 192.168.1.10/24 dev eth0 744 ip route add default via 192.168.1.1 745 echo 'nameserver 192.168.1.1' > /etc/resolv.conf 746 747 and `rc-update del dhcpcd`. 748 749 ### 6.8 Wireless 750 751 The card needs its firmware (7.4). Then iwd: 752 753 mag install iwd dbus 754 755 and add it, which starts dbus with it: 756 757 rc-update add iwd 758 rc-service iwd start 759 760 `iwctl` connects, the same as on the ISO (2.3), and remembers 761 the network. dhcpcd gives it an address. 762 763 `wpa_supplicant` works too, for those who know it: `mag install wpa_supplicant`. 764 765 ### 6.9 Mounting and disks 766 767 mount /dev/sdb1 /mnt/usb 768 mount -t vfat -o ro /dev/sdb1 /mnt/usb 769 umount /mnt/usb 770 771 `mount` and `umount` are busybox's; `lsblk`, `blkid`, `sfdisk` and `cfdisk` are packages of their own, `mkfs.ext4` and 772 `fsck.ext4` are e2fsprogs', `mkfs.fat` is dosfstools', `zpool` and `zfs` are `zfs`. 773 774 On a ZFS root, the boot runs `zfs mount -a` right after `mount -a`, which mounts `rpool/home` and `rpool/var`; the root itself was 775 mounted by the initramfs. 776 777 ### 6.10 Kernel settings 778 779 The boot loads every `/etc/sysctl.d/*.conf` and `/etc/sysctl.conf` at boot. The base ships 780 `/etc/sysctl.d/10-chamesle.conf`: kernel addresses and `dmesg` are for root only (`doas dmesg`), a process may 781 `ptrace` only its own children, users get no BPF, links and files in sticky directories like `/tmp` are protected, 782 setuid programs leave no core dumps, and the network takes no redirects or source routes and filters spoofed 783 addresses. To change one, put it in a file of your own that sorts later, `/etc/sysctl.d/90-local.conf`: 784 785 kernel.dmesg_restrict = 0 786 787 `sysctl -a` lists them all, `sysctl -w name=value` changes one until the next boot. 788 789 790 ## 7. The kernel and firmware 791 792 ### 7.1 The kernel package 793 794 Nobody builds a kernel in Chamesle. `linux-lts` is the newest Linux LTS kernel with a generic configuration that runs on 795 most machines, and it installs 796 797 /boot/vmlinuz-lts 798 /boot/config-VERSION 799 /boot/System.map-VERSION 800 /lib/modules/VERSION/ 801 802 `linux-virt` is a smaller one for virtual machines. Give it to chamesle-bootstrap with `-k`, and name its files in 803 `limine.conf` (`vmlinuz-virt`, `initramfs-virt`). 804 805 ### 7.2 Updating 806 807 mag update 808 mag upgrade 809 810 A new `linux-lts` replaces `vmlinuz-lts` and makes `initramfs-lts` again, so `limine.conf` needs no change. Reboot to 811 run it; `uname -r` says what runs. Keep the ISO at hand in case a new kernel does not boot. 812 813 ### 7.3 Modules 814 815 Modules are files in `/lib/modules/VERSION`. `lsmod` shows what is loaded, `modprobe name` loads a module with what 816 it needs, `modinfo name` describes it. udev loads the ones the hardware asks for. Modules belong to one kernel build: 817 after an upgrade of the kernel, reboot before loading any. 818 819 ### 7.4 Firmware 820 821 The firmware is split by vendor, so a machine takes only what it uses: 822 823 | package | for | 824 |---------|-----| 825 | `linux-firmware-intel` | Intel wireless (iwlwifi), Bluetooth and the rest of the intel folder | 826 | `linux-firmware-i915` | Intel graphics | 827 | `linux-firmware-amdgpu`, `linux-firmware-radeon` | AMD graphics | 828 | `linux-firmware-rtlwifi`, `linux-firmware-rtw88`, `linux-firmware-rtw89`, `linux-firmware-rtl_nic` | Realtek wireless and ethernet | 829 | `linux-firmware-ath10k`, `linux-firmware-ath11k`, `linux-firmware-ath9k_htc` | Qualcomm Atheros wireless | 830 | `linux-firmware-brcm` | Broadcom wireless | 831 | `linux-firmware` | all of them, over 500 MB | 832 | `linux-firmware-none` | none | 833 834 `mag search linux-firmware` lists them. If `dmesg` says a firmware file failed to load, `mag owns` is no help yet, since 835 it is not installed; the name of the file says the vendor. 836 837 ### 7.5 The initramfs 838 839 The kernel package makes `/boot/initramfs-lts` with `mkinitfs` whenever the kernel is installed or updated. What goes into 840 it is set in `/etc/mkinitfs/mkinitfs.conf`: 841 842 features="ata base cdrom ext4 keymap kms mmc nvme raid scsi usb virtio" 843 844 For a root on ZFS add `zfs` to the list, install `zfs` and `zfs-lts`, and make it again: 845 846 mag install zfs zfs-lts 847 mkinitfs $(ls /lib/modules) 848 849 The initramfs reads `root=`, `rootfstype=` and `modules=` from the command line, mounts the root and starts `/sbin/init`. 850 If it cannot, it says why and gives a shell. 851 852 The live ISO has its own initramfs, made by `iso/mkinitramfs`, which mounts the squashfs (chapter 8). 853 854 855 ## 8. The live ISO 856 857 ### 8.1 What it is 858 859 The ISO is a live system to work from. It boots on BIOS and UEFI machines with limine, from a disc or a stick, logs in as 860 root on every tty and has 861 862 * mag, the keys and the repos, and `chamesle-bootstrap`, `chamesle-disk`, `chamesle-boot`, `arch-chroot` 863 * the disk tools: `cfdisk`, `sfdisk`, `lsblk`, `blkid`, `mkfs.ext4`, `mkfs.fat`, `zpool`, `zfs`, `limine` 864 * the network: `dhcpcd`, `iwd` with `iwctl`, `wpa_supplicant`, `curl` 865 * the Intel wireless firmware, vim, less, and this handbook in `/usr/share/doc/chamesle/handbook.md` 866 867 It is where you do chapter 3. `chamesle.iso` is for x86_64, `chamesle-x86.iso` for 32-bit machines (BIOS only). 868 869 ### 8.2 How it boots 870 871 `iso/init` looks through `/dev/sr*`, `/dev/sd*`, `/dev/nvme*n*p*`, `/dev/vd*` and `/dev/mmcblk*` until it finds one that 872 mounts and has `LiveOS/rootfs.sfs`. It mounts that squashfs read-only, puts a tmpfs overlay over it, moves the medium and 873 the squashfs to `/run/live/medium` and `/run/live/rootfs`, and runs `switch_root` into the result. Whatever you change 874 in the live system is gone at shutdown. 875 876 ### 8.3 Making it 877 878 iso/mkiso -o chamesle.iso 879 iso/mkiso -a x86 -o chamesle-x86.iso 880 881 as root, with mag in PATH, and `xorriso`, `mksquashfs`, `zstd` and `bsdcpio` on the host. mkiso installs 882 `chamesle-base`, the kernel and what `iso/profile/packages` names into `work/rootfs` with mag, copies 883 `iso/profile/overlay` over it, makes the initramfs and the squashfs and puts them on the ISO with limine. 884 885 ### 8.4 Trying it in qemu 886 887 BIOS: 888 889 qemu-system-x86_64 -m 1G -cdrom chamesle.iso -boot d 890 891 UEFI, with the firmware of your qemu (`edk2-x86_64-code.fd`; the path differs between systems): 892 893 qemu-system-x86_64 -m 1G -bios /usr/share/qemu/edk2-x86_64-code.fd -cdrom chamesle.iso 894 895 Add `-enable-kvm` for speed. To go through all of chapter 3 in a virtual machine, give it a disk: 896 897 qemu-img create -f qcow2 disk.qcow2 8G 898 qemu-system-x86_64 -m 1G -enable-kvm -cdrom chamesle.iso -drive file=disk.qcow2 -boot d -nic user 899 900 A machine like an old Pentium 4 with 256 MB: `-cpu pentium3,+sse2 -m 256` and the x86 ISO. 901 902 To write the ISO to a stick: `dd if=chamesle.iso of=/dev/sdX bs=4M conv=fsync`. 903 904 905 ## 9. Maintaining 906 907 ### 9.1 Updating 908 909 mag update 910 mag -n upgrade 911 mag upgrade 912 913 The first gets the indexes, the second says what would change, the third does it. 914 915 ### 9.2 Cleaning up 916 917 mag autoremove dependencies nothing needs any more 918 rm -rf /var/cache/mag/pkg downloaded packages; they are fetched again when needed 919 920 ### 9.3 Configuration files 921 922 A changed file under `/etc` is never written over. When a package brings a new one, it lands next to yours as 923 `NAME.new`. Look for them after an upgrade and merge by hand: 924 925 find /etc -name '*.new' 926 927 ### 9.4 Failures you will see 928 929 | what you see | why, and what to do | 930 |--------------|---------------------| 931 | `no package NAME` | not in any repo; `mag search`, and `mag update` | 932 | a signature or hash that does not match | the download or the index is not what the repo signed; `mag update` and try again, check `/etc/mag/keys` | 933 | `NAME wants FILE, which OTHER has` | two packages want the same file; `-f` writes over it if you are sure | 934 | "root device not found" at boot | the initramfs cannot see the disk or the file system: check `root=` and `modules=` in `limine.conf` | 935 | the machine boots to a limine prompt | `limine.conf` is not found, or its `path:` does not name a file in `/boot`; check with `ls /boot` | 936 | a BIOS machine does not boot | `limine bios-install /dev/sda` was not run, or `limine-bios.sys` is not in `/boot` | 937 | a UEFI machine does not boot | `EFI/BOOT/BOOTX64.EFI` is not on the EFI partition, or the partition is not of type EFI System | 938 | no wireless interface | the firmware is missing (7.4); `dmesg` names the file | 939 | no devices in `/dev` | udev did not start; `rc-service udev status` | 940 941 942 ## 10. X and a window manager 943 944 ### 10.1 What to install 945 946 mag install xorg-server xinit xf86-input-libinput mesa-dri-gallium font-dejavu windowmaker st 947 948 | package | for | 949 |---------|-----| 950 | `xorg-server` | X itself, with the `modesetting` driver, which drives Intel, AMD, NVIDIA and virtual graphics through the kernel | 951 | `xinit` | `startx` | 952 | `xf86-input-libinput` | keyboard, mouse and touchpad | 953 | `mesa-dri-gallium` | OpenGL | 954 | `font-dejavu` | a font; X programs show empty boxes without one | 955 | `windowmaker` | the window manager, and `WPrefs` for its settings | 956 | `st` | a terminal; `xterm` is another | 957 958 Any other window manager or desktop in the repos goes the same way; only the line in `~/.xinitrc` changes. 959 960 ### 10.2 Firmware for the graphics 961 962 The kernel's graphics drivers load firmware for most cards. Install the one for yours and reboot: 963 964 | graphics | firmware | Vulkan | 965 |----------|----------|--------| 966 | Intel, up to 14th generation | `linux-firmware-i915` | `mesa-vulkan-intel` | 967 | Intel Arc, Lunar Lake and newer | `linux-firmware-xe` | `mesa-vulkan-intel` | 968 | AMD | `linux-firmware-amdgpu`, `linux-firmware-radeon` for older cards | `mesa-vulkan-ati` | 969 | NVIDIA | `linux-firmware-nvidia` | `mesa-vulkan-nouveau` | 970 971 NVIDIA's own driver is built for glibc and is not in the repos. The open one, nouveau, runs every card; from the GTX 16 972 and RTX 20 on, the card's own firmware sets the clocks and it is fast, with Vulkan from NVK in 973 `mesa-vulkan-nouveau`. On older NVIDIA cards it stays slow. `lspci` says which graphics a machine has. 974 975 ### 10.3 Groups 976 977 There is no logind to hand the screen and the input devices to whoever logs in. X opens them as the user, so the user 978 needs the `video` and `input` groups (6.5): 979 980 adduser alice video 981 adduser alice input 982 983 Log out and in again after. 984 985 ### 10.4 startx 986 987 `startx` runs `~/.xinitrc`, as the user, from a text login: 988 989 echo 'exec wmaker' > ~/.xinitrc 990 startx 991 992 X runs until `wmaker` ends: Exit in its menu. To start X at every login on tty1, at the end of `~/.profile`: 993 994 [ "$(tty)" = /dev/tty1 ] && exec startx 995 996 Lines in `.xinitrc` before the `exec` run first, which is the place for the keyboard layout and the screen size: 997 998 setxkbmap fr 999 xrandr --output eDP-1 --mode 1920x1080 1000 exec wmaker 1001 1002 `mag install setxkbmap xrandr` for those; `xrandr` alone lists the outputs and their modes. 1003 1004 ### 10.5 Window Maker 1005 1006 The first start makes `~/GNUstep` with Window Maker's settings. The right button on the desktop opens the menu, with 1007 programs, workspaces and Exit. The dock is in the top right corner and the clip, which switches workspaces, in the top 1008 left. Drag a program's icon to the dock to keep it there. `WPrefs` changes the rest: focus, themes, keys. The menu is 1009 `~/GNUstep/Defaults/WMRootMenu`. 1010 1011 ### 10.6 Firefox 1012 1013 mag install firefox 1014 1015 `firefox-esr` is the long-term one. Firefox and many other programs want a D-Bus session; with `dbus` and `dbus-x11` 1016 installed and `dbus` enabled (6.2), start the window manager inside one: 1017 1018 exec dbus-launch --exit-with-session wmaker 1019 1020 ### 10.7 When it fails 1021 1022 X writes `~/.local/share/xorg/Xorg.0.log`; `grep EE` in it shows the errors. 1023 1024 | what you see | why, and what to do | 1025 |--------------|---------------------| 1026 | `open /dev/dri/card0: Permission denied`, then `no screens found` | the user is not in `video` (10.3) | 1027 | `no screens found` with no permission error | no graphics driver came up; check `ls /dev/dri`, and the firmware (10.2) | 1028 | no keyboard or mouse in X | `xf86-input-libinput` is not installed, or the user is not in `input` | 1029 | X starts and ends at once | `~/.xinitrc` is missing, or names a program that is not installed | 1030 | boxes in place of letters | no font, `font-dejavu` | 1031 1032 1033 ## 11. File reference 1034 1035 ### 11.1 On an installed system 1036 1037 | path | what | 1038 |------|------| 1039 | `/sbin/init`, `/etc/inittab` | busybox init, which runs OpenRC | 1040 | `/etc/init.d/`, `/etc/runlevels/` | the services, and the ones started at boot | 1041 | `/usr/lib/chamesle/` | the boot scripts the services run | 1042 | `/etc/hostname`, `/etc/modules` | host name, modules loaded at boot | 1043 | `/etc/profile` | `PATH`, `umask` | 1044 | `/etc/passwd`, `/etc/shadow`, `/etc/group`, `/etc/shells` | accounts, passwords, groups, login shells | 1045 | `/etc/fstab` | file systems | 1046 | `/etc/sysctl.d/` | kernel settings loaded at boot (6.10) | 1047 | `/etc/os-release` | `NAME=Chamesle`, `ID=chamesle` | 1048 | `/etc/mag/` | `repos`, `keys/`, `arch`, `build.conf` | 1049 | `/etc/mkinitfs/mkinitfs.conf` | what goes into the initramfs | 1050 | `/boot/limine.conf` | the boot entries | 1051 | `/boot/limine-bios.sys` | limine's BIOS stage | 1052 | `/boot/EFI/BOOT/BOOTX64.EFI` | limine for UEFI | 1053 | `/boot/vmlinuz-lts`, `initramfs-lts` | the kernel and its initramfs | 1054 | `/lib/modules/V/` | its modules | 1055 | `/lib/firmware/` | firmware | 1056 | `/var/lib/mag/` | what is installed, and its files | 1057 | `/var/cache/mag/` | indexes, downloaded packages and port trees | 1058 | `/usr/share/limine/` | limine's boot files, for installing it | 1059 | `/usr/share/doc/chamesle/handbook.md` | this book | 1060 1061 ### 11.2 In the sources 1062 1063 | path | what | 1064 |------|------| 1065 | `system/tools/chamesle-bootstrap` | puts the base into a root with mag | 1066 | `system/tools/chamesle-boot` | limine.conf and limine for the system in a directory | 1067 | `system/tools/chamesle-disk` | cfdisk, vfat boot partition, ZFS root, mounted on `/mnt` | 1068 | `system/tools/mkapk`, `mkrepo`, `mkpkgs` | packages, signed indexes, Chamesle's own repo | 1069 | `system/files/` | the files in `/etc` and the tools, in `chamesle-base` | 1070 | `system/pkg/chamesle-base/` | its scripts, `repos`, `os-release`, `issue` | 1071 | `system/keys/` | the public keys the repos are signed with | 1072 | `system/iso/mkiso`, `mkinitramfs`, `init` | the live ISO, its initramfs and the first process in it | 1073 | `system/iso/profile/` | `packages`, `modules`, `limine.conf` and the `overlay/` of the live root | 1074 | `system/handbook/handbook.md` | this book | 1075 | `mag/mag.c`, `mag/c.h`, `mag/build.sh` | the package manager | 1076 | `rifle/rifle.c`, `rifle/c.h`, `rifle/build.sh` | the coreutils | 1077 | `rifle/tests/run.sh`, `rifle/tests/cases` | the comparison tests | 1078 1079 ### 11.3 Commands in short 1080 1081 chamesle-bootstrap [-a ARCH] [-n HOSTNAME] [-k KERNEL] [-f FIRMWARE] TARGET [PACKAGE]... 1082 arch-chroot DIR [COMMAND...] 1083 chamesle-disk DISK 1084 chamesle-boot [DIR] 1085 mag [-nfy] update|install|build|remove|upgrade|autoremove|list|info|search|files|owns|deps|rdeps|fetch 1086 rifle --install DIR | --list 1087 limine bios-install DEVICE