1#
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				$INTERCEPT_DIR/postinst_intercept update_mandb ${PKG} mlprefix=${MLPREFIX} binprefix=${MLPREFIX} bindir=${bindir} sysconfdir=${sysconfdir} mandir=${mandir}
27			else
28				$INTERCEPT_DIR/postinst_intercept delay_to_first_boot ${PKG} mlprefix=${MLPREFIX}
29			fi
30		else
31			mandb -q
32		fi
33	fi
34}
35
36pkg_postrm:${MAN_PKG}:append () {
37	# only update manual page index caches when manual files are built and installed
38	if ${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'true', 'false', d)}; then
39		mandb -q
40	fi
41}
42