sector-f-linux

Sector F Linux
git clone https://git.sectorflabs.com/sector-f-linux.git
Log | Files | Refs | README | LICENSE

commit ba75ada2942870f1b424c43a300fc8eda6665cac
parent 7bced45c31d8d1725c5f8dd8f29dc08a957d99e1
Author: Divan Visagie <me@divanv.com>
Date:   Fri, 16 Oct 2026 01:16:03 +0200

The Patina desktop in the image, logged into from GDM

desktop/build.sh builds patina-desktop's last commit in an Ubuntu 26.04
container and lays it out under build/desktop: the binaries in /usr/bin,
the session file, the PAM service. The image adds GDM, NetworkManager,
PipeWire, Mesa, fonts and foot; a dev stage adds a test user and trust in
the registry. The VM gets a screen over VNC, and screenshots and keys
through QEMU's monitor.

GDM 50 has no default-session setting and Ubuntu's AccountsService
templates leave it empty, so GDM started GNOME, which isn't there; the
image's templates make it Patina. NetworkManager replaces networkd, with
Ubuntu's netplan-only rule for wired interfaces masked.

Diffstat:
M.dockerignore | 1+
M.gitignore | 3+++
MContainerfile | 51+++++++++++++++++++++++++++++++++++++++++++--------
MREADME.md | 3++-
Adesktop/build.sh | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adesktop/builder.Containerfile | 11+++++++++++
Mdocs/notes.md | 18++++++++----------
Asystem/etc/NetworkManager/conf.d/10-globally-managed-devices.conf | 4++++
Asystem/etc/accountsservice/user-templates/administrator | 10++++++++++
Asystem/etc/accountsservice/user-templates/standard | 10++++++++++
Dsystem/usr/lib/systemd/network/80-wired.network | 8--------
Mvm/README.md | 27++++++++++++++++++++++-----
Mvm/build.sh | 9++++++---
Mvm/common.sh | 3+++
Mvm/vm.sh | 22++++++++++++++++++++--
15 files changed, 198 insertions(+), 37 deletions(-)

