me

/

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

Run the target font generator in cross-build SDKs

diviocity committed 5 days ago · e1adb26f890e7ed302a11b152024a0ee601ccbd9 View patch
Unverified signature 4 files changed +41 -6
tests/FEED.md +2 -0

@@ -19,6 +19,8 @@ A builder with its own unprivileged service account and private state directory

1919

2020Target 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.

2121

22+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`.

23+

2224For 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.

2325

2426```sh

tests/combined-feed.py +5 -1

@@ -81,8 +81,11 @@ def run(args):

8181 check=True, stdout=log, stderr=subprocess.STDOUT)

8282 if args.publish_only:

8383 return

84+ install_flags = ["--fakeroot"]

85+ if args.cross_sdk:

86+ install_flags.append("--cross-sdk")

8487 for label, command in [

85- ("install", ["feed", "install", args.keys, repo, args.arch, client, "--fakeroot", *(args.install or names)]),

88+ ("install", ["feed", "install", args.keys, repo, args.arch, client, *install_flags, *(args.install or names)]),

8689 ("audit", [args.auditor, args.arch, client]),

8790 ]:

8891 with (args.work / (label + ".log")).open("w") as log:

@@ -101,4 +104,5 @@ if __name__ == "__main__":

101104 mode.add_argument("--install", metavar="NAME", action="append",

102105 help="install this root and its dependencies; repeat for additional roots (default: every package)")

103106 mode.add_argument("--publish-only", action="store_true", help="publish the signed repository for a separate clean install")

107+ parser.add_argument("--cross-sdk", action="store_true", help="emulate the bitmap font hook on a cross-build SDK")

104108 run(parser.parse_args())

tests/feed.v +30 -4

@@ -130,14 +130,30 @@ fn publish(state string, repo string, arch string, archives []string) ! {

130130 os.rename(stage, os.join_path(repo, arch))!

131131}

132132

133-fn install(state string, repo string, arch string, client string, packages []string, fakeroot bool) ! {

133+fn install(state string, repo string, arch string, client string, packages []string, fakeroot bool, cross_sdk bool) ! {

134134 if packages.any(it.len == 0 || it.starts_with('-') || it.contains('/')) {

135135 return error('expected package names from the signed repository')

136136 }

137+ if cross_sdk && arch == os.uname().machine {

138+ return error('--cross-sdk requires a foreign package architecture')

139+ }

137140 os.mkdir(client)!

138141 for subdir in ['root', 'db/local', 'db/sync', 'cache', 'hooks'] {

139142 os.mkdir_all(os.join_path(client, subdir))!

140143 }

144+ root := os.join_path(client, 'root')

145+ font_hook := '60-update-x11-misc-fonts.hook'

146+ mask := os.join_path(client, 'hooks', font_hook)

147+ if cross_sdk {

148+ // libalpm's chroot cannot run a foreign executable on this worker.

149+ // Run the packaged index generator under user-mode QEMU after installation.

150+ os.symlink('/dev/null', mask)!

151+ }

152+ defer {

153+ if cross_sdk {

154+ os.rm(mask) or {}

155+ }

156+ }

141157 os.write_file(os.join_path(client, 'db/local/ALPM_DB_VERSION'), '9\n')!

142158 config := os.join_path(client, 'config.vile')

143159 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

167183 if result.output.split_into_lines().any(it.starts_with('error:')) {

168184 return error('vpac reported a transaction error in the install log')

169185 }

186+ if cross_sdk && os.is_file(os.join_path(root, 'usr/share/libalpm/hooks', font_hook)) {

187+ program := os.join_path(root, 'usr/bin/mkfontscale')

188+ font_dir := os.join_path(root, 'usr/share/fonts/X11/misc')

189+ print(output(['env', 'VPAC_TARGET_ARCH=' + arch, 'VPAC_MAKEPKG_ROOT=' + root,

190+ 'vinix-run', program, '-b', '-s', '-l', font_dir])!)

191+ }

170192}

171193

172194fn command(args []string) ! {

@@ -188,19 +210,23 @@ fn command(args []string) ! {

188210 }

189211 if args[0] == 'install' && args.len >= 6 {

190212 fakeroot := args[5] == '--fakeroot'

191- first_package := if fakeroot { 6 } else { 5 }

213+ mut first_package := if fakeroot { 6 } else { 5 }

214+ cross_sdk := first_package < args.len && args[first_package] == '--cross-sdk'

215+ if cross_sdk {

216+ first_package++

217+ }

192218 packages := args[first_package..]

193219 if packages.len == 0 {

194220 return error('expected at least one package name')

195221 }

196- install(state, repo, args[3], os.abs_path(args[4]), packages, fakeroot)!

222+ install(state, repo, args[3], os.abs_path(args[4]), packages, fakeroot, cross_sdk)!

197223 return

198224 }

199225 }

200226 eprintln('usage: feed keys NEW_KEY_STATE')

201227 eprintln(' feed trust NEW_CLIENT_KEY_STATE PUBLIC_KEY EXPECTED_FINGERPRINT')

202228 eprintln(' feed publish KEY_STATE NEW_REPO ARCH PACKAGE_ARCHIVE...')

203- eprintln(' feed install KEY_STATE REPO ARCH NEW_CLIENT [--fakeroot] PACKAGE_NAME...')

229+ eprintln(' feed install KEY_STATE REPO ARCH NEW_CLIENT [--fakeroot] [--cross-sdk] PACKAGE_NAME...')

204230 exit(2)

205231}

206232

tools/build-queue.py +4 -1

@@ -150,7 +150,10 @@ def build(args, recipe_name, outputs, receipts, logs, artifacts):

150150 def run(cmd, **kwargs):

151151 subprocess.run(cmd, stdout=log, stderr=subprocess.STDOUT, check=True, **kwargs)

152152 try:

153- run([sys.executable, scripts / "combined-feed.py", args.arch, args.keys, args.auditor, sdk, *receipts])

153+ feed = [sys.executable, scripts / "combined-feed.py", args.arch, args.keys, args.auditor, sdk, *receipts]

154+ if args.arch != os.uname().machine:

155+ feed.append("--cross-sdk")

156+ run(feed)

154157 finally:

155158 for filename in ("selection.tsv", "audit.log", "install.log", "publish.log"):

156159 if (sdk / filename).is_file():