From e1adb26f890e7ed302a11b152024a0ee601ccbd9 Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 16:38:59 +0100 Subject: [PATCH] Run the target font generator in cross-build SDKs --- tests/FEED.md | 2 ++ tests/combined-feed.py | 6 +++++- tests/feed.v | 34 ++++++++++++++++++++++++++++++---- tools/build-queue.py | 5 ++++- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/tests/FEED.md b/tests/FEED.md index bc8d1a7..a93b371 100644 --- a/tests/FEED.md +++ b/tests/FEED.md @@ -19,6 +19,8 @@ A builder with its own unprivileged service account and private state directory Target post-transaction hooks need permission to enter the installed root. For the worker's x86_64 font test, systemd granted the dynamic user `CAP_SYS_CHROOT` within its private user namespace using `PrivateUsers=yes`, `CapabilityBoundingSet=CAP_SYS_CHROOT` and `AmbientCapabilities=CAP_SYS_CHROOT`. The install fixture also checks vpac's transaction log for hook errors. Without that capability, vpac returned zero after a hook failed and the fixture rejected the result. +For a foreign-architecture build SDK, `feed install --cross-sdk` masks the bitmap font hook during the transaction and runs the packaged `mkfontscale` with user-mode QEMU and the installed musl loader. The mask lives in the worker's client hook directory and is removed after installation. The AArch64 proof installed 11 signed packages, audited 725 owned paths and 20 ELFs, and generated `fonts.dir` with 335 entries. The installed root retained the original hook for Vinix. See `xorg/arm/abi16/cross-font-sdk-01`, receipt SHA-256 `2d6362b78953c336f2ce42cc7e8c24dfc355945ea557a3475058fe74decc5b5c`. + For a separate consumer, transfer the repository directory and obtain the expected fingerprint independently from the test owner. Import the public key into a client-only keyring. ```sh diff --git a/tests/combined-feed.py b/tests/combined-feed.py index 35bcbc7..8b8b757 100644 --- a/tests/combined-feed.py +++ b/tests/combined-feed.py @@ -81,8 +81,11 @@ def run(args): check=True, stdout=log, stderr=subprocess.STDOUT) if args.publish_only: return + install_flags = ["--fakeroot"] + if args.cross_sdk: + install_flags.append("--cross-sdk") for label, command in [ - ("install", ["feed", "install", args.keys, repo, args.arch, client, "--fakeroot", *(args.install or names)]), + ("install", ["feed", "install", args.keys, repo, args.arch, client, *install_flags, *(args.install or names)]), ("audit", [args.auditor, args.arch, client]), ]: with (args.work / (label + ".log")).open("w") as log: @@ -101,4 +104,5 @@ if __name__ == "__main__": mode.add_argument("--install", metavar="NAME", action="append", help="install this root and its dependencies; repeat for additional roots (default: every package)") mode.add_argument("--publish-only", action="store_true", help="publish the signed repository for a separate clean install") + parser.add_argument("--cross-sdk", action="store_true", help="emulate the bitmap font hook on a cross-build SDK") run(parser.parse_args()) diff --git a/tests/feed.v b/tests/feed.v index e32d6dc..4ff353d 100644 --- a/tests/feed.v +++ b/tests/feed.v @@ -130,14 +130,30 @@ fn publish(state string, repo string, arch string, archives []string) ! { os.rename(stage, os.join_path(repo, arch))! } -fn install(state string, repo string, arch string, client string, packages []string, fakeroot bool) ! { +fn install(state string, repo string, arch string, client string, packages []string, fakeroot bool, cross_sdk bool) ! { if packages.any(it.len == 0 || it.starts_with('-') || it.contains('/')) { return error('expected package names from the signed repository') } + if cross_sdk && arch == os.uname().machine { + return error('--cross-sdk requires a foreign package architecture') + } os.mkdir(client)! for subdir in ['root', 'db/local', 'db/sync', 'cache', 'hooks'] { os.mkdir_all(os.join_path(client, subdir))! } + root := os.join_path(client, 'root') + font_hook := '60-update-x11-misc-fonts.hook' + mask := os.join_path(client, 'hooks', font_hook) + if cross_sdk { + // libalpm's chroot cannot run a foreign executable on this worker. + // Run the packaged index generator under user-mode QEMU after installation. + os.symlink('/dev/null', mask)! + } + defer { + if cross_sdk { + os.rm(mask) or {} + } + } os.write_file(os.join_path(client, 'db/local/ALPM_DB_VERSION'), '9\n')! config := os.join_path(client, 'config.vile') url := 'file://' + os.join_path(repo, arch).split('/').map(urllib.path_escape(it)).join('/') @@ -167,6 +183,12 @@ fn install(state string, repo string, arch string, client string, packages []str if result.output.split_into_lines().any(it.starts_with('error:')) { return error('vpac reported a transaction error in the install log') } + if cross_sdk && os.is_file(os.join_path(root, 'usr/share/libalpm/hooks', font_hook)) { + program := os.join_path(root, 'usr/bin/mkfontscale') + font_dir := os.join_path(root, 'usr/share/fonts/X11/misc') + print(output(['env', 'VPAC_TARGET_ARCH=' + arch, 'VPAC_MAKEPKG_ROOT=' + root, + 'vinix-run', program, '-b', '-s', '-l', font_dir])!) + } } fn command(args []string) ! { @@ -188,19 +210,23 @@ fn command(args []string) ! { } if args[0] == 'install' && args.len >= 6 { fakeroot := args[5] == '--fakeroot' - first_package := if fakeroot { 6 } else { 5 } + mut first_package := if fakeroot { 6 } else { 5 } + cross_sdk := first_package < args.len && args[first_package] == '--cross-sdk' + if cross_sdk { + first_package++ + } packages := args[first_package..] if packages.len == 0 { return error('expected at least one package name') } - install(state, repo, args[3], os.abs_path(args[4]), packages, fakeroot)! + install(state, repo, args[3], os.abs_path(args[4]), packages, fakeroot, cross_sdk)! return } } eprintln('usage: feed keys NEW_KEY_STATE') eprintln(' feed trust NEW_CLIENT_KEY_STATE PUBLIC_KEY EXPECTED_FINGERPRINT') eprintln(' feed publish KEY_STATE NEW_REPO ARCH PACKAGE_ARCHIVE...') - eprintln(' feed install KEY_STATE REPO ARCH NEW_CLIENT [--fakeroot] PACKAGE_NAME...') + eprintln(' feed install KEY_STATE REPO ARCH NEW_CLIENT [--fakeroot] [--cross-sdk] PACKAGE_NAME...') exit(2) } diff --git a/tools/build-queue.py b/tools/build-queue.py index c63febc..3c9b4bd 100644 --- a/tools/build-queue.py +++ b/tools/build-queue.py @@ -150,7 +150,10 @@ def build(args, recipe_name, outputs, receipts, logs, artifacts): def run(cmd, **kwargs): subprocess.run(cmd, stdout=log, stderr=subprocess.STDOUT, check=True, **kwargs) try: - run([sys.executable, scripts / "combined-feed.py", args.arch, args.keys, args.auditor, sdk, *receipts]) + feed = [sys.executable, scripts / "combined-feed.py", args.arch, args.keys, args.auditor, sdk, *receipts] + if args.arch != os.uname().machine: + feed.append("--cross-sdk") + run(feed) finally: for filename in ("selection.tsv", "audit.log", "install.log", "publish.log"): if (sdk / filename).is_file(): -- 2.56.1