From cbd2d400e82f75db02a0f223d93c518821a6638d Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 03:39:10 +0100 Subject: [PATCH] Boot the package-owned desktop init through first-boot registration --- PROFILES.md | 2 + tests/desktop-guest.py | 86 ++++++++++++++++++++++++++++++++++++ tests/userland/desktop.sh | 40 +++++++++++++++++ tests/userland/framebuffer.c | 43 ++++++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 tests/desktop-guest.py create mode 100644 tests/userland/desktop.sh create mode 100644 tests/userland/framebuffer.c diff --git a/PROFILES.md b/PROFILES.md index fc9bd23..974045f 100644 --- a/PROFILES.md +++ b/PROFILES.md @@ -103,3 +103,5 @@ Both targets also passed a fresh signed install of musl, `vinix-accounts`, `vini The next clean x86_64 install resolved 129 signed packages in ten dependency stages. The auditor counted 18,170 owned files and links and 334 target ELFs. BusyBox 1.38.0-5 owned the shell, and `vinix-desktop-init` owned a byte-identical copy of the published x86_64 PID 1. The X11 bitmap font hook populated the index during installation. Of 3,899 matching release observations, 1,608 had their expected owner at the published path, and 1,360 more had documented relocations. The remaining work includes the native GCC and Mesa stacks, vpac and guest checks. See `foundation/desktop-owners-04`, receipt SHA-256 `819fd43ec280e519dbfa41e1628a5822faedf7f5059c03fd4bdf3e8d6bc24e9b`. The x86_64 path fixture booted the published kernel with a 19-package signed root. It loaded Zsh's attribute, line-editor and completion modules, initialized completion, read the linux, alacritty and xterm-256color terminfo entries, found the indexed Misc Fixed bitmap font, and executed the target-prefixed GNU assembler and linker. The serial transcript is in `foundation/relocated-guest-x86-01`, receipt SHA-256 `c6b8615194003d7ee9490682127a0b2d477b35bac8d37282f97ac94e8bb4eeab`. A separate audit of the 129-package root ran the installed musl loader over all 158 dynamic executable paths on the x86_64 build worker. See `foundation/abi-desktop-129-01`, receipt SHA-256 `9b07bc02aa03c6c5a30411ec760865648f39297d6c270cd8f0e973165a37337b`. + +The x86_64 first-boot registration screen ran with a clean, 15-package vpac root and its packaged release PID 1. The test added the five native Vinix programs from the checksum-pinned release initramfs and checked their hashes inside the guest. The guest observed both the graphical session and the registration process, then sampled at least 24 colors from the 1024×768 framebuffer. Reproduce this with `tests/desktop-guest.py`. The worker retains the manifest and serial transcript in `foundation/desktop-registration-x86-01`, receipt SHA-256 `0f0a3bc88bbb2b4921df92510163a43afbaaf8f683b05fe8bf180a62f9888129`. diff --git a/tests/desktop-guest.py b/tests/desktop-guest.py new file mode 100644 index 0000000..836c1e6 --- /dev/null +++ b/tests/desktop-guest.py @@ -0,0 +1,86 @@ +"""Exercise the packaged release PID 1 with the native Vinix first-boot desktop.""" +import argparse +import hashlib +import os +import shutil +import subprocess +import tarfile +from pathlib import Path + + +# Published November 28 release, checked against each architecture's ISO. +INITRAMFS = { + "x86_64": "8be0f76685936c66d40609f62ad7ad5d2b231e6778678618a445e7fe83ce54da", + "aarch64": "a32afaa82a33096256280086bacbc39873e36a2e3ecd81c5504960b9034ec4f9", +} +PROGRAMS = ("usr/bin/vinix-desktop", "usr/sbin/vinix-session", "usr/sbin/vinix-account", + "usr/sbin/vinix-authd", "usr/sbin/vinix-system") + + +def digest(path): + with path.open("rb") as stream: + return hashlib.file_digest(stream, "sha256").hexdigest() + + +def native_overlay(archive, arch, root): + if digest(archive) != INITRAMFS[arch]: + raise ValueError("release initramfs checksum mismatch") + copies = set() + with tarfile.open(archive, "r|gz") as members: + for item in members: + name = item.name.removeprefix("./") + if name not in PROGRAMS: + continue + if not item.isfile() or not item.mode & 0o111: + raise ValueError(f"expected a native executable at {name}") + target = root / name + with members.extractfile(item) as source, target.open("xb") as output: + shutil.copyfileobj(source, output) + target.chmod(0o755) + copies.add(name) + if copies != set(PROGRAMS): + raise ValueError(f"missing release programs: {set(PROGRAMS) - copies}") + manifest = root / "desktop-programs.sha256" + with manifest.open("x") as output: + for name in ("sbin/init", *PROGRAMS): + output.write(f"{digest(root / name)} /{name}\n") + + +def run(args): + work = args.work + work.mkdir() + client = work / "client" + tests = Path(__file__).resolve().parent + + def log(name, argv, **kwargs): + with (work / (name + ".log")).open("x") as output: + subprocess.run(argv, stdout=output, stderr=subprocess.STDOUT, check=True, **kwargs) + + log("install", ["feed", "install", args.keys, args.repo, args.arch, client, "--fakeroot", + "vinix-desktop-init", "vinix-accounts", "vinix-release", "netbase"]) + log("audit", [args.auditor, args.arch, client]) + root = work / "root" + shutil.copytree(client / "root", root, symlinks=True) + native_overlay(args.initramfs, args.arch, root) + shutil.copyfile(root / "desktop-programs.sha256", work / "desktop-programs.sha256") + log("compile", ["vinix-cc", "-Wall", "-Wextra", "-Werror", "-O2", tests / "userland/framebuffer.c", + "-o", root / "framebuffer-check"], + env={**os.environ, "VPAC_MAKEPKG_ROOT": str(args.sdk)}) + helper = root / "usr/libexec/vinix-version-check" + helper.parent.mkdir(exist_ok=True) + with helper.open("x") as output: + output.write("#!/bin/sh\nexec /bin/sh /userland-check.sh\n") + helper.chmod(0o755) + mode = "--aarch64-fixture" if args.arch == "aarch64" else "--fixture" + log("boot", [args.boot, root, args.iso, work / "guest", mode, tests / "userland/desktop.sh"]) + with (work / "receipts.sha256").open("x") as output: + for file in sorted([*work.glob("*.log"), work / "guest/serial.log", work / "desktop-programs.sha256"]): + output.write(f"{digest(file)} {file.relative_to(work)}\n") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("arch", choices=INITRAMFS) + for name in ("keys", "repo", "auditor", "sdk", "initramfs", "boot", "iso", "work"): + parser.add_argument(name, type=lambda path: Path(path).resolve()) + run(parser.parse_args()) diff --git a/tests/userland/desktop.sh b/tests/userland/desktop.sh new file mode 100644 index 0000000..c62f5a1 --- /dev/null +++ b/tests/userland/desktop.sh @@ -0,0 +1,40 @@ +#!/bin/sh +set -eu +arch=$(/bin/busybox uname -m) +case "$arch" in + aarch64) exec >/dev/console 2>&1 ;; + x86_64) exec >/dev/com1 2>&1 ;; + *) exit 1 ;; +esac +finish() { + status=$? + if [ "$status" -ne 0 ]; then echo "VPAC desktop fixture failed"; fi + /sbin/poweroff -f +} +trap finish EXIT +find_command() { + for proc in /proc/[0-9]*; do + [ -r "$proc/cmdline" ] || continue + command=$(tr '\000' ' ' <"$proc/cmdline" 2>/dev/null) || continue + if [ "$command" = "$1 " ]; then echo "${proc##*/}"; return 0; fi + done + return 1 +} +echo 'Checking the first-boot Vinix desktop' +/bin/busybox sha256sum -c /desktop-programs.sha256 +case "$arch" in + aarch64) test "$(readlink /proc/1/exe)" = /sbin/init ;; + x86_64) tr '\000' '\n' +#include +#include +#include +#include +#include +#include + +/* Sample the displayed framebuffer without changing its graphics ownership. */ +int main(void) { + struct fb_var_screeninfo v = {0}; + struct fb_fix_screeninfo f = {0}; + int fd = open("/dev/fb0", O_RDONLY); + if (fd < 0 || ioctl(fd, FBIOGET_VSCREENINFO, &v) || ioctl(fd, FBIOGET_FSCREENINFO, &f)) + return 1; + if (v.xres < 320 || v.yres < 200 || v.xres > 16384 || v.yres > 16384 || v.bits_per_pixel != 32) + return 1; + size_t pitch = f.line_length ? f.line_length : v.xres * 4; + if (pitch < v.xres * 4 || pitch % 4 || pitch > 65536) + return 1; + const size_t length = pitch * v.yres; + const uint32_t *pixels = mmap(NULL, length, PROT_READ, MAP_SHARED, fd, 0); + if (pixels == MAP_FAILED) + return 1; + uint32_t palette[24]; + size_t count = 0; + for (size_t y = 0; y < v.yres && count < 24; y += 7) { + for (size_t x = 0; x < v.xres && count < 24; x += 7) { + uint32_t color = pixels[y * (pitch / 4) + x] & 0xffffff; + size_t i = 0; + while (i < count && color != palette[i]) + ++i; + if (i == count) + palette[count++] = color; + } + } + munmap((void *)pixels, length); + close(fd); + if (count < 24) + return 1; + printf("desktop framebuffer %ux%u at 32 bpp, at least %zu sampled colors\n", v.xres, v.yres, count); + return 0; +} -- 2.56.1