system

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

commit 1952f7b1f34e7b8a5777010ec3d3ca163c4b6a1f
parent 08c30866f388e7aaadb3ebb61f541be04d76ccba
Author: torter <koubbamohamedrayan@gmail.com>
Date:   Sun, 22 Nov 2026 23:28:05 +0000

r23: the glibc Chamesle on Artix, Arch and the AUR, repos on edge

chamesle-install asks musl or glibc on x86_64, chamesle-bootstrap -l glibc, chamesle-boot knows mkinitcpio.
every installer menu has a fixed list height, the libc one showed a single row.

Diffstat:
Mhandbook/handbook.md | 88++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Miso/mkinitramfs | 2++
Apkg/chamesle-base-glibc/post-install | 8++++++++
Apkg/chamesle-base-glibc/repos | 8++++++++
Apkg/chamesle-base-glibc/rifle.sh | 2++
Mpkg/chamesle-base/repos | 4++--
Mtools/chamesle-boot | 25+++++++++++++++++++------
Mtools/chamesle-bootstrap | 39+++++++++++++++++++++++++++++----------
Mtools/chamesle-install | 76+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
Mtools/mkpkgs | 50++++++++++++++++++++++++++++++++++++++++++++------
10 files changed, 252 insertions(+), 50 deletions(-)

