From 51967741cbe805f0acfde1ff543d4fdcbd767b72 Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 02:34:38 +0100 Subject: [PATCH] mkfontscale: own the bitmap index and verify its hook in Vinix --- mkfontscale/PKGBUILD.vile | 10 ++++-- mkfontscale/update-x11-misc-fonts.hook | 1 + tests/x11/font-index.v | 50 ++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 tests/x11/font-index.v diff --git a/mkfontscale/PKGBUILD.vile b/mkfontscale/PKGBUILD.vile index 60085d9..78a9a1d 100644 --- a/mkfontscale/PKGBUILD.vile +++ b/mkfontscale/PKGBUILD.vile @@ -1,7 +1,7 @@ defpkgbuild(mkfontscale, #:pkgname, "mkfontscale", #:pkgver, "1.2.3", - #:pkgrel, 1, + #:pkgrel, 2, #:pkgdesc, "Scalable font index generator for X", #:arch, [#:x86-64, #:aarch64], #:license, "MIT", @@ -11,7 +11,7 @@ defpkgbuild(mkfontscale, #:source, ["https://xorg.freedesktop.org/archive/individual/app/mkfontscale-1.2.3.tar.xz", "update-x11-misc-fonts.hook"], #:sha256sums, [ "2921cdc344f1acee04bcd6ea1e29565c1308263006e134a9ee38cf9c9d6fe75e", - "3d34e8785692b8df97e86c539004f4fb45bebd0239535bb3e52999cf3aea56ac" + "0ae9b28e5c63ef460ab4c847b81b36610eb0935df3b333f1f8a3f2d2d3af53e4" ], #:build, fn() { @@ -23,6 +23,12 @@ defpkgbuild(mkfontscale, }, #:package, fn() { run("make", "install", string-append("DESTDIR=", pkgdir())) + ; Own the live index even when no bitmap fonts are installed. The hook + ; rebuilds it on font changes and after this package replaces the index. + fonts := string-append(pkgdir(), "/usr/share/fonts/X11/misc") + run("mkdir", "-p", fonts) + run("vinix-run", "./mkfontscale", "-b", "-s", "-l", fonts) + run("grep", "-Fx", "0", string-append(fonts, "/fonts.dir")) run("install", "-Dm644", "update-x11-misc-fonts.hook", string-append(pkgdir(), "/usr/share/libalpm/hooks/60-update-x11-misc-fonts.hook")) run("install", "-Dm644", "mkfontscale-1.2.3/COPYING", diff --git a/mkfontscale/update-x11-misc-fonts.hook b/mkfontscale/update-x11-misc-fonts.hook index cf437f4..c659f66 100644 --- a/mkfontscale/update-x11-misc-fonts.hook +++ b/mkfontscale/update-x11-misc-fonts.hook @@ -4,6 +4,7 @@ Operation = Upgrade Operation = Remove Type = Path Target = usr/share/fonts/X11/misc/*.pcf.gz +Target = usr/share/fonts/X11/misc/fonts.dir [Action] Description = Updating the X11 bitmap font directory diff --git a/tests/x11/font-index.v b/tests/x11/font-index.v new file mode 100644 index 0000000..03bdbab --- /dev/null +++ b/tests/x11/font-index.v @@ -0,0 +1,50 @@ +// Run in the diskless guest with both X11 bitmap font packages installed. +module main + +import os + +const font_dir = '/usr/share/fonts/X11/misc' + +fn rebuild(expect_cursor bool) ! { + hook := '/usr/share/libalpm/hooks/60-update-x11-misc-fonts.hook' + commands := os.read_lines(hook)!.filter(it.starts_with('Exec = ')) + if commands.len != 1 { + return error('expected one Exec action in ${hook}') + } + result := os.exec(commands[0].all_after('Exec = ').split(' ')) + if result.exit_code != 0 { + return error('font index hook exited ${result.exit_code}: ${result.output}') + } + lines := os.read_lines(os.join_path(font_dir, 'fonts.dir'))! + if lines.len < 2 || lines[0].int() != lines.len - 1 + || lines.any(it.starts_with('cursor.pcf.gz ')) != expect_cursor + || !lines.any(it.to_lower().starts_with('6x13.pcf.gz -misc-fixed-')) { + return error('font index has an incorrect count or bitmap font entries') + } +} + +fn check() ! { + rebuild(true)! + cursor := os.join_path(font_dir, 'cursor.pcf.gz') + directory := os.join_path(font_dir, '.vinix-test-${os.getpid()}') + os.mkdir(directory)! + defer { + os.rmdir(directory) or { eprintln(err) } + } + temporary := os.join_path(directory, 'cursor.pcf.gz') + os.rename(cursor, temporary)! + rebuild(false) or { + os.rename(temporary, cursor)! + return err + } + os.rename(temporary, cursor)! + rebuild(true)! +} + +fn main() { + check() or { + eprintln(err) + exit(1) + } + println('Vinix font index hook passed for installed, removed and restored bitmap fonts.') +} -- 2.56.1