blob: 693fb5367144a11f9e5a6fb39f31c0065a0820d7 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7# Inherit this class to enable or disable building and installation of manpages
8# depending on whether 'api-documentation' is in DISTRO_FEATURES. Such building
9# tends to pull in the entire XML stack and other tools, so it's not enabled
10# by default.
11PACKAGECONFIG:append:class-target = " ${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', 'manpages', '', d)}"
12
13inherit qemu
14
15# usually manual files are packaged to ${PN}-doc except man-pages
16MAN_PKG ?= "${PN}-doc"
17
18# only add man-db to RDEPENDS when manual files are built and installed
19RDEPENDS:${MAN_PKG} += "${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'man-db', '', d)}"
20
21pkg_postinst:${MAN_PKG}:append () {
22 # only update manual page index caches when manual files are built and installed
23 if ${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'true', 'false', d)}; then
24 if test -n "$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}
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
38 $INTERCEPT_DIR/postinst_intercept delay_to_first_boot ${PKG} mlprefix=${MLPREFIX}
39 fi
40 else
41 mandb -q
42 fi
43 fi
44}
45
46pkg_postrm:${MAN_PKG}:append () {
47 # only update manual page index caches when manual files are built and installed
48 if ${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'true', 'false', d)}; then
49 mandb -q
50 fi
51}