Subject: [alpine-aports] [PATCH] main/mdocml: use a cron instead of a trigger to invoke makewhatis(8)

From: Sören Tempel <[email-masked]>
Date: Mon, 10 Aug 2015 22:19:34 +0200

The database created by makewhatis(8) doesn't need to be up to date all
the time, it is not critical at all when the database doesn't contain a
newly added manpage for a few hours. So instead of slowing down package
installation by using a trigger the makewhatis(8) database is now
created and updated using a daily cron. The daily cron is run once after
the first install of mdocml as well.

Many distribution (e.g. Gentoo) also use a cron instead of a trigger to
invoke makewhatis(8), in my opinion it is simply saner to it this way.
---
 main/mdocml/APKBUILD            | 18 +++++++++++-------
 main/mdocml/mdocml.cron         |  4 ++++
 main/mdocml/mdocml.post-install |  1 +
 main/mdocml/mdocml.trigger      |  4 ----
 4 files changed, 16 insertions(+), 11 deletions(-)
 create mode 100644 main/mdocml/mdocml.cron
 create mode 120000 main/mdocml/mdocml.post-install
 delete mode 100644 main/mdocml/mdocml.trigger

diff --git a/main/mdocml/APKBUILD b/main/mdocml/APKBUILD
index 278c71f..e912f10 100644
--- a/main/mdocml/APKBUILD
+++ b/main/mdocml/APKBUILD
@@ -1,21 +1,20 @@
 # Maintainer:  Natanael Copa <[email-masked]>
 pkgname=mdocml
 pkgver=1.13.3
-pkgrel=4
+pkgrel=5
 pkgdesc="mdoc/man compiler"
 url="http://mdocml.bsd.lv/"
 arch="all"
 license="BSD"
 depends=
 makedepends="sqlite-dev"
-install="$pkgname.post-deinstall"
-triggers="$pkgname.trigger=/usr/share/man/*"
+install="$pkgname.post-install $pkgname.post-deinstall"
 subpackages="$pkgname-doc $pkgname-dev man"
 source="http://mdocml.bsd.lv/snapshots/mdocml-$pkgver.tar.gz
 	shared-libmandoc.patch
 	mdocml.post-deinstall
 	default-pager.patch
-	mdocml.trigger
+	mdocml.cron
 	man.conf
 	"
 