diff --git a/.dockerignore b/.dockerignore @@ -3,4 +3,5 @@ # podman, disk images) never goes to the daemon. * !system/ +!build/desktop/ !vm/registries.conf diff --git a/.gitignore b/.gitignore @@ -2,6 +2,9 @@ # logs (vm/README.md). /out/ +# What desktop/build.sh makes: the source it builds, cargo's target, the staging. +/build/ + # Disk images, logs and private keys anywhere else, should one land outside out/. *.raw *.qcow2 diff --git a/Containerfile b/Containerfile @@ -1,14 +1,18 @@ -# Patina OS: the system image. For now just the Ubuntu 26.04 bootc base with a -# current kernel, set up to update from the development registry, to try out -# booting, upgrading and rolling back in a VM (see vm/README.md). Patina's -# desktop comes later. +# Patina OS: the Ubuntu 26.04 bootc base with a current kernel, the Patina +# desktop and what it needs, logged into from GDM. Two images come out of it: +# +# system the real one +# dev the system plus what the test VM needs: a user to log in as, and +# trust in the development registry (vm/README.md) +# +# The desktop is built first by desktop/build.sh into build/desktop/. # apt's database as a fresh Ubuntu has it: the base image empties /var, so # derived images restore it to use apt (as the base's AGENTS.md describes). FROM docker.io/library/ubuntu@sha256:f144425ff09be612d6d9ad965196e9cdc23dae1f42110a8a11a3e9a8198759f7 AS dpkg-state # ubuntu-bootc's minimal 26.04 base, pinned by digest (docs/notes.md). -FROM ghcr.io/ubuntu-bootc/ubuntu-26.04-bootc@sha256:d50ac19557f0b5bc56a980178aa68e3675735ad06b3750b4c9af967901e966f4 +FROM ghcr.io/ubuntu-bootc/ubuntu-26.04-bootc@sha256:d50ac19557f0b5bc56a980178aa68e3675735ad06b3750b4c9af967901e966f4 AS system COPY --from=dpkg-state /var/lib/dpkg /var/lib/dpkg @@ -17,6 +21,11 @@ COPY --from=dpkg-state /var/lib/dpkg /var/lib/dpkg # bootc issue 2174, fixed from 7.0.7). Take the archive's current kernel, keep # only it, and build its initramfs with the base's dracut settings. Kernel hooks # are stubbed by the base, and /boot is emptied: bootc boots from /usr/lib/modules. +# +# Then what the desktop needs: GDM to log in, NetworkManager (patina-wifi), +# PipeWire and WirePlumber (wpctl, for the volume keys), Mesa (EGL, GBM), +# libinput, libseat, xkb's layouts, fonts, and foot as a terminal. The +# libraries are what the binaries link or load (see desktop/build.sh). RUN mkdir -p /var/cache/apt/archives/partial /var/lib/apt/lists/partial /var/log/apt \ /var/tmp /var/roothome && \ apt-get update && \ @@ -27,19 +36,45 @@ RUN mkdir -p /var/cache/apt/archives/partial /var/lib/apt/lists/partial /var/log cp "/boot/vmlinuz-$kver" "/usr/lib/modules/$kver/vmlinuz" && \ dracut --force --kver "$kver" "/usr/lib/modules/$kver/initramfs.img" && \ rm -rf /boot/* && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + gdm3 dbus-user-session polkitd \ + network-manager \ + pipewire pipewire-pulse wireplumber \ + libegl1 libegl-mesa0 libgbm1 libgl1-mesa-dri mesa-vulkan-drivers \ + libwayland-server0 libwayland-client0 libwayland-egl1 \ + libinput10 libseat1 libxkbcommon0 xkb-data libpixman-1-0 libdrm2 \ + fonts-dejavu-core fonts-ubuntu hicolor-icon-theme adwaita-icon-theme \ + xdg-user-dirs foot && \ apt-get clean && \ rm -rf /var && mkdir /var # Files the system adds to the base, as laid out under system/. COPY system/ / -RUN systemctl enable systemd-networkd.service + +# The Patina desktop, and "Patina" as GDM's session. +COPY build/desktop/ / + +RUN systemctl enable gdm.service NetworkManager.service && \ + systemctl set-default graphical.target + +RUN bootc container lint + +# --------------------------------------------------------------------------- + +FROM system AS dev # Trust the development registry: localhost:5000 on the host, which is 10.0.2.2 -# from inside a QEMU VM. Development builds only. +# from inside a QEMU VM. COPY vm/registries.conf /etc/containers/registries.conf.d/50-patina-dev.conf +# A user to log in as at GDM: patina, password patina, allowed sudo. Its home +# is made at boot, since /var starts empty. +RUN useradd -M -d /var/home/patina -s /bin/bash -G sudo patina && \ + echo patina:patina | chpasswd && \ + echo 'd /var/home/patina 0700 patina patina -' > /usr/lib/tmpfiles.d/patina-dev-user.conf + # Which build this is, so an upgrade can be seen to have happened. ARG BUILD_ID=unknown -RUN mkdir -p /usr/lib/patina-os && echo "$BUILD_ID" > /usr/lib/patina-os/build +RUN echo "$BUILD_ID" > /usr/lib/patina-os/build RUN bootc container lint diff --git a/README.md b/README.md @@ -4,7 +4,8 @@ A Linux based operating system image for the Patina desktop: Ubuntu as a bootc i one known-good build, updates by moving to the next one whole, and rolls back if it breaks. The user's data lives on a ZFS pool beside it. -Nothing is built yet; these are notes. See [docs/adr](docs/adr) for decisions and +The image builds and runs in a VM: GDM logs in to the Patina desktop, and the system upgrades +and rolls back ([vm/README.md](vm/README.md)). See [docs/adr](docs/adr) for decisions and [docs/notes.md](docs/notes.md) for the research and open questions behind them. ## Principles diff --git a/desktop/build.sh b/desktop/build.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# Builds the Patina desktop for the image, from patina-desktop's last commit +# (not its working tree, so stray changes don't ship), and lays out what the +# image adds in build/desktop/, as it goes under /: +# +# usr/bin/patina-* the binaries +# usr/share/wayland-sessions/patina.desktop "Patina" at the login screen +# etc/pam.d/patina-lock the lock screen's PAM service +# usr/lib/patina-os/desktop which commit it was built from +# +# PATINA_DESKTOP is the checkout (default: ../patina-desktop beside this one). +set -euo pipefail + +ROOT=$(cd "$(dirname "$0")/.." && pwd) +SRC=${PATINA_DESKTOP:-$ROOT/../patina-desktop} +BUILD="$ROOT/build" +STAGE="$BUILD/desktop" +BUILDER=patina-os-desktop-builder + +say() { printf '==> %s\n' "$*"; } + +[[ -d "$SRC/.git" ]] || { echo "error: no patina-desktop checkout at $SRC" >&2; exit 1; } +commit=$(git -C "$SRC" rev-parse HEAD) +dirty=$(git -C "$SRC" status --porcelain --untracked-files=no) +[[ -z "$dirty" ]] || say "patina-desktop has uncommitted changes; building its last commit, $commit" + +say "the build environment" +docker build -q -f "$ROOT/desktop/builder.Containerfile" -t "$BUILDER" "$ROOT/desktop" >/dev/null + +say "building patina-desktop $(git -C "$SRC" log --oneline -1)" +rm -rf "$BUILD/src" +mkdir -p "$BUILD/src" "$BUILD/target" +git -C "$SRC" archive HEAD | tar -x -C "$BUILD/src" +# Cargo's downloads are kept in a volume, and its target folder in build/, so +# rebuilds are incremental. As the user, so build/ stays theirs. +docker run --rm --user "$(id -u):$(id -g)" \ + -e CARGO_HOME=/cargo -e HOME=/tmp \ + -v patina-os-cargo:/cargo \ + -v "$BUILD/src:/src:ro" -v "$BUILD/target:/target" \ + -w /src "$BUILDER" \ + cargo build --release --locked --workspace --target-dir /target + +say "laying out build/desktop" +rm -rf "$STAGE" +binaries=(patina-bar patina-compositor patina-launcher patina-lock patina-menu + patina-volume patina-wallpaper patina-wifi) +install -d "$STAGE/usr/bin" +for b in "${binaries[@]}"; do + install -m 755 "$BUILD/target/release/$b" "$STAGE/usr/bin/" +done +install -d "$STAGE/usr/share/wayland-sessions" "$STAGE/etc/pam.d" "$STAGE/usr/lib/patina-os" +sed 's|@BINDIR@|/usr/bin|' "$BUILD/src/packaging/linux/patina.desktop" \ + > "$STAGE/usr/share/wayland-sessions/patina.desktop" +install -m 644 "$BUILD/src/packaging/linux/patina-lock.pam" "$STAGE/etc/pam.d/patina-lock" +echo "$commit" > "$STAGE/usr/lib/patina-os/desktop" diff --git a/desktop/builder.Containerfile b/desktop/builder.Containerfile @@ -0,0 +1,11 @@ +# The Patina desktop's build environment: Ubuntu 26.04, as the image is, with +# its own Rust and the libraries patina-desktop builds against (its `make +# deps`). desktop/build.sh runs cargo in it. +FROM docker.io/library/ubuntu@sha256:f144425ff09be612d6d9ad965196e9cdc23dae1f42110a8a11a3e9a8198759f7 + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + ca-certificates git cargo rustc pkg-config \ + libxkbcommon-dev libpixman-1-dev libudev-dev libinput-dev libseat-dev \ + libgbm-dev libegl-dev libdrm-dev libwayland-dev libpam0g-dev && \ + rm -rf /var/lib/apt/lists/* diff --git a/docs/notes.md b/docs/notes.md @@ -91,22 +91,20 @@ Open, roughly in order: ## The image -- A Containerfile `FROM` an Ubuntu bootc base, adding: - - the Patina desktop's binaries, built in an earlier stage from `../patina-desktop` - (`cargo build --release`), into `/usr/bin` rather than `~/.local/bin`; - - its session file (`/usr/share/wayland-sessions/patina.desktop`) and the PAM service for - patina-lock (`/etc/pam.d/patina-lock`), as `make install-session` puts them now; - - a display manager (gdm, or something lighter like greetd), PipeWire and wireplumber - (`wpctl` is the default for the volume keys), NetworkManager (patina-wifi), fonts. +- **Done 2026-10-16**: the Containerfile adds the Patina desktop (built by desktop/build.sh into + `/usr/bin`, with its session file and PAM service), GDM, NetworkManager, PipeWire and + WirePlumber, Mesa, fonts and foot. In the VM, GDM logs in to the Patina session, and the + launcher starts apps. vm/README.md has what it took. +- Open: GDM brings much of GNOME's plumbing; a Patina login screen (as patina-lock replaced + swaylock) could replace it later. - Open: where images are pushed (a registry: ghcr.io, or our own), and signing them. - Open: how a machine is installed: `bootc install to-disk` from the image, or an ISO (bootc-image-builder). ## Questions for Patina itself -- The desktop now assumes binaries beside each other in `~/.local/bin`; in an image they're in - `/usr/bin`. The compositor puts its own folder first on clients' PATH, so this should just - work; check. +- Binaries in `/usr/bin` rather than `~/.local/bin`: works (checked in the VM: the compositor + starts the wallpaper, bar and launcher from there). - Config defaults (`~/.config/patina-*`) stay per user; system-wide defaults could go in `/etc/xdg` or `/usr/share` if we want the image to choose them. diff --git a/system/etc/NetworkManager/conf.d/10-globally-managed-devices.conf b/system/etc/NetworkManager/conf.d/10-globally-managed-devices.conf @@ -0,0 +1,4 @@ +# Ubuntu's NetworkManager leaves wired interfaces to netplan, which this +# system doesn't have; this empty file in /etc masks the package's +# /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf, so +# NetworkManager manages every interface itself. diff --git a/system/etc/accountsservice/user-templates/administrator b/system/etc/accountsservice/user-templates/administrator @@ -0,0 +1,10 @@ +# Every user's session is Patina unless they choose another. Ubuntu's own +# template (/usr/share/accountsservice/user-templates) leaves Session= empty, +# which GDM takes as GNOME; GDM 50 has no setting for a default session. +[Template] +#EnvironmentFiles=/etc/os-release; + +[User] +Session=patina +SessionType=wayland +Icon=${HOME}/.face diff --git a/system/etc/accountsservice/user-templates/standard b/system/etc/accountsservice/user-templates/standard @@ -0,0 +1,10 @@ +# Every user's session is Patina unless they choose another. Ubuntu's own +# template (/usr/share/accountsservice/user-templates) leaves Session= empty, +# which GDM takes as GNOME; GDM 50 has no setting for a default session. +[Template] +#EnvironmentFiles=/etc/os-release; + +[User] +Session=patina +SessionType=wayland +Icon=${HOME}/.face diff --git a/system/usr/lib/systemd/network/80-wired.network b/system/usr/lib/systemd/network/80-wired.network @@ -1,8 +0,0 @@ -# Wired interfaces by DHCP, with systemd-networkd. Enough for the VM and a -# headless machine; the desktop will bring NetworkManager (patina-wifi) instead. -[Match] -Type=ether -Kind=!* - -[Network] -DHCP=yes diff --git a/vm/README.md b/vm/README.md @@ -1,21 +1,26 @@ # The test VM -Builds the image, installs it onto a disk file the way it would go onto a real disk, and boots it +Builds the Patina desktop and the image, installs it onto a disk file the way it would go onto a real disk, and boots it in QEMU, then lets the VM upgrade from a local registry and roll back. Needs Docker, QEMU with KVM, and OVMF (`apt install qemu-system-x86 ovmf`); no root, no podman on the host. ``` -vm/build.sh build the Containerfile, push it to the registry on localhost:5000 +vm/build.sh build the desktop and the image (its dev stage), push it to localhost:5000 vm/disk.sh install the image onto out/disk.raw (and make out/data.qcow2, the SSH key) vm/vm.sh start boot it in the background (serial console in out/serial.log) vm/vm.sh wait wait until SSH answers vm/vm.sh ssh [cmd] a root shell, or a command vm/vm.sh console boot it on this terminal instead (Ctrl-a x quits) +vm/vm.sh view its screen in a VNC viewer (localhost:5901) +vm/vm.sh screenshot its screen, saved to out/screen.png vm/vm.sh log follow the serial console vm/vm.sh stop power it off vm/clean.sh stop it and delete out/ (--all: the registry and the image too) ``` +GDM comes up on the screen; log in as **patina**, password **patina**, and the Patina session +starts (the dev image adds that user; the real image has none). + Trying an update: ``` @@ -28,6 +33,12 @@ vm/vm.sh ssh bootc rollback # the previous one, at the next boot ## How it works +- **The desktop** is built by `desktop/build.sh` from patina-desktop's last commit (beside this + checkout, or `PATINA_DESKTOP`), in an Ubuntu 26.04 container with the archive's Rust, so it + links what the image has. It lands in `build/desktop/` as it goes under `/`, with the session + file and the PAM service; the commit is in `/usr/lib/patina-os/desktop`. +- **The image** has two stages: `system`, the real one, and `dev`, which adds the test user and + trust in the registry. vm/build.sh builds `dev`. - **The registry** (`vm/registry.sh`, started by the others) is Docker's `registry:2` on localhost:5000, which the VM reaches as 10.0.2.2:5000 (QEMU's user network). The image trusts it over plain HTTP (`vm/registries.conf`); that's for development builds only. @@ -38,7 +49,9 @@ vm/vm.sh ssh bootc rollback # the previous one, at the next boot - **After the install**, the boot entry gets `root=UUID=...` (systemd 259 on 26.04 doesn't always find the root by itself) and root's `authorized_keys` goes straight into the installed `/var`. - **The VM** has 4 CPUs, 4 GB, UEFI, the system disk, an empty 10 GB second disk for the ZFS pool - (`vdb`), and SSH on localhost:2222 with the key in `out/id_ed25519`. + (`vdb`), SSH on localhost:2222 with the key in `out/id_ed25519`, a virtio GPU shown over VNC + (Mesa draws in software), a USB tablet and keyboard, and QEMU's monitor on + `out/monitor.sock` (screenshots, and `sendkey` to type into it). ## Found along the way @@ -48,7 +61,11 @@ vm/vm.sh ssh bootc rollback # the previous one, at the next boot - bootc's composefs backend can't install straight from a registry ("Invalid splitstream content type"), only from podman's storage, hence the pull inside the install container. - `--root-ssh-authorized-keys` leaves `/root/.ssh` empty with the composefs backend. -- The minimal base has no network configuration; `system/` adds DHCP on wired interfaces - with systemd-networkd. +- The minimal base has no network configuration; the image adds NetworkManager. +- GDM 50 has no setting for the default session, and Ubuntu's AccountsService templates leave + a new user's session empty, which GDM takes as GNOME (not installed: "Failed to fill + session"). `system/etc/accountsservice/user-templates` makes it Patina. +- Ubuntu's NetworkManager leaves wired interfaces to netplan, which isn't here; an empty + `10-globally-managed-devices.conf` in `/etc` lets it manage them. - Docker here has only the legacy builder (no BuildKit), so the Containerfile uses `COPY --from` rather than `RUN --mount`. diff --git a/vm/build.sh b/vm/build.sh @@ -1,11 +1,14 @@ #!/usr/bin/env bash -# Builds the image from the Containerfile and pushes it to the development -# registry, where a VM's `bootc upgrade` finds it. +# Builds the Patina desktop (desktop/build.sh), then the image's dev stage from +# the Containerfile, and pushes it to the development registry, where a VM's +# `bootc upgrade` finds it. source "$(dirname "$0")/common.sh" +"$ROOT/desktop/build.sh" "$ROOT/vm/registry.sh" build_id=$(date -u +%Y-%m-%dT%H:%M:%SZ) say "building $IMAGE ($build_id)" -docker build -f "$ROOT/Containerfile" --build-arg BUILD_ID="$build_id" -t "$IMAGE" "$ROOT" +docker build -f "$ROOT/Containerfile" --target dev \ + --build-arg BUILD_ID="$build_id" -t "$IMAGE" "$ROOT" say "pushing $IMAGE" docker push -q "$IMAGE" diff --git a/vm/common.sh b/vm/common.sh @@ -19,6 +19,9 @@ DATA_SIZE=10G KEY="$OUT/id_ed25519" SSH_PORT=2222 SERIAL_LOG="$OUT/serial.log" +# The screen, over VNC on localhost:5901, and QEMU's monitor, for screenshots. +VNC_DISPLAY=1 +MONITOR="$OUT/monitor.sock" PIDFILE="$OUT/qemu.pid" OVMF_CODE=/usr/share/OVMF/OVMF_CODE_4M.fd diff --git a/vm/vm.sh b/vm/vm.sh @@ -6,6 +6,8 @@ # vm/vm.sh console boot it in the foreground on this terminal (Ctrl-a x quits) # vm/vm.sh ssh [cmd] a shell (or a command) as root # vm/vm.sh wait wait until SSH answers +# vm/vm.sh view its screen, in a VNC viewer (it's on localhost:5901) +# vm/vm.sh screenshot [file.png] its screen, saved (default out/screen.png) # vm/vm.sh log follow the serial console # vm/vm.sh stop power it off source "$(dirname "$0")/common.sh" @@ -19,7 +21,10 @@ qemu_args() { -drive "if=pflash,format=raw,file=$OVMF_VARS" \ -drive "file=$DISK,format=raw,if=virtio" \ -drive "file=$DATA,format=qcow2,if=virtio" \ - -nic "user,model=virtio-net-pci,hostfwd=tcp:127.0.0.1:$SSH_PORT-:22" + -nic "user,model=virtio-net-pci,hostfwd=tcp:127.0.0.1:$SSH_PORT-:22" \ + -device virtio-vga -vnc "127.0.0.1:$VNC_DISPLAY" \ + -device qemu-xhci -device usb-tablet -device usb-kbd \ + -monitor "unix:$MONITOR,server,nowait" } need_disk() { [[ -f "$DISK" ]] || die "no $DISK; vm/disk.sh first"; } @@ -53,6 +58,19 @@ case "${1:-}" in done die "no SSH after 4 minutes; see $SERIAL_LOG" ;; + view) + vm_running || die "not running" + exec vncviewer "127.0.0.1:$((5900 + VNC_DISPLAY))" + ;; + screenshot) + vm_running || die "not running" + shot=${2:-$OUT/screen.png} + rm -f "$shot" + printf 'screendump %s -f png\n' "$shot" | nc -U -q 1 "$MONITOR" >/dev/null + for _ in $(seq 1 20); do [[ -s "$shot" ]] && break; sleep 0.2; done + [[ -s "$shot" ]] || die "no screenshot" + echo "$shot" + ;; log) exec tail -f "$SERIAL_LOG" ;; @@ -63,7 +81,7 @@ case "${1:-}" in say "stopped" ;; *) - sed -n '2,10p' "$0" | sed 's/^# \{0,1\}//' + sed -n '2,12p' "$0" | sed 's/^# \{0,1\}//' exit 1 ;; esac