diff --git a/handbook/handbook.md b/handbook/handbook.md @@ -24,7 +24,7 @@ The parts: | part | what it is | |--------|------------| -| kernel | a prebuilt Linux 6.18 LTS kernel with its modules | +| kernel | a prebuilt Linux LTS kernel with its modules | | musl | the C library | | mag | the package manager, binary packages only, in one C file | | rifle | the coreutils, all in one C file; `cat`, `ls`, `cp` and the rest are links to one program | @@ -46,7 +46,25 @@ mag reads two kinds of repository, both signed: Both are in `/etc/mag/repos`. A package is checked against the keys in `/etc/mag/keys` before anything of it is unpacked. -### 1.3 The layout of the system +### 1.3 The glibc Chamesle + +There is a second Chamesle on glibc, for what musl cannot run: NVIDIA's driver, Steam, programs that only come built for +glibc. It is the same idea on other packages. mag, rifle, the tools and OpenRC are the same; the packages are Artix's +and Arch's, about 25,000, and anything else comes from the AUR, built here. `chamesle-install` asks which one you want, +`chamesle-bootstrap -l glibc` makes it by hand (3.12). + +| part | musl Chamesle | glibc Chamesle | +|--------|---------------|----------------| +| kernel | Linux LTS | Linux, latest (`linux-lts` and `linux-zen` are there too) | +| initramfs | mkinitfs | mkinitcpio | +| file systems | ZFS, btrfs, ext4 | btrfs, ext4 | +| login shell | mksh | bash | +| packages | ~28,000 | ~25,000, and the AUR | + +On glibc, coreutils owns `/usr/bin/ls` and the rest, so rifle's links are in `/usr/lib/rifle/bin`, which a login shell +puts first in PATH (`/etc/profile.d/rifle.sh`). + +### 1.4 The layout of the system /bin /sbin /lib /lib holds the musl loader and the firmware /usr/bin /usr/sbin programs, /usr/lib libraries, /usr/share data @@ -59,7 +77,7 @@ Both are in `/etc/mag/repos`. A package is checked against the keys in `/etc/mag /var/cache/mag downloaded indexes and packages /run /tmp tmpfs, made new at every boot -### 1.4 Where the sources are +### 1.5 Where the sources are | directory | what is in it | |-----------|---------------| @@ -271,7 +289,7 @@ writes nothing and prints an entry for the GRUB of the system already on the mac What it does by hand follows; skip to 3.8 if it said nothing went wrong. ls /mnt/boot - System.map-6.18.64-0-lts config-6.18.64-0-lts initramfs-lts vmlinuz-lts + System.map-7.3.5-0-lts config-7.3.5-0-lts initramfs-lts vmlinuz-lts The names stay the same when the kernel is updated, so `limine.conf` is written once. `/mnt/boot/limine.conf`, with the UUID of the root partition: @@ -383,6 +401,28 @@ and make your user with the same name, user number and group number as there (`i `-H` makes no home, since the other system's is used: the files, the dotfiles and the settings of the programs are the same in both systems. +### 3.12 The glibc Chamesle + +The install is the same, with `-l glibc` for chamesle-bootstrap. ZFS is not there: neither Artix nor Arch carries it, so +the root is btrfs or ext4. + + chamesle-disk -t btrfs -y /dev/sda + chamesle-bootstrap -l glibc -n box -f "linux-firmware-intel linux-firmware-realtek" /mnt networkmanager networkmanager-openrc + +The repos and keyrings come from `/usr/share/chamesle/glibc` on the live system. `-k` is the kernel (`linux`, or +`linux-lts`, `linux-zen`); `-f` the firmware, split by vendor as in Arch (`linux-firmware-amdgpu`, `-nvidia`, +`-atheros`, `-broadcom`, `-mediatek`, or `linux-firmware` for all of it). For an NVIDIA card, add `nvidia-open +nvidia-utils`. Users are made with `useradd`, services have their names from Artix (`NetworkManager`, `iwd`): + + echo root:PASSWORD | arch-chroot /mnt chpasswd + arch-chroot /mnt useradd -m -G wheel,video,input,audio alice + arch-chroot /mnt passwd alice + arch-chroot /mnt rc-update del dhcpcd default + arch-chroot /mnt rc-update add NetworkManager default + chamesle-boot /mnt + +chamesle-boot sees the glibc system and writes the entries for mkinitcpio's `initramfs-linux.img`. + ## 4. mag @@ -435,8 +475,8 @@ A name can also be what a package provides: `mag install cmd:htop` installs the ### 4.4 Repositories https://chamesle.org/repo - https://dl-cdn.alpinelinux.org/alpine/v3.24/main - https://dl-cdn.alpinelinux.org/alpine/v3.24/community + https://dl-cdn.alpinelinux.org/alpine/edge/main + https://dl-cdn.alpinelinux.org/alpine/edge/community Each line is the URL above the directory of the architecture: mag adds `/x86_64/APKINDEX.tar.gz`. A repository you add needs its key in `/etc/mag/keys`. `mag update` after any change. @@ -502,6 +542,40 @@ same way. When two trees have a package, `mag build` takes the newer version. A package the binary repos split differently, like xz with its `xz-libs`, clashes with what is installed, and mag stops; `-f` writes over it. +### 4.8 pacman repos and the AUR + +The glibc Chamesle (1.3) runs on pacman repos, which mag reads natively. Its `/etc/mag/repos`: + + https://chamesle.org/repo/glibc + pacman https://mirrors.dotsrc.org/artix-linux/repos/system/os + pacman https://mirrors.dotsrc.org/artix-linux/repos/world/os + pacman https://mirrors.dotsrc.org/artix-linux/repos/galaxy/os + pacman https://mirrors.dotsrc.org/artix-linux/repos/lib32/os + pacman https://geo.mirror.pkgbuild.com/extra/os + pacman https://geo.mirror.pkgbuild.com/multilib/os + aur https://aur.archlinux.org + +A `pacman` line is the URL above the architecture's directory; the database is named after the last part before `os` +(`system.db`). As in pacman, a package that two repos have comes from the first one, so Artix's OpenRC builds win over +Arch's systemd ones. Any other mirror of the same repos works the same. + +Packages are checked against their sha256 in the database and their OpenPGP signature, with the keyrings of +`artix-keyring` and `archlinux-keyring` in `/usr/share/pacman/keyrings` (RSA and ed25519, without the revoked keys), +and any `*.gpg` in `/etc/mag/keys`. A package's `.INSTALL` runs as its scripts, and after every run mag runs the hooks +in `/usr/share/libalpm/hooks` and `/etc/pacman.d/hooks`, the way pacman does: they make the initramfs, the system +users, the linker cache and the other caches. mag decompresses zstd itself. + +The `aur` line makes the AUR one more repo. `mag update` gets the metadata of every AUR package (15 MB), and +`mag install` builds what is not in the binary repos: + + mag install spotify + +mag installs `base-devel`, `git` and what the PKGBUILD needs to build, gets the snapshot into +`/var/cache/mag/aur/NAME`, and runs makepkg there as nobody; the package it makes is installed like any other. Keys +the PKGBUILD lists in `validpgpkeys` are fetched from keyserver.ubuntu.com for the build. A PKGBUILD is written by +whoever uploaded it and nobody else read it: look at it first (`/var/cache/mag/aur/NAME/PKGBUILD` stays after the build) +if you do not trust the package. + ## 5. rifle @@ -708,7 +782,7 @@ addresses. To change one, put it in a file of your own that sorts later, `/etc/s ### 7.1 The kernel package -Nobody builds a kernel in Chamesle. `linux-lts` is a Linux 6.18 LTS kernel with a generic configuration that runs on +Nobody builds a kernel in Chamesle. `linux-lts` is the newest Linux LTS kernel with a generic configuration that runs on most machines, and it installs /boot/vmlinuz-lts diff --git a/iso/mkinitramfs b/iso/mkinitramfs @@ -21,6 +21,8 @@ inroot() { done echo "$f" } +# a readelf that does not run copies no libraries, and an init that cannot mount /proc +"$rd" -h "$(inroot "$root/bin/busybox")" >/dev/null 2>&1 || { echo "mkinitramfs: $rd does not work" >&2; exit 1; } # copy what a binary links against: the musl loader and every NEEDED library found in the root needed() { $rd -d "$1" | sed -n 's/.*(NEEDED).*\[\(.*\)\]/\1/p' | while read -r l; do diff --git a/pkg/chamesle-base-glibc/post-install b/pkg/chamesle-base-glibc/post-install @@ -0,0 +1,8 @@ +#!/bin/sh +cat > /etc/motd <<M +Chamesle. The handbook is /usr/share/doc/chamesle/handbook.md, mag help says how to get more. + +M +grep -q '^permit persist :wheel' /etc/doas.conf 2>/dev/null || echo 'permit persist :wheel' >> /etc/doas.conf +chmod 600 /etc/doas.conf +exit 0 diff --git a/pkg/chamesle-base-glibc/repos b/pkg/chamesle-base-glibc/repos @@ -0,0 +1,8 @@ +https://chamesle.org/repo/glibc +pacman https://mirrors.dotsrc.org/artix-linux/repos/system/os +pacman https://mirrors.dotsrc.org/artix-linux/repos/world/os +pacman https://mirrors.dotsrc.org/artix-linux/repos/galaxy/os +pacman https://mirrors.dotsrc.org/artix-linux/repos/lib32/os +pacman https://geo.mirror.pkgbuild.com/extra/os +pacman https://geo.mirror.pkgbuild.com/multilib/os +aur https://aur.archlinux.org diff --git a/pkg/chamesle-base-glibc/rifle.sh b/pkg/chamesle-base-glibc/rifle.sh @@ -0,0 +1,2 @@ +# rifle is the coreutils of Chamesle: its tools come first, GNU's are behind them +case ":$PATH:" in *:/usr/lib/rifle/bin:*) ;; *) PATH=/usr/lib/rifle/bin:$PATH;; esac diff --git a/pkg/chamesle-base/repos b/pkg/chamesle-base/repos @@ -1,3 +1,3 @@ https://chamesle.org/repo -https://dl-cdn.alpinelinux.org/alpine/v3.24/main -https://dl-cdn.alpinelinux.org/alpine/v3.24/community +https://dl-cdn.alpinelinux.org/alpine/edge/main +https://dl-cdn.alpinelinux.org/alpine/edge/community diff --git a/tools/chamesle-boot b/tools/chamesle-boot @@ -28,12 +28,21 @@ rootdev=$1 rootfs=$2 rootopts=$3 set -- $(mnt "$t/boot") bootdev=$1 bootfs=$2 +# the glibc Chamesle is Artix underneath: mkinitcpio makes initramfs-linux.img, and grub is one package +glibc= +[ -e "$t/usr/lib/libc.so.6" ] && glibc=1 kernels= for k in "$t"/boot/vmlinuz-*; do [ -e "$k" ] && kernels="$kernels ${k##*/vmlinuz-}"; done -[ -n "$kernels" ] || die "no kernel in $t/boot, install linux-lts first" +[ -n "$kernels" ] || die "no kernel in $t/boot, install a kernel first (linux-lts, or linux on glibc)" +img() { [ -e "$t/boot/initramfs-$1.img" ] && echo "initramfs-$1.img" || echo "initramfs-$1"; } # feature NAME PACKAGE...: puts NAME in the initramfs, with the packages it needs feature() { + if [ -n "$glibc" ]; then + shift + arch-chroot "$t" mag install "$@" || die "mag install $* failed" + return + fi conf=$t/etc/mkinitfs/mkinitfs.conf grep -qE "^features=\"([^\"]* )?$1( |\")" "$conf" && return echo "adding $1 to the initramfs" @@ -44,13 +53,16 @@ feature() { for m in "$t"/lib/modules/*; do arch-chroot "$t" mkinitfs "${m##*/}" || die "mkinitfs failed"; done } -if [ "$rootfs" = zfs ]; then +if [ "$rootfs" = zfs ] && [ -n "$glibc" ]; then + die "the glibc Chamesle has no ZFS: neither Artix nor Arch carries it" +elif [ "$rootfs" = zfs ]; then cmdline="root=ZFS=$rootdev rootfstype=zfs" feature zfs zfs zfs-openrc $(for k in $kernels; do echo zfs-$k; done) for s in zfs-import zfs-mount; do [ -e "$t/etc/runlevels/sysinit/$s" ] || ln -s /etc/init.d/$s "$t/etc/runlevels/sysinit/$s"; done else uuid=$(blkid -s UUID -o value "$rootdev") || die "no UUID for $rootdev" cmdline="root=UUID=$uuid modules=sd-mod,usb-storage,nvme,$rootfs rootfstype=$rootfs" + [ -n "$glibc" ] && cmdline="root=UUID=$uuid rw rootfstype=$rootfs" if [ "$rootfs" = btrfs ]; then sub=$(echo "$rootopts" | tr , '\n' | sed -n 's|^subvol=/*||p') [ -n "$sub" ] && cmdline="$cmdline rootflags=subvol=$sub" @@ -70,7 +82,7 @@ if [ "$bootfs" != vfat ]; then menuentry 'Chamesle ($k)' { search --no-floppy --fs-uuid --set=root $(blkid -s UUID -o value "$where") linux $p/vmlinuz-$k $cmdline quiet - initrd $p/initramfs-$k + initrd $p/$(img $k) } G done @@ -83,7 +95,8 @@ if [ "$(lsblk -dno PTTYPE "$disk")" = gpt ] && ! lsblk -no PARTTYPE "$disk" | gr if [ $loader = grub ]; then case $(cat "$t/etc/mag/arch" 2>/dev/null) in x86) efi=i386-efi;; *) efi=x86_64-efi;; esac - arch-chroot "$t" mag install grub grub-efi ${bios:+grub-bios} >/dev/null || die "mag install grub failed" + if [ -n "$glibc" ]; then arch-chroot "$t" mag install grub >/dev/null || die "mag install grub failed" + else arch-chroot "$t" mag install grub grub-efi ${bios:+grub-bios} >/dev/null || die "mag install grub failed"; fi arch-chroot "$t" grub-install --target=$efi --efi-directory=/boot --boot-directory=/boot --removable --no-nvram >/dev/null || die "grub-install for UEFI failed" echo "UEFI: GRUB in EFI/BOOT on $bootdev" if [ -n "$bios" ]; then @@ -98,7 +111,7 @@ if [ $loader = grub ]; then echo "set timeout=3" for k in $kernels; do printf "\nmenuentry 'Chamesle (%s)' {\n\tsearch --no-floppy --fs-uuid --set=root %s\n" "$k" "$(blkid -s UUID -o value "$bootdev")" - printf '\tlinux /vmlinuz-%s %s quiet\n\tinitrd /initramfs-%s\n}\n' "$k" "$cmdline" "$k" + printf '\tlinux /vmlinuz-%s %s quiet\n\tinitrd /%s\n}\n' "$k" "$cmdline" "$(img $k)" done } > "$c" cat "$c" @@ -113,7 +126,7 @@ c=$t/boot/limine.conf echo "timeout: 3" for k in $kernels; do printf '\n/Chamesle (%s)\n protocol: linux\n path: boot():/vmlinuz-%s\n' "$k" "$k" - printf ' module_path: boot():/initramfs-%s\n cmdline: %s quiet\n' "$k" "$cmdline" + printf ' module_path: boot():/%s\n cmdline: %s quiet\n' "$(img $k)" "$cmdline" done } > "$c" cat "$c" diff --git a/tools/chamesle-bootstrap b/tools/chamesle-bootstrap @@ -1,19 +1,23 @@ #!/bin/sh # chamesle-bootstrap TARGET [PACKAGE]...: puts the Chamesle base into TARGET with mag, like debootstrap does for Debian. # the repos and the keys are this system's, from /etc/mag. the base is chamesle-base, a kernel and what they need. +# -l glibc makes the glibc Chamesle instead, on Artix and Arch packages and the AUR, from /usr/share/chamesle/glibc. # chamesle-bootstrap /mnt # chamesle-bootstrap -a x86 -n box /mnt vim +# chamesle-bootstrap -l glibc -f "linux-firmware-intel linux-firmware-realtek" /mnt set -e usage() { - echo "usage: chamesle-bootstrap [-a ARCH] [-n HOSTNAME] [-k KERNEL] [-f FIRMWARE] TARGET [PACKAGE]..." >&2 + echo "usage: chamesle-bootstrap [-l musl|glibc] [-a ARCH] [-n HOSTNAME] [-k KERNEL] [-f FIRMWARE] TARGET [PACKAGE]..." >&2 + echo " -l musl (default) or glibc" >&2 echo " -a x86_64, x86 and so on (default: this machine's)" >&2 echo " -n host name of the new system (default chamesle)" >&2 - echo " -k the kernel package (default linux-lts), -f its firmware (default linux-firmware-none)" >&2 + echo " -k the kernel package (default linux-lts, linux on glibc), -f its firmware (default linux-firmware-none, none on glibc)" >&2 exit 2 } -arch= name=chamesle kernel=linux-lts firmware=linux-firmware-none -while getopts a:n:k:f: o; do +arch= name=chamesle kernel= firmware= libc=musl +while getopts l:a:n:k:f: o; do case $o in + l) libc=$OPTARG;; a) arch=$OPTARG;; n) name=$OPTARG;; k) kernel=$OPTARG;; @@ -27,18 +31,33 @@ target=$1 shift [ "$(id -u)" = 0 ] || { echo "chamesle-bootstrap: run it as root" >&2; exit 1; } command -v mag >/dev/null || { echo "chamesle-bootstrap: mag is not in PATH" >&2; exit 1; } -[ -f /etc/mag/repos ] && [ -d /etc/mag/keys ] || { echo "chamesle-bootstrap: /etc/mag/repos and /etc/mag/keys are needed" >&2; exit 1; } +case $libc in +musl) conf=/etc/mag;; +glibc) conf=/usr/share/chamesle/glibc; arch=x86_64;; +*) usage;; +esac +[ -f $conf/repos ] && [ -d $conf/keys ] || { echo "chamesle-bootstrap: $conf/repos and $conf/keys are needed" >&2; exit 1; } mkdir -p "$target/etc/mag" "$target/dev" "$target/proc" "$target/sys" "$target/run" "$target/tmp" "$target/boot" chmod 1777 "$target/tmp" -cp /etc/mag/repos "$target/etc/mag/repos" -cp -R /etc/mag/keys "$target/etc/mag/" +cp $conf/repos "$target/etc/mag/repos" +cp -R $conf/keys "$target/etc/mag/" [ -n "$arch" ] && echo "$arch" > "$target/etc/mag/arch" export MAG_ROOT=$target mag update -# the kernel wants some firmware; the vendor packages do not count as that, so -none goes with them -case $firmware in linux-firmware|linux-firmware-none) ;; *) firmware="linux-firmware-none $firmware";; esac -mag install chamesle-base $firmware $kernel "$@" +if [ $libc = glibc ]; then + # pacman's hooks (the initramfs, the users, tmpfiles) want /proc, /sys and /dev in there, as pacstrap gives them + for m in proc sys dev run; do mount --rbind /$m "$target/$m" && mount --make-rslave "$target/$m"; done + trap 'for m in run dev sys proc; do umount -R "$target/$m" 2>/dev/null; done' EXIT + mag install chamesle-base ${kernel:-linux} $firmware "$@" + rm -f "$target"/etc/mag/keys/*.gpg + # Artix's localmount would mount a second /sys over the cgroups: proc and sys are its services' to mount + [ -f "$target/etc/fstab" ] && sed -i '/^proc[[:space:]]/d; /^sysfs[[:space:]]/d' "$target/etc/fstab" +else + # the kernel wants some firmware; the vendor packages do not count as that, so -none goes with them + case ${firmware:=linux-firmware-none} in linux-firmware|linux-firmware-none) ;; *) firmware="linux-firmware-none $firmware";; esac + mag install chamesle-base $firmware ${kernel:-linux-lts} "$@" +fi echo "$name" > "$target/etc/hostname" [ -e "$target/etc/resolv.conf" ] || cp /etc/resolv.conf "$target/etc/" 2>/dev/null || : echo diff --git a/tools/chamesle-install b/tools/chamesle-install @@ -9,9 +9,10 @@ d() { dialog --stdout --backtitle "$T installer" "$@"; } msg() { d --msgbox "$1" 0 0; } log=/var/log/chamesle-install.log -online() { curl -fsS -m 8 -o /dev/null https://chamesle.org/repo/x86_64/APKINDEX.tar.gz; } +# three tries: right after boot the first lookup can be slow +online() { for i in 1 2 3; do curl -fsS -m 8 -o /dev/null https://chamesle.org/repo/x86_64/APKINDEX.tar.gz 2>/dev/null && return; sleep 2; done; return 1; } while ! online; do - c=$(d --menu "There is no network. A cable just works; for wifi, connect with iwctl:\n station wlan0 scan\n station wlan0 get-networks\n station wlan0 connect NAME" 0 0 0 \ + c=$(d --menu "There is no network. A cable just works; for wifi, connect with iwctl:\n station wlan0 scan\n station wlan0 get-networks\n station wlan0 connect NAME" 0 0 8 \ wifi "connect in iwctl, then come back" retry "try again" quit "leave the installer") || die "left" case $c in wifi) clear; iwctl;; @@ -28,21 +29,46 @@ for b in /sys/block/*; do disks="$disks /dev/$n '$(lsblk -dno SIZE,MODEL "/dev/$n" | tr -cd 'A-Za-z0-9 ._-' | tr -s ' ')'" done [ -n "$disks" ] || die "there is no disk to install on" -disk=$(eval d --menu "'Which disk? Everything on it will be erased.'" 0 0 0 "$disks") || die "left" +disk=$(eval d --menu "'Which disk? Everything on it will be erased.'" 0 0 8 "$disks") || die "left" -fs=$(d --default-item zfs --menu "The file system of the root" 0 0 0 \ - zfs "ZFS: compression, snapshots, checksums (the handbook's default)" \ - btrfs "btrfs: compression, snapshots, subvolumes @ and @home" \ - ext4 "ext4: plain and simple") || die "left" +libc=musl +[ "$(uname -m)" = x86_64 ] && { libc=$(d --menu "Which Chamesle?" 10 70 2 \ + musl "the small one, its own base" \ + glibc "Artix, Arch and the AUR: NVIDIA, Steam") || die "left"; } -loader=$(d --menu "The bootloader" 0 0 0 \ +if [ $libc = glibc ]; then + fs=$(d --menu "The file system of the root" 0 0 8 \ + btrfs "btrfs: compression, snapshots, subvolumes @ and @home" \ + ext4 "ext4: plain and simple") || die "left" +else + fs=$(d --default-item zfs --menu "The file system of the root" 0 0 8 \ + zfs "ZFS: compression, snapshots, checksums (the handbook's default)" \ + btrfs "btrfs: compression, snapshots, subvolumes @ and @home" \ + ext4 "ext4: plain and simple") || die "left" +fi + +loader=$(d --menu "The bootloader" 0 0 8 \ limine "limine: small, UEFI and BIOS" \ grub "GRUB: UEFI and BIOS") || die "left" # the firmware the hardware here wants, ticked already has() { for v in /sys/bus/pci/devices/*; do [ "$(cat $v/vendor)" = "$1" ] && case $(cat $v/class) in $2*) return 0;; esac; done; return 1; } on() { has "$@" && echo on || echo off; } -fw=$(d --separate-output --checklist "Firmware for the hardware (ticked: what this machine has)" 0 0 0 \ +if [ $libc = glibc ]; then + intel=off + { has 0x8086 0x0280 || has 0x8086 0x03; } && intel=on + fw=$(d --separate-output --checklist "Firmware for the hardware (ticked: what this machine has)" 0 0 8 \ + linux-firmware-intel "Intel wifi, bluetooth and graphics" $intel \ + linux-firmware-amdgpu "AMD graphics" $(on 0x1002 0x03) \ + linux-firmware-realtek "Realtek wifi and ethernet" $(on 0x10ec 0x02) \ + linux-firmware-mediatek "MediaTek wifi" $(on 0x14c3 0x0280) \ + linux-firmware-atheros "Qualcomm Atheros wifi" $(on 0x168c 0x0280) \ + linux-firmware-broadcom "Broadcom wifi" $(on 0x14e4 0x0280) \ + linux-firmware-nvidia "NVIDIA graphics" $(on 0x10de 0x03)) || die "left" + nvidia= + has 0x10de 0x03 && d --yesno "There is an NVIDIA card. Install NVIDIA's driver (nvidia-open), not nouveau?" 0 0 && nvidia="nvidia-open nvidia-utils" +else +fw=$(d --separate-output --checklist "Firmware for the hardware (ticked: what this machine has)" 0 0 8 \ linux-firmware-intel "Intel wifi and bluetooth" $(on 0x8086 0x0280) \ linux-firmware-i915 "Intel graphics" $(on 0x8086 0x03) \ linux-firmware-amdgpu "AMD graphics" $(on 0x1002 0x03) \ @@ -51,8 +77,9 @@ fw=$(d --separate-output --checklist "Firmware for the hardware (ticked: what th linux-firmware-mediatek "MediaTek wifi" $(on 0x14c3 0x0280) \ linux-firmware-nvidia "NVIDIA graphics (nouveau)" $(on 0x10de 0x03) \ linux-firmware-rtl_nic "Realtek ethernet" $(on 0x10ec 0x0200)) || die "left" +fi -wifi=$(d --menu "Wifi on the installed system" 0 0 0 \ +wifi=$(d --menu "Wifi on the installed system" 0 0 8 \ iwd "iwd, connect with iwctl" \ networkmanager "NetworkManager, connect with nmtui" \ none "cable only") || die "left" @@ -74,15 +101,21 @@ user=$(d --inputbox "Your user name (empty for none)" 0 0) || die "left" user=$(echo "$user" | tr -cd 'a-z0-9_-') [ -n "$user" ] && userpw=$(pw "The password of $user") -d --yesno "Install now?\n\n disk $disk (ERASED)\n file system $fs\n bootloader $loader\n firmware $(echo $fw)\n network $wifi\n host name $host\n user ${user:-none}" 0 0 || die "nothing was changed" +d --yesno "Install now?\n\n disk $disk (ERASED)\n Chamesle $libc\n file system $fs\n bootloader $loader\n firmware $(echo $fw)\n network $wifi\n host name $host\n user ${user:-none}" 0 0 || die "nothing was changed" pkgs= -case $wifi in -iwd) pkgs=iwd;; -networkmanager) pkgs="networkmanager networkmanager-wifi networkmanager-tui";; +case $libc/$wifi in +musl/iwd) pkgs=iwd;; +musl/networkmanager) pkgs="networkmanager networkmanager-wifi networkmanager-tui";; +glibc/iwd) pkgs="iwd iwd-openrc";; +glibc/networkmanager) pkgs="networkmanager networkmanager-openrc";; esac -first=$(echo $fw | cut -d' ' -f1) -rest=$(echo $fw | cut -s -d' ' -f2-) +if [ $libc = glibc ]; then + first= rest="$(echo $fw) $nvidia" +else + first=$(echo $fw | cut -d' ' -f1) + rest=$(echo $fw | cut -s -d' ' -f2-) +fi step() { echo "==> $1" >> $log; d --infobox "$1" 3 60; } : > $log @@ -91,14 +124,17 @@ step() { echo "==> $1" >> $log; d --infobox "$1" 3 60; } chamesle-disk -t $fs -y "$disk" >> $log 2>&1 || exit 1 step "Installing the base (a few minutes)" n=0 - until chamesle-bootstrap -n "$host" ${first:+-f $first} /mnt $rest $pkgs >> $log 2>&1; do + until chamesle-bootstrap -l $libc -n "$host" ${first:+-f $first} /mnt $rest $pkgs >> $log 2>&1; do n=$((n + 1)) [ $n -lt 3 ] || exit 1 sleep 5 done step "Passwords and the user" echo "root:$rootpw" | arch-chroot /mnt chpasswd >> $log 2>&1 || exit 1 - if [ -n "$user" ]; then + if [ -n "$user" ] && [ $libc = glibc ]; then + arch-chroot /mnt useradd -m -G wheel,video,input,audio "$user" >> $log 2>&1 || exit 1 + echo "$user:$userpw" | arch-chroot /mnt chpasswd >> $log 2>&1 || exit 1 + elif [ -n "$user" ]; then arch-chroot /mnt adduser -D "$user" >> $log 2>&1 || exit 1 echo "$user:$userpw" | arch-chroot /mnt chpasswd >> $log 2>&1 || exit 1 for g in wheel video input audio netdev; do arch-chroot /mnt addgroup "$user" $g >> $log 2>&1; done @@ -108,8 +144,10 @@ step() { echo "==> $1" >> $log; d --infobox "$1" 3 60; } iwd) arch-chroot /mnt rc-update add iwd default >> $log 2>&1;; networkmanager) arch-chroot /mnt rc-update del dhcpcd default >> $log 2>&1 - arch-chroot /mnt rc-update add networkmanager default >> $log 2>&1;; + [ $libc = glibc ] && s=NetworkManager || s=networkmanager + arch-chroot /mnt rc-update add $s default >> $log 2>&1;; esac + [ $libc = glibc ] && [ $wifi != networkmanager ] && arch-chroot /mnt rc-update add dhcpcd default >> $log 2>&1 step "The bootloader" chamesle-boot -b $loader /mnt >> $log 2>&1 || exit 1 cp $log /mnt/var/log/ 2>/dev/null diff --git a/tools/mkpkgs b/tools/mkpkgs @@ -2,7 +2,10 @@ # mkpkgs ARCH OUT: Chamesle's own packages for one arch, signed with KEY, and the index of OUT. # KEY=~/.chamesle-keys/chamesle-20261118.rsa MAG=~/src/mag/mag RIFLE=~/src/rifle/rifle mkpkgs x86_64 repo/x86_64 # RIFLE is left out where rifle does not build (it is x86_64 only for now). REL is the -rN of the base's version. -# WMREL makes slate too, with that -rN; DOCKAPPS is what desktop/slate/dockapps built for this arch, for chamesle-dockapps +# WMREL makes slate too, with that -rN; DOCKAPPS is what desktop/slate/dockapps built for this arch, for chamesle-dockapps. +# LIBC=glibc makes the packages of the glibc Chamesle instead, for repo/glibc. KEYRINGS is a directory with artix.gpg and +# archlinux.gpg (from a root where mag installed artix-keyring and archlinux-keyring): the base gets them so its +# chamesle-bootstrap can make a glibc system set -e here=$(cd "$(dirname "$0")/.." && pwd) [ $# = 2 ] && [ -f "$KEY" ] && [ -x "$MAG" ] || { echo "usage: KEY=... MAG=... [RIFLE=...] mkpkgs ARCH OUT" >&2; exit 2; } @@ -16,6 +19,43 @@ mkdir -p "$tmp/mag/usr/bin" install -m755 "$MAG" "$tmp/mag/usr/bin/mag" mkapk -n mag -v "$("$MAG" --version | cut -d' ' -f2)" -d "the package manager" -s "$here/pkg/mag" -t /etc/init.d "$tmp/mag" +# the files every base has: the tools, the handbook, what makes a glibc system +common() { + mkdir -p "$1/etc/mag/keys" "$1/usr/bin" "$1/usr/share/doc/chamesle" "$1/usr/share/chamesle" + cp "$here/keys/"*.pub "$1/etc/mag/keys/" + cp "$here/pkg/chamesle-base/os-release" "$1/etc/" + for t in chamesle-bootstrap chamesle-disk chamesle-boot chamesle-install; do install -m755 "$here/tools/$t" "$1/usr/bin/$t"; done + cp "$here/handbook/handbook.md" "$1/usr/share/doc/chamesle/handbook.md" + cp "$here/files/usr/share/chamesle/logo.txt" "$1/usr/share/chamesle/" + if [ -n "$KEYRINGS" ]; then + mkdir -p "$1/usr/share/chamesle/glibc/keys" + cp "$here/pkg/chamesle-base-glibc/repos" "$1/usr/share/chamesle/glibc/" + cp "$here/keys/"*.pub "$KEYRINGS/artix.gpg" "$KEYRINGS/archlinux.gpg" "$1/usr/share/chamesle/glibc/keys/" + fi +} + +if [ "$LIBC" = glibc ]; then + [ -n "$RIFLE" ] && [ -n "$KEYRINGS" ] || { echo "mkpkgs: LIBC=glibc needs RIFLE and KEYRINGS" >&2; exit 2; } + r=$tmp/rifle + mkdir -p "$r/usr/bin" "$r/usr/lib/rifle/bin" "$r/etc/profile.d" + install -m755 "$RIFLE" "$r/usr/bin/rifle" + for t in $("$RIFLE" --list); do ln -s ../../../bin/rifle "$r/usr/lib/rifle/bin/$t"; done + cp "$here/pkg/chamesle-base-glibc/rifle.sh" "$r/etc/profile.d/" + mkapk -n rifle -v "$("$RIFLE" --version | head -n 1 | cut -d' ' -f2)" -d "the coreutils, in one program" "$r" + b=$tmp/base + common "$b" + cp "$here/pkg/chamesle-base-glibc/repos" "$b/etc/mag/repos" + cp "$here/files/etc/xdg/fastfetch/config.jsonc" "$b/usr/share/chamesle/" 2>/dev/null || : + mkdir -p "$b/etc/sysctl.d" "$b/var/lib/pacman/local" + cp "$here/files/etc/sysctl.d/10-chamesle.conf" "$b/etc/sysctl.d/" + echo 9 > "$b/var/lib/pacman/local/ALPM_DB_VERSION" + mkapk -n chamesle-base -v "$(date +%Y%m%d)-r${REL:-0}" -d "the files in /etc and the tools of Chamesle, on glibc" \ + -D "base openrc elogind-openrc mkinitcpio dhcpcd dhcpcd-openrc opendoas arch-install-scripts artix-keyring archlinux-keyring e2fsprogs dosfstools curl mag rifle" \ + -s "$here/pkg/chamesle-base-glibc" "$b" + "$here/tools/mkrepo" "$out" "$KEY" + exit 0 +fi + mkdir -p "$tmp/init" mkapk -n chamesle-init -v 1 -d "moves a base from before r20 over to OpenRC" -s "$here/pkg/chamesle-init" "$tmp/init" @@ -31,13 +71,11 @@ fi b=$tmp/base cp -R "$here/files" "$b" rm -f "$b/etc/hosts" "$b/etc/services" -mkdir -p "$b/etc/mag/keys" "$b/etc/apk" "$b/usr/bin" "$b/usr/share/doc/chamesle" -cp "$here/keys/"*.pub "$b/etc/mag/keys/" +common "$b" +mkdir -p "$b/etc/apk" ln -s ../mag/keys "$b/etc/apk/keys" cp "$here/pkg/chamesle-base/repos" "$b/etc/mag/repos" -cp "$here/pkg/chamesle-base/os-release" "$here/pkg/chamesle-base/issue" "$b/etc/" -for t in chamesle-bootstrap chamesle-disk chamesle-boot chamesle-install; do install -m755 "$here/tools/$t" "$b/usr/bin/$t"; done -cp "$here/handbook/handbook.md" "$b/usr/share/doc/chamesle/handbook.md" +cp "$here/pkg/chamesle-base/issue" "$b/etc/" mkapk -n chamesle-base -v "$(date +%Y%m%d)-r${REL:-0}" -d "the files in /etc and the tools of Chamesle" \ -D "$deps" -s "$here/pkg/chamesle-base" "$b"