summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2023-03-07 15:56:06 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-03-08 10:21:05 +0000
commitd42904ba0cf0eac28ef79b0e6015150d376d134d (patch)
tree8aae3cb11f85f487ca5ad093935596c5612a0231
parente0a6ba834eb1d985ce2726b746ed7014e9f19489 (diff)
downloadpoky-d42904ba0cf0eac28ef79b0e6015150d376d134d.tar.gz
manpages: use an intercept to run mandb
If you build an image with lots of manpages in, then each package will run mandb inside qemu-user at rootfs time. This is a slow operation and should be done once when all of the packages have installed using an intercept instead. The call to mandb has been changed too. mandb doesn't actually allow the configuration file to be read from stdin so that was being ignored, instead write the file to a temporary file and use that. This means we then don't need to tell it where to search explicitly, and it writes the indexes to the correct paths so we don't need to move files afterwards either. Sadly we do still need to run mandb inside qemu-user, as the underlying database is a gdbm file and they are byte-order dependent. For my test case of core-image-base with api-documentation DISTRO_FEATURES and doc-pkgs IMAGE_FEATURES enabled, the performance gain is significant: core-image-base do_rootfs -1303.1s -73.6% 1771.6s -> 468.5s (From OE-Core rev: fbd8a57aa307bfda70a08cb78af3c97f05c39a3a) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-recipe/manpages.bbclass12
-rw-r--r--scripts/postinst-intercepts/update_mandb16
2 files changed, 17 insertions, 11 deletions
diff --git a/meta/classes-recipe/manpages.bbclass b/meta/classes-recipe/manpages.bbclass
index 693fb53671..e9ca2f895b 100644
--- a/meta/classes-recipe/manpages.bbclass
+++ b/meta/classes-recipe/manpages.bbclass
@@ -23,17 +23,7 @@ pkg_postinst:${MAN_PKG}:append () {
23 if ${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'true', 'false', d)}; then 23 if ${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'true', 'false', d)}; then
24 if test -n "$D"; then 24 if test -n "$D"; then
25 if ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'true', 'false', d)}; then 25 if ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'true', 'false', d)}; then
26 sed "s:\(\s\)/:\1$D/:g" $D${sysconfdir}/man_db.conf | ${@qemu_run_binary(d, '$D', '${bindir}/mandb')} -C - -u -q $D${mandir} 26 $INTERCEPT_DIR/postinst_intercept update_mandb ${PKG} mlprefix=${MLPREFIX} binprefix=${MLPREFIX} bindir=${bindir} sysconfdir=${sysconfdir} mandir=${mandir}
27 chown -R root:root $D${mandir}
28
29 mkdir -p $D${localstatedir}/cache/man
30 cd $D${mandir}
31 find . -name index.db | while read index; do
32 mkdir -p $D${localstatedir}/cache/man/$(dirname ${index})
33 mv ${index} $D${localstatedir}/cache/man/${index}
34 chown man:man $D${localstatedir}/cache/man/${index}
35 done
36 cd -
37 else 27 else
38 $INTERCEPT_DIR/postinst_intercept delay_to_first_boot ${PKG} mlprefix=${MLPREFIX} 28 $INTERCEPT_DIR/postinst_intercept delay_to_first_boot ${PKG} mlprefix=${MLPREFIX}
39 fi 29 fi
diff --git a/scripts/postinst-intercepts/update_mandb b/scripts/postinst-intercepts/update_mandb
new file mode 100644
index 0000000000..a061bb426a
--- /dev/null
+++ b/scripts/postinst-intercepts/update_mandb
@@ -0,0 +1,16 @@
1#!/bin/sh
2#
3# SPDX-License-Identifier: MIT
4#
5
6set -eu
7
8# Create a temporary man_db.conf with paths to the rootfs, as mandb needs absolute paths
9CONFIG=$(mktemp --tmpdir update-mandb.XXXXX)
10sed "s:\(\s\)/:\1$D/:g" $D${sysconfdir}/man_db.conf > $CONFIG
11
12PSEUDO_UNLOAD=1 ${binprefix}qemuwrapper -L $D $D${bindir}/mandb --config-file $CONFIG --create
13
14rm -f $CONFIG
15
16chown -R man:man $D${localstatedir}/cache/man/