summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2019-06-11 19:45:11 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2019-09-20 07:10:46 +0000
commit2b77347cd95dc12475fe2af8a715097166d0523a (patch)
tree28be17f67a1d6821fe33bd4cf4b5f8cb0da8a33a
parentf5700834e5d27ffa87ba2d9ec0fe5b4e38f5bb1c (diff)
downloadillumos-joyent-2b77347cd95dc12475fe2af8a715097166d0523a.tar.gz
11683 Automatically maintain whatis database
Reviewed by: Rich Lowe <richlowe@richlowe.net> Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/cmd/man/Makefile10
-rwxr-xr-xusr/src/cmd/man/update-man-index56
-rw-r--r--usr/src/cmd/man/update-man-index.xml81
-rw-r--r--usr/src/pkg/manifests/system-man.mf7
-rw-r--r--usr/src/pkg/transforms/restart_fmri17
5 files changed, 163 insertions, 8 deletions
diff --git a/usr/src/cmd/man/Makefile b/usr/src/cmd/man/Makefile
index 911bae6340..cd0b875049 100644
--- a/usr/src/cmd/man/Makefile
+++ b/usr/src/cmd/man/Makefile
@@ -12,16 +12,20 @@
#
# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
#
PROG= man
LINKS= apropos whatis catman
LIBLINKS = makewhatis
OBJS= makewhatis.o man.o stringlist.o
-SRCS= $(OBJS:%.o=%.c)
+MANIFEST= update-man-index.xml
+SVCMETHOD= update-man-index
include $(SRC)/cmd/Makefile.cmd
+ROOTMANIFESTDIR= $(ROOTSVCSYSTEM)
+
CFLAGS += $(CCVERBOSE)
ROOTLINKS= $(LINKS:%=$(ROOTBIN)/%) $(LIBLINKS:%=$(ROOTLIB)/%)
@@ -33,9 +37,9 @@ all: $(PROG)
clean:
$(RM) $(OBJS)
-install: all $(ROOTPROG) $(ROOTLINKS)
+install: all $(ROOTPROG) $(ROOTLINKS) $(ROOTMANIFEST) $(ROOTSVCMETHOD)
-lint: lint_SRCS
+check: $(CHKMANIFEST)
$(PROG): $(OBJS)
$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
diff --git a/usr/src/cmd/man/update-man-index b/usr/src/cmd/man/update-man-index
new file mode 100755
index 0000000000..c6c3dcaa63
--- /dev/null
+++ b/usr/src/cmd/man/update-man-index
@@ -0,0 +1,56 @@
+#!/bin/ksh
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
+#
+
+[ -f /lib/svc/share/smf_include.sh ] || exit 1
+
+. /lib/svc/share/smf_include.sh
+
+# Associative array to hold unique components for manpath
+typeset -A manpath
+
+default_system_path=
+if [ -f /etc/default/login ]; then
+ default_system_path="`grep '^PATH=' /etc/default/login | sed -n '
+ s/PATH=//
+ p
+ q
+ '`"
+fi
+
+oIFS="$IFS"; IFS=":"
+# The config/manpath property from the service will have been passed as
+# arguments to this method script.
+for p in $@; do
+ manpath["$p"]=1
+done
+
+# Add any additional man directories from the default system path
+for p in $default_system_path; do
+ dir="`dirname "$p"`"
+ for suffix in man share/man; do
+ [ -d "$dir/$suffix" ] && manpath["$dir/$suffix"]=1
+ done
+done
+IFS="$oIFS"
+
+MANPATH=
+for p in "${!manpath[@]}"; do
+ MANPATH+="${MANPATH:+:}$p"
+done
+
+echo "Rebuilding man page index using $MANPATH"
+export MANPATH
+/usr/bin/man -w
+
+exit 0
diff --git a/usr/src/cmd/man/update-man-index.xml b/usr/src/cmd/man/update-man-index.xml
new file mode 100644
index 0000000000..989e86275a
--- /dev/null
+++ b/usr/src/cmd/man/update-man-index.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<!--
+ This file and its contents are supplied under the terms of the
+ Common Development and Distribution License ("CDDL"), version 1.0.
+ You may only use this file in accordance with the terms of version
+ 1.0 of the CDDL.
+
+ A full copy of the text of the CDDL should have accompanied this
+ source. A copy of the CDDL is also available via the Internet at
+ http://www.illumos.org/license/CDDL.
+
+ Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
+-->
+
+<service_bundle type='manifest' name='system/man:update-man-index'>
+
+<service
+ name='system/update-man-index'
+ type='service'
+ version='1'>
+
+ <create_default_instance enabled='true' />
+
+ <single_instance/>
+
+ <dependency
+ name='fs-local'
+ grouping='require_all'
+ restart_on='none'
+ type='service'>
+ <service_fmri value='svc:/system/filesystem/local' />
+ </dependency>
+
+ <exec_method
+ type='method'
+ name='start'
+ exec='/lib/svc/method/update-man-index %{config/manpath:}'
+ timeout_seconds='300' />
+
+ <exec_method
+ type='method'
+ name='stop'
+ exec=':true'
+ timeout_seconds='3' />
+
+ <exec_method
+ type='method'
+ name='refresh'
+ exec=':true'
+ timeout_seconds='3' />
+
+ <property_group name='startd' type='framework'>
+ <propval name='duration' type='astring' value='transient' />
+ </property_group>
+
+ <property_group name='config' type='application'>
+ <property name='manpath' type='astring'>
+ <astring_list>
+ <value_node value='/usr/share/man' />
+ <value_node value='/usr/has/man' />
+ </astring_list>
+ </property>
+ </property_group>
+
+ <stability value='Unstable' />
+
+ <template>
+ <common_name>
+ <loctext xml:lang='C'>
+ Man page index database updater
+ </loctext>
+ </common_name>
+ <documentation>
+ <manpage title='man' section='1'
+ manpath='/usr/share/man' />
+ </documentation>
+ </template>
+</service>
+
+</service_bundle>
diff --git a/usr/src/pkg/manifests/system-man.mf b/usr/src/pkg/manifests/system-man.mf
index 31bccf54db..6b21bb432b 100644
--- a/usr/src/pkg/manifests/system-man.mf
+++ b/usr/src/pkg/manifests/system-man.mf
@@ -12,6 +12,7 @@
#
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
#
set name=pkg.fmri value=pkg:/system/man@$(PKGVERS)
@@ -21,12 +22,18 @@ set name=pkg.summary value="Reference Manual Pages Tools"
set name=info.classification \
value="org.opensolaris.category.2008:System/Text Tools"
set name=variant.arch value=$(ARCH)
+dir path=lib/svc
+dir path=lib/svc/manifest group=sys
+dir path=lib/svc/manifest/system group=sys
+dir path=lib/svc/method
dir path=usr/bin
dir path=usr/share
dir path=usr/share/man
dir path=usr/share/man/man1
dir path=usr/share/man/man1m
dir path=usr/share/man/man5
+file path=lib/svc/manifest/system/update-man-index.xml group=sys mode=0444
+file path=lib/svc/method/update-man-index mode=0555
file path=usr/bin/man mode=0555
file path=usr/bin/mandoc mode=0555
file path=usr/share/man/man1/apropos.1
diff --git a/usr/src/pkg/transforms/restart_fmri b/usr/src/pkg/transforms/restart_fmri
index 4e20486bc9..d58018cf7d 100644
--- a/usr/src/pkg/transforms/restart_fmri
+++ b/usr/src/pkg/transforms/restart_fmri
@@ -21,11 +21,18 @@
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
#
-<transform file path=var/svc/manifest/.*\.xml -> add restart_fmri svc:/system/manifest-import:default>
-<transform file path=lib/svc/manifest/.*\.xml -> add restart_fmri svc:/system/manifest-import:default>
-<transform file path=etc/security/[^/]+_attr.d/.+ -> add restart_fmri svc:/system/rbac:default>
-<transform file path=etc/user_attr.d/.+ -> add restart_fmri svc:/system/rbac:default>
+<transform file path=var/svc/manifest/.*\.xml -> \
+ add restart_fmri svc:/system/manifest-import:default>
+<transform file path=lib/svc/manifest/.*\.xml -> \
+ add restart_fmri svc:/system/manifest-import:default>
+<transform file path=etc/security/[^/]+_attr.d/.+ -> \
+ add restart_fmri svc:/system/rbac:default>
+<transform file path=etc/user_attr.d/.+ -> \
+ add restart_fmri svc:/system/rbac:default>
<transform file path=usr/share/applications/.*\.desktop -> \
- add restart_fmri svc:/application/desktop-cache/desktop-mime-cache:default>
+ add restart_fmri svc:/application/desktop-cache/desktop-mime-cache:default>
+<transform file link path=usr/(share|has)/man/.*\.\d[a-z]*$ -> \
+ add restart_fmri svc:/system/update-man-index:default>