Boot the package-owned desktop init through first-boot registration
@@ -103,3 +103,5 @@ Both targets also passed a fresh signed install of musl, `vinix-accounts`, `vini
103103The 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`.
104104
105105The 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`.
106+
107+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`.
@@ -0,0 +1,86 @@
1+"""Exercise the packaged release PID 1 with the native Vinix first-boot desktop."""
2+import argparse
3+import hashlib
4+import os
5+import shutil
6+import subprocess
7+import tarfile
8+from pathlib import Path
9+
10+
11+# Published November 28 release, checked against each architecture's ISO.
12+INITRAMFS = {
13+ "x86_64": "8be0f76685936c66d40609f62ad7ad5d2b231e6778678618a445e7fe83ce54da",
14+ "aarch64": "a32afaa82a33096256280086bacbc39873e36a2e3ecd81c5504960b9034ec4f9",
15+}
16+PROGRAMS = ("usr/bin/vinix-desktop", "usr/sbin/vinix-session", "usr/sbin/vinix-account",
17+ "usr/sbin/vinix-authd", "usr/sbin/vinix-system")
18+
19+
20+def digest(path):
21+ with path.open("rb") as stream:
22+ return hashlib.file_digest(stream, "sha256").hexdigest()
23+
24+
25+def native_overlay(archive, arch, root):
26+ if digest(archive) != INITRAMFS[arch]:
27+ raise ValueError("release initramfs checksum mismatch")
28+ copies = set()
29+ with tarfile.open(archive, "r|gz") as members:
30+ for item in members:
31+ name = item.name.removeprefix("./")
32+ if name not in PROGRAMS:
33+ continue
34+ if not item.isfile() or not item.mode & 0o111:
35+ raise ValueError(f"expected a native executable at {name}")
36+ target = root / name
37+ with members.extractfile(item) as source, target.open("xb") as output:
38+ shutil.copyfileobj(source, output)
39+ target.chmod(0o755)
40+ copies.add(name)
41+ if copies != set(PROGRAMS):
42+ raise ValueError(f"missing release programs: {set(PROGRAMS) - copies}")
43+ manifest = root / "desktop-programs.sha256"
44+ with manifest.open("x") as output:
45+ for name in ("sbin/init", *PROGRAMS):
46+ output.write(f"{digest(root / name)} /{name}\n")
47+
48+
49+def run(args):
50+ work = args.work
51+ work.mkdir()
52+ client = work / "client"
53+ tests = Path(__file__).resolve().parent
54+
55+ def log(name, argv, **kwargs):
56+ with (work / (name + ".log")).open("x") as output:
57+ subprocess.run(argv, stdout=output, stderr=subprocess.STDOUT, check=True, **kwargs)
58+
59+ log("install", ["feed", "install", args.keys, args.repo, args.arch, client, "--fakeroot",
60+ "vinix-desktop-init", "vinix-accounts", "vinix-release", "netbase"])
61+ log("audit", [args.auditor, args.arch, client])
62+ root = work / "root"
63+ shutil.copytree(client / "root", root, symlinks=True)
64+ native_overlay(args.initramfs, args.arch, root)
65+ shutil.copyfile(root / "desktop-programs.sha256", work / "desktop-programs.sha256")
66+ log("compile", ["vinix-cc", "-Wall", "-Wextra", "-Werror", "-O2", tests / "userland/framebuffer.c",
67+ "-o", root / "framebuffer-check"],
68+ env={**os.environ, "VPAC_MAKEPKG_ROOT": str(args.sdk)})
69+ helper = root / "usr/libexec/vinix-version-check"
70+ helper.parent.mkdir(exist_ok=True)
71+ with helper.open("x") as output:
72+ output.write("#!/bin/sh\nexec /bin/sh /userland-check.sh\n")
73+ helper.chmod(0o755)
74+ mode = "--aarch64-fixture" if args.arch == "aarch64" else "--fixture"
75+ log("boot", [args.boot, root, args.iso, work / "guest", mode, tests / "userland/desktop.sh"])
76+ with (work / "receipts.sha256").open("x") as output:
77+ for file in sorted([*work.glob("*.log"), work / "guest/serial.log", work / "desktop-programs.sha256"]):
78+ output.write(f"{digest(file)} {file.relative_to(work)}\n")
79+
80+
81+if __name__ == "__main__":
82+ parser = argparse.ArgumentParser(description=__doc__)
83+ parser.add_argument("arch", choices=INITRAMFS)
84+ for name in ("keys", "repo", "auditor", "sdk", "initramfs", "boot", "iso", "work"):
85+ parser.add_argument(name, type=lambda path: Path(path).resolve())
86+ run(parser.parse_args())
@@ -0,0 +1,40 @@
1+#!/bin/sh
2+set -eu
3+arch=$(/bin/busybox uname -m)
4+case "$arch" in
5+ aarch64) exec >/dev/console 2>&1 ;;
6+ x86_64) exec >/dev/com1 2>&1 ;;
7+ *) exit 1 ;;
8+esac
9+finish() {
10+ status=$?
11+ if [ "$status" -ne 0 ]; then echo "VPAC desktop fixture failed"; fi
12+ /sbin/poweroff -f
13+}
14+trap finish EXIT
15+find_command() {
16+ for proc in /proc/[0-9]*; do
17+ [ -r "$proc/cmdline" ] || continue
18+ command=$(tr '\000' ' ' <"$proc/cmdline" 2>/dev/null) || continue
19+ if [ "$command" = "$1 " ]; then echo "${proc##*/}"; return 0; fi
20+ done
21+ return 1
22+}
23+echo 'Checking the first-boot Vinix desktop'
24+/bin/busybox sha256sum -c /desktop-programs.sha256
25+case "$arch" in
26+ aarch64) test "$(readlink /proc/1/exe)" = /sbin/init ;;
27+ x86_64) tr '\000' '\n' </proc/1/cmdline | grep -Fx /sbin/init ;;
28+esac
29+for attempt in $(seq 1 60); do
30+ if session=$(find_command '/usr/sbin/vinix-session graphical --desktop /usr/bin/vinix-desktop') &&
31+ registration=$(find_command '/usr/bin/vinix-desktop --register-only') &&
32+ /framebuffer-check; then
33+ echo "graphical session PID $session, registration PID $registration"
34+ echo 'VPAC FIXTURE GUEST PASS'
35+ exit 0
36+ fi
37+ sleep 1
38+done
39+ps
40+exit 1
@@ -0,0 +1,43 @@
1+#include <fcntl.h>
2+#include <linux/fb.h>
3+#include <stdint.h>
4+#include <stdio.h>
5+#include <sys/ioctl.h>
6+#include <sys/mman.h>
7+#include <unistd.h>
8+
9+/* Sample the displayed framebuffer without changing its graphics ownership. */
10+int main(void) {
11+ struct fb_var_screeninfo v = {0};
12+ struct fb_fix_screeninfo f = {0};
13+ int fd = open("/dev/fb0", O_RDONLY);
14+ if (fd < 0 || ioctl(fd, FBIOGET_VSCREENINFO, &v) || ioctl(fd, FBIOGET_FSCREENINFO, &f))
15+ return 1;
16+ if (v.xres < 320 || v.yres < 200 || v.xres > 16384 || v.yres > 16384 || v.bits_per_pixel != 32)
17+ return 1;
18+ size_t pitch = f.line_length ? f.line_length : v.xres * 4;
19+ if (pitch < v.xres * 4 || pitch % 4 || pitch > 65536)
20+ return 1;
21+ const size_t length = pitch * v.yres;
22+ const uint32_t *pixels = mmap(NULL, length, PROT_READ, MAP_SHARED, fd, 0);
23+ if (pixels == MAP_FAILED)
24+ return 1;
25+ uint32_t palette[24];
26+ size_t count = 0;
27+ for (size_t y = 0; y < v.yres && count < 24; y += 7) {
28+ for (size_t x = 0; x < v.xres && count < 24; x += 7) {
29+ uint32_t color = pixels[y * (pitch / 4) + x] & 0xffffff;
30+ size_t i = 0;
31+ while (i < count && color != palette[i])
32+ ++i;
33+ if (i == count)
34+ palette[count++] = color;
35+ }
36+ }
37+ munmap((void *)pixels, length);
38+ close(fd);
39+ if (count < 24)
40+ return 1;
41+ printf("desktop framebuffer %ux%u at 32 bpp, at least %zu sampled colors\n", v.xres, v.yres, count);
42+ return 0;
43+}