xref: /OK3568_Linux_fs/yocto/poky/meta/classes/manpages.bbclass (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# Inherit this class to enable or disable building and installation of manpages
2*4882a593Smuzhiyun# depending on whether 'api-documentation' is in DISTRO_FEATURES. Such building
3*4882a593Smuzhiyun# tends to pull in the entire XML stack and other tools, so it's not enabled
4*4882a593Smuzhiyun# by default.
5*4882a593SmuzhiyunPACKAGECONFIG:append:class-target = " ${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', 'manpages', '', d)}"
6*4882a593Smuzhiyun
7*4882a593Smuzhiyuninherit qemu
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun# usually manual files are packaged to ${PN}-doc except man-pages
10*4882a593SmuzhiyunMAN_PKG ?= "${PN}-doc"
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun# only add man-db to RDEPENDS when manual files are built and installed
13*4882a593SmuzhiyunRDEPENDS:${MAN_PKG} += "${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'man-db', '', d)}"
14*4882a593Smuzhiyun
15*4882a593Smuzhiyunpkg_postinst:${MAN_PKG}:append () {
16*4882a593Smuzhiyun	# only update manual page index caches when manual files are built and installed
17*4882a593Smuzhiyun	if ${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'true', 'false', d)}; then
18*4882a593Smuzhiyun		if test -n "$D"; then
19*4882a593Smuzhiyun			if ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'true', 'false', d)}; then
20*4882a593Smuzhiyun				sed "s:\(\s\)/:\1$D/:g" $D${sysconfdir}/man_db.conf | ${@qemu_run_binary(d, '$D', '${bindir}/mandb')} -C - -u -q $D${mandir}
21*4882a593Smuzhiyun				chown -R root:root $D${mandir}
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun				mkdir -p $D${localstatedir}/cache/man
24*4882a593Smuzhiyun				cd $D${mandir}
25*4882a593Smuzhiyun				find . -name index.db | while read index; do
26*4882a593Smuzhiyun					mkdir -p $D${localstatedir}/cache/man/$(dirname ${index})
27*4882a593Smuzhiyun					mv ${index} $D${localstatedir}/cache/man/${index}
28*4882a593Smuzhiyun					chown man:man $D${localstatedir}/cache/man/${index}
29*4882a593Smuzhiyun				done
30*4882a593Smuzhiyun				cd -
31*4882a593Smuzhiyun			else
32*4882a593Smuzhiyun				$INTERCEPT_DIR/postinst_intercept delay_to_first_boot ${PKG} mlprefix=${MLPREFIX}
33*4882a593Smuzhiyun			fi
34*4882a593Smuzhiyun		else
35*4882a593Smuzhiyun			mandb -q
36*4882a593Smuzhiyun		fi
37*4882a593Smuzhiyun	fi
38*4882a593Smuzhiyun}
39*4882a593Smuzhiyun
40*4882a593Smuzhiyunpkg_postrm:${MAN_PKG}:append () {
41*4882a593Smuzhiyun	# only update manual page index caches when manual files are built and installed
42*4882a593Smuzhiyun	if ${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'true', 'false', d)}; then
43*4882a593Smuzhiyun		mandb -q
44*4882a593Smuzhiyun	fi
45*4882a593Smuzhiyun}
46