@@ -23,11 +22,14 @@ _builddir="$srcdir"/$pkgname-$pkgver
 
 prepare() {
 	cd "$_builddir"
+
+	local i=
 	for i in $source; do
 		case $i in
 		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
 		esac
 	done
+
 	cat >configure.local<<EOF
 PREFIX=/usr
 MANDIR=/usr/share/man
@@ -46,6 +48,8 @@ package() {
 	cd "$_builddir"
 	make -j1 DESTDIR="$pkgdir" base-install db-install || return 1
 	install -Dm644 "$srcdir"/man.conf "$pkgdir"/etc/man.conf || return 1
+	install -Dm755 "$srcdir"/${pkgname}.cron \
+		"$pkgdir"/etc/periodic/daily/makewhatis || return 1
 }
 
 man() {
@@ -59,17 +63,17 @@ md5sums="7be80e1116a11abe2aabd6b2f04434ef  mdocml-1.13.3.tar.gz
 8d130a332fbd3268550819ade96c9afd  shared-libmandoc.patch
 f369b00f82b5cb03477cbea363dc3c65  mdocml.post-deinstall
 aa3421f2d2da345a7514be51707d6829  default-pager.patch
-f8cf8d023cded16f33eedc2cee7261fe  mdocml.trigger
+f8cf8d023cded16f33eedc2cee7261fe  mdocml.cron
 6e893bef0cf680eec807b230e6619d27  man.conf"
 sha256sums="23ccab4800d50bf4c327979af5d4aa1a6a2dc490789cb67c4c3ac1bd40b8cad8  mdocml-1.13.3.tar.gz
 676dd35caedc759cc83ae1dbf7fde5709d6fe4ed14c652af4cbebc5ccdbdc71b  shared-libmandoc.patch
 c57b5009009fdb4e8585166b2df404ed41e4caf3cbcbc0bf1d8bf2669637f68c  mdocml.post-deinstall
 f0a393ff3a630cd0e9e412241890b2356153ffb4ef0d419a7979edc4ed5e57e3  default-pager.patch
-30895170f89dfcf3ffa10ba5ec3140639ce0a64f06bf4c89050f8f80fea60bd8  mdocml.trigger
+30895170f89dfcf3ffa10ba5ec3140639ce0a64f06bf4c89050f8f80fea60bd8  mdocml.cron
 3381c6ceb99e7db1404fdb44419040c3b441a251d594292e53545b5e4e378e2b  man.conf"
 sha512sums="a3b7304e313b905b3575d79eb7ac861723e0ef3f700199c136abe4d4c698929e99ee0789bfc6e591224fb0006c709afe0e4c1bb578605a767c371ec7dee26024  mdocml-1.13.3.tar.gz
 bdbe471bcc5d5009ee8a9c4fb2f7903a5114afd8da1d6807c462fefdbe4b508711386b0fe7febb92977f97751c1d4fd486f1e1ecae0b7c1ba4dc28c0a7dda0b6  shared-libmandoc.patch
 c677c1b3d3705dfa130d69056a2a4c694802f51d881d0b48d8b280d87a882e0a5b906273840510af439b0c7f08da5d8d99b3f2cba396cf1781633dcb044bf4d9  mdocml.post-deinstall
 c8a4a11a5aa166670d8f8d4e0dba803068d3f1b6aee483daaf889da661a9281387fcd2f00d2dad7ef5c66e3419df205e2c75bb58fb9b055db284b4ac2f23eb7e  default-pager.patch
-e553cf83dde0a7926326acf306f7b363d0218009e328af82abb5256292c8693d341b85d3490c1ac33fbf3ac37f58f059926b1a9e790e24e7e0a85ca44f1fa126  mdocml.trigger
+e553cf83dde0a7926326acf306f7b363d0218009e328af82abb5256292c8693d341b85d3490c1ac33fbf3ac37f58f059926b1a9e790e24e7e0a85ca44f1fa126  mdocml.cron
 0723c32ab70e5b1c77768ca78d7437b26bed19b90b27876b10cc463359c41332befc0105fc1e23ceae48de5a892f1aa7ac60ef7eb0b6b8f1616726c4300632fe  man.conf"
diff --git a/main/mdocml/mdocml.cron b/main/mdocml/mdocml.cron
new file mode 100644
index 0000000..b1060c4
--- /dev/null
+++ b/main/mdocml/mdocml.cron
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+exec /usr/sbin/makewhatis \
+	-a -T utf8 /usr/share/man
diff --git a/main/mdocml/mdocml.post-install b/main/mdocml/mdocml.post-install
new file mode 120000
index 0000000..76d799b
--- /dev/null
+++ b/main/mdocml/mdocml.post-install
@@ -0,0 +1 @@
+mdocml.cron
\ No newline at end of file
diff --git a/main/mdocml/mdocml.trigger b/main/mdocml/mdocml.trigger
deleted file mode 100644
index b1060c4..0000000
--- a/main/mdocml/mdocml.trigger
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-exec /usr/sbin/makewhatis \
-	-a -T utf8 /usr/share/man
-- 
2.5.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Wed, 12 Aug 2015 11:01:54 +0200

On Mon, 10 Aug 2015 22:19:34 +0200

> invoke makewhatis(8), in my opinion it is simply saner to it this way.

I am not sure I like this. How much does it slow things down? are we
talking about 1-2 seconds or 2 minutes?

The way i think, the index is only needed to be created once, not every
night.

If you can wait til tomorrow for using it, then you will most likely
not need it at all.

so i wonder if we should simply move makewhatis and db and all to a
subpackage and have the trigger there.

That way you could have man pages without the whatis index.

---

---

From: Sören Tempel <[email-masked]>
Date: Wed, 12 Aug 2015 14:31:56 +0200

> talking about 1-2 seconds or 2 minutes?

I have 10488 man pages installed:

	$ find /usr/share/man -type f | wc -l

This is the output of 'time apk add mdocml-doc' with this patch:

(1/1) Installing mdocml-doc (1.13.3-r5)
OK: 819 MiB in 314 packages
    0m0.44s real     0m0.00s user     0m0.00s system

This is the output of 'time apk add mdocml-doc' without this patch:

(1/1) Installing mdocml-doc (1.13.3-r5)
Executing mdocml-1.13.3-r4.trigger
OK: 818 MiB in 314 packages
    0m37.73s real     0m0.00s user     0m0.00s system

> The way i think, the index is only needed to be created once, not every

If a new man page gets added to /usr/share/man the index needs to be
rebuild so it is a good idea to invoke makewhatis(8) automatically in a
certain interval. I think invoking it every night is a good interval.

> If you can wait til tomorrow for using it, then you will most likely

That's not true at all. The index is created on install already, it's
only updated at night.

> subpackage and have the trigger there.

I kind of dislike that idea since it doesn't solve the problem that it
takes ages to install packages containing manpages than.

Sören.

---

---

From: Natanael Copa <[email-masked]>
Date: Wed, 12 Aug 2015 15:05:43 +0200

On Wed, 12 Aug 2015 14:31:56 +0200

> I have 10488 man pages installed:
...
>     0m37.73s real     0m0.00s user     0m0.00s system

ok, 38 sec is not acceptable.

> certain interval. I think invoking it every night is a good interval.

But you only add things to /usr/share/man when you apk add?

> That's not true at all. The index is created on install already, it's

How is it created on install if there are no trigger?

> takes ages to install packages containing manpages than.

You can use man pages without mandoc.db since mdocml-1.13.3.

From http://mdocml.bsd.lv/NEWS:
> Changes in version 1.13.3, released on March 13, 2015
...
> * Use this to always provide man(1), even without database support.

Pages are showed perfectly fine, but you do get a warning on exit:

ncdev-edge-x86_64:~/aports/main/mdocml$ sudo apk add man-pages
(1/1) Installing man-pages (4.02-r0)
Executing mdocml-1.13.3-r4.trigger
OK: 435 MiB in 134 packages
ncdev-edge-x86_64:~/aports/main/mdocml$ man 2 read
ncdev-edge-x86_64:~/aports/main/mdocml$ sudo rm /usr/share/man/mandoc.db 
ncdev-edge-x86_64:~/aports/main/mdocml$ man 2 read
/usr/share/man/mandoc.db: No such file or directory
man: outdated mandoc.db lacks read(2) entry,
     consider running  # makewhatis /usr/share/man

Other option would be to run it in background:

    /usr/sbin/makewhatis -a -T utf8 /usr/share/man &

-nc

---

---

From: Lennart Jablonka <[email-masked]>
Date: Tue, 27 Dec 2022 22:39:37 +0000

Quoth Sören Tempel, 2015-08-10T22:19:34:
>The database created by makewhatis(8) doesn't need to be up to date 
>all the time, it is not critical at all when the database doesn't 
>contain a newly added manpage for a few hours. So instead of slowing 
>down package installation by using a trigger the makewhatis(8) 
>database is now created and updated using a daily cron. The daily cron 
>is run once after the first install of mdocml as well.

+1