me

/

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

mkfontscale: own the bitmap index and verify its hook in Vinix

diviocity committed 5 days ago · 51967741cbe805f0acfde1ff543d4fdcbd767b72 View patch
Unverified signature 3 files changed +59 -2
mkfontscale/PKGBUILD.vile +8 -2

@@ -1,7 +1,7 @@

11defpkgbuild(mkfontscale,

22 #:pkgname, "mkfontscale",

33 #:pkgver, "1.2.3",

4- #:pkgrel, 1,

4+ #:pkgrel, 2,

55 #:pkgdesc, "Scalable font index generator for X",

66 #:arch, [#:x86-64, #:aarch64],

77 #:license, "MIT",

@@ -11,7 +11,7 @@ defpkgbuild(mkfontscale,

1111 #:source, ["https://xorg.freedesktop.org/archive/individual/app/mkfontscale-1.2.3.tar.xz", "update-x11-misc-fonts.hook"],

1212 #:sha256sums, [

1313 "2921cdc344f1acee04bcd6ea1e29565c1308263006e134a9ee38cf9c9d6fe75e",

14- "3d34e8785692b8df97e86c539004f4fb45bebd0239535bb3e52999cf3aea56ac"

14+ "0ae9b28e5c63ef460ab4c847b81b36610eb0935df3b333f1f8a3f2d2d3af53e4"

1515 ],

1616

1717 #:build, fn() {

@@ -23,6 +23,12 @@ defpkgbuild(mkfontscale,

2323 },

2424 #:package, fn() {

2525 run("make", "install", string-append("DESTDIR=", pkgdir()))

26+ ; Own the live index even when no bitmap fonts are installed. The hook

27+ ; rebuilds it on font changes and after this package replaces the index.

28+ fonts := string-append(pkgdir(), "/usr/share/fonts/X11/misc")

29+ run("mkdir", "-p", fonts)

30+ run("vinix-run", "./mkfontscale", "-b", "-s", "-l", fonts)

31+ run("grep", "-Fx", "0", string-append(fonts, "/fonts.dir"))

2632 run("install", "-Dm644", "update-x11-misc-fonts.hook",

2733 string-append(pkgdir(), "/usr/share/libalpm/hooks/60-update-x11-misc-fonts.hook"))

2834 run("install", "-Dm644", "mkfontscale-1.2.3/COPYING",

mkfontscale/update-x11-misc-fonts.hook +1 -0

@@ -4,6 +4,7 @@ Operation = Upgrade

44Operation = Remove

55Type = Path

66Target = usr/share/fonts/X11/misc/*.pcf.gz

7+Target = usr/share/fonts/X11/misc/fonts.dir

78

89[Action]

910Description = Updating the X11 bitmap font directory

tests/x11/font-index.v new file +50 -0

@@ -0,0 +1,50 @@

1+// Run in the diskless guest with both X11 bitmap font packages installed.

2+module main

3+

4+import os

5+

6+const font_dir = '/usr/share/fonts/X11/misc'

7+

8+fn rebuild(expect_cursor bool) ! {

9+ hook := '/usr/share/libalpm/hooks/60-update-x11-misc-fonts.hook'

10+ commands := os.read_lines(hook)!.filter(it.starts_with('Exec = '))

11+ if commands.len != 1 {

12+ return error('expected one Exec action in ${hook}')

13+ }

14+ result := os.exec(commands[0].all_after('Exec = ').split(' '))

15+ if result.exit_code != 0 {

16+ return error('font index hook exited ${result.exit_code}: ${result.output}')

17+ }

18+ lines := os.read_lines(os.join_path(font_dir, 'fonts.dir'))!

19+ if lines.len < 2 || lines[0].int() != lines.len - 1

20+ || lines.any(it.starts_with('cursor.pcf.gz ')) != expect_cursor

21+ || !lines.any(it.to_lower().starts_with('6x13.pcf.gz -misc-fixed-')) {

22+ return error('font index has an incorrect count or bitmap font entries')

23+ }

24+}

25+

26+fn check() ! {

27+ rebuild(true)!

28+ cursor := os.join_path(font_dir, 'cursor.pcf.gz')

29+ directory := os.join_path(font_dir, '.vinix-test-${os.getpid()}')

30+ os.mkdir(directory)!

31+ defer {

32+ os.rmdir(directory) or { eprintln(err) }

33+ }

34+ temporary := os.join_path(directory, 'cursor.pcf.gz')

35+ os.rename(cursor, temporary)!

36+ rebuild(false) or {

37+ os.rename(temporary, cursor)!

38+ return err

39+ }

40+ os.rename(temporary, cursor)!

41+ rebuild(true)!

42+}

43+

44+fn main() {

45+ check() or {

46+ eprintln(err)

47+ exit(1)

48+ }

49+ println('Vinix font index hook passed for installed, removed and restored bitmap fonts.')

50+}