me

/

vinix-ports Public
382 commits 0 issues 0 pull requests 1 contributor Discussions Projects Snippets LOC history Platform CI

Assemble X11 sidecars from audited Vinix package roots

diviocity committed 5 days ago · 079afeaaf284232615ff2296a7928657eb058ecd View patch
Unverified signature 3 files changed +193 -0
tests/x11/README.md +8 -0

@@ -59,6 +59,14 @@ For those checks, install `vinix-release-x11` and `busybox-init` from the signed

5959

6060For the on-demand release test, combine the signed desktop and X11 package lists with `tests/combined-feed.py --publish-only`. Pass the combined feed to `tools/desktop-root.py` to install the desktop metapackage and embed the signed feed. Add the native desktop programs and framebuffer probe as in `tests/desktop-guest.py`. Set `VINIX_DESKTOP_NEXT_FIXTURE` in the desktop fixture to the guest path of `graphics.sh` and set `VINIX_X11_INSTALL_FROM_PKG=1` in that script. With `tests/disk-root.py --desktop-init --space-for "$x11_sdk/root"`, the guest must reach graphical registration, resolve `x11` by exact name, install the signed X11 metapackage, verify the server and Mesa owners, and pass both rendered pixel checks.

6161

62+Use the same signed feed for the downloadable X11 sidecar. Cold-install `vinix-release-desktop` into one client. Into a second client, cold-install both `vinix-release-desktop` and `vinix-release-x11` with the target font hooks enabled.

63+

64+```sh

65+python3 tools/bundle-x11.py "$arch" "$desktop_client" "$x11_client" "$auditor" "$output"

66+```

67+

68+The tool audits both clients and checks the package versions, modes, link targets and bytes shared with the desktop. It writes the new paths to a root-owned archive under the published name `vinix-x11-amd64.tar.gz` or `vinix-x11-arm64.tar.gz`, with a matching checksum file. The package manager installs from the signed feed. Run `python3 tests/x11/bundle.py` for the archive layout, link preservation and rejection checks. The worker fixture is in `foundation/x11-bundle-fixture-01`, receipt SHA-256 `0a9abdd8e27a93cc6bb6926b1a95b9c7a46e281274c9fd7015a343c8255781dc`.

69+

6270Both architectures passed the desktop PID 1 and framebuffer checks from a disposable ext2 image. Those runs used the five checksum-pinned native programs from the November 28 release. The x86_64 chained fixture also ran its second script after registration and verified the larger disk size. A separate test published a signed feed with `--publish-only`, then installed musl and netbase into a clean root using the pinned public key. See `foundation/native-desktop-disk-path-01`, `foundation/native-desktop-chained-fixture-01` and `foundation/combined-publish-only-01`, receipt SHA-256 `86c564cb9415859d2411343f74b8ad8926418c16bedb4a612aab85db46137ccd`, `cb2d6c6afbdf2733676080f49792aa11b10907d1778d2bc3d01ae3317874a7e0` and `afde40678739b96cf16db58803ef87447ae4499a9e70f3425814a244e12d6883`. The complete desktop and X11 transaction still needs both graphics feeds.

6371

6472Set `VINIX_MESA_NATIVE_FILE` to a Meson native machine file whose `pkg_config_path` includes a build-host `wayland-scanner.pc`. The worker reused the source-built x86_64 Wayland scanner from an audited signed root. Meson found the native scanner through that file, found the target Wayland client in the SDK, and generated a protocol header. Mako and Intel CLC run in the build environment. See `xorg/mesa-host-tools-03/generator-check`, receipt SHA-256 `8df63367710d4ead9e968d30fe97eb3c63b45b4eba0f444447f5bf75b0cd4229`.

tests/x11/bundle.py new file +79 -0

@@ -0,0 +1,79 @@

1+"""Test the release overlay layout and rejection of a changed base."""

2+

3+import argparse

4+import hashlib

5+from importlib import import_module

6+import os

7+from pathlib import Path

8+import sys

9+import tarfile

10+import tempfile

11+import unittest

12+

13+

14+sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "tools"))

15+sidecar = import_module("bundle-x11")

16+

17+

18+class BundleTest(unittest.TestCase):

19+ def setUp(self):

20+ work = tempfile.TemporaryDirectory()

21+ self.addCleanup(work.cleanup)

22+ self.base, self.full, self.output = (Path(work.name, name) for name in ("base", "full", "output"))

23+ for client in (self.base, self.full):

24+ self.install_record(client, "vinix-release-desktop", "1-1")

25+ (client / "root/usr/bin").mkdir(parents=True)

26+ (client / "root/usr/bin/pkg").write_bytes(b"desktop package manager")

27+ self.install_record(self.full, "vinix-release-x11", "2-1")

28+ for path in sidecar.RELEASE_COMMANDS:

29+ command = self.full / "root" / path

30+ command.write_bytes(path.encode())

31+ command.chmod(0o755)

32+

33+ def install_record(self, client, name, version):

34+ directory = client / "db/local" / f"{name}-{version}"

35+ directory.mkdir(parents=True)

36+ (directory / "desc").write_text(f"%NAME%\n{name}\n\n%VERSION%\n{version}\n\n")

37+

38+ def write_bundle(self, arch="x86_64"):

39+ # Signature and ELF checks run in the signed-root release fixture.

40+ sidecar.bundle(argparse.Namespace(

41+ desktop=self.base, x11=self.full, output=self.output, auditor="/bin/true", arch=arch))

42+

43+ def test_arm64_overlay_preserves_links_and_omits_desktop_paths(self):

44+ drivers = self.full / "root/usr/lib/dri"

45+ drivers.mkdir(parents=True)

46+ driver = drivers / "swrast_dri.so"

47+ driver.write_bytes(b"software driver")

48+ os.link(driver, drivers / "kms_swrast_dri.so")

49+ (drivers / "swrast.so").symlink_to(driver.name)

50+

51+ self.write_bundle("aarch64")

52+

53+ archive = self.output / "vinix-x11-arm64.tar.gz"

54+ digest = hashlib.sha256(archive.read_bytes()).hexdigest()

55+ self.assertEqual(archive.with_suffix(".gz.sha256").read_text(), f"{digest} {archive.name}\n")

56+ with tarfile.open(archive) as tar:

57+ self.assertNotIn("./usr/bin/pkg", tar.getnames())

58+ self.assertNotIn("./usr/bin", tar.getnames())

59+ self.assertNotIn("./db", tar.getnames())

60+ binary = tar.getmember("./usr/bin/Xvfb")

61+ self.assertEqual((binary.uid, binary.gid, binary.mode), (0, 0, 0o755))

62+ self.assertEqual(tar.getmember("./usr/lib/dri/swrast.so").linkname, driver.name)

63+ self.assertTrue(tar.getmember("./usr/lib/dri/swrast_dri.so").islnk())

64+

65+ def test_changed_desktop_bytes_prevent_publication(self):

66+ (self.full / "root/usr/bin/pkg").write_bytes(b"replaced package manager")

67+ with self.assertRaisesRegex(ValueError, "changed /usr/bin/pkg"):

68+ self.write_bundle()

69+ self.assertFalse(self.output.exists())

70+

71+ def test_missing_glx_server_prevents_publication(self):

72+ (self.full / "root/usr/bin/Xvfb-glx").unlink()

73+ with self.assertRaisesRegex(ValueError, "missing executable /usr/bin/Xvfb-glx"):

74+ self.write_bundle()

75+ self.assertFalse(self.output.exists())

76+

77+

78+if __name__ == "__main__":

79+ unittest.main()

tools/bundle-x11.py new file +106 -0

@@ -0,0 +1,106 @@

1+"""Assemble a release X11 overlay from two audited vpac clients."""

2+

3+import argparse

4+import filecmp

5+import gzip

6+import hashlib

7+from importlib import import_module

8+import os

9+from pathlib import Path

10+import stat

11+import subprocess

12+import tarfile

13+import tempfile

14+

15+RELEASE_COMMANDS = (

16+ "usr/bin/Xorg", "usr/bin/Xvfb", "usr/bin/Xvfb-glx", "usr/bin/startx",

17+ "usr/bin/vinix-wine-host", "usr/bin/vinix-xinput",

18+)

19+

20+

21+def tree(root):

22+ entries = {}

23+ for directory, folders, files in os.walk(root):

24+ # os.walk puts symlinks to directories in folders but does not traverse them.

25+ for name in folders + files:

26+ path = Path(directory, name)

27+ entries[path.relative_to(root).as_posix()] = path.lstat().st_mode

28+ return entries

29+

30+

31+def overlay_paths(base, full):

32+ before, after = tree(base), tree(full)

33+ for path, mode in before.items():

34+ updated = after.get(path)

35+ if updated is None or mode != updated:

36+ raise ValueError(f"X11 install removed or replaced /{path}")

37+ if stat.S_ISDIR(mode):

38+ continue

39+ original, installed = base / path, full / path

40+ matches = (os.readlink(original) == os.readlink(installed) if stat.S_ISLNK(mode)

41+ else filecmp.cmp(original, installed, shallow=False))

42+ if not matches:

43+ raise ValueError(f"X11 install changed /{path} from the desktop root")

44+ added = sorted(after.keys() - before.keys())

45+ for path in added:

46+ mode = after[path]

47+ if not (stat.S_ISREG(mode) or stat.S_ISLNK(mode) or stat.S_ISDIR(mode)):

48+ raise ValueError(f"unexpected sidecar entry type for /{path}")

49+ return added

50+

51+

52+def packages(client):

53+ package_fields = import_module("stage-image").package_fields

54+ records = (client / "db/local").glob("*/desc")

55+ return {record["NAME"]: record["VERSION"]

56+ for record in (package_fields(path.read_text()) for path in records)}

57+

58+

59+def owner_root(entry):

60+ entry.uid = entry.gid = 0

61+ entry.uname = entry.gname = "root"

62+ return entry

63+

64+

65+def bundle(args):

66+ base, full = args.desktop.resolve(), args.x11.resolve()

67+ output = args.output.resolve()

68+ if output.is_relative_to(base) or output.is_relative_to(full):

69+ raise ValueError("put sidecar output outside both clients")

70+ if output.exists():

71+ raise FileExistsError(output)

72+ for client in (base, full):

73+ subprocess.run([args.auditor, args.arch, client], check=True)

74+ common, combined = packages(base), packages(full)

75+ if ("vinix-release-desktop" not in common or "vinix-release-x11" in common

76+ or "vinix-release-x11" not in combined or not common.items() < combined.items()):

77+ raise ValueError("expected desktop and desktop-plus-X11 package roots")

78+ base, full = base / "root", full / "root"

79+ paths = overlay_paths(base, full)

80+ for name in RELEASE_COMMANDS:

81+ if name not in paths or not os.access(full / name, os.X_OK):

82+ raise ValueError(f"sidecar is missing executable /{name}")

83+

84+ suffix = "amd64" if args.arch == "x86_64" else "arm64"

85+ name = f"vinix-x11-{suffix}.tar.gz"

86+ with tempfile.TemporaryDirectory(dir=output.parent) as work:

87+ staging = Path(work, "sidecar")

88+ staging.mkdir(mode=0o755)

89+ archive = staging / name

90+ with archive.open("xb") as data:

91+ with gzip.GzipFile(filename="", mode="wb", fileobj=data, mtime=0) as compressed:

92+ with tarfile.open(fileobj=compressed, mode="w|", format=tarfile.USTAR_FORMAT) as tar:

93+ for path in paths:

94+ tar.add(full / path, arcname=f"./{path}", recursive=False, filter=owner_root)

95+ with archive.open("rb") as data:

96+ digest = hashlib.file_digest(data, "sha256").hexdigest()

97+ (staging / (name + ".sha256")).write_text(f"{digest} {name}\n")

98+ staging.rename(output)

99+

100+

101+if __name__ == "__main__":

102+ parser = argparse.ArgumentParser(description=__doc__)

103+ parser.add_argument("arch", choices=("x86_64", "aarch64"))

104+ for label in ("desktop", "x11", "auditor", "output"):

105+ parser.add_argument(label, type=Path)

106+ bundle(parser.parse_args())