[Slackbuilds-users] always run `mandb -c` after installing/removing manpages?

B. Watson urchlay at slackware.uk
Sun Aug 11 21:52:29 UTC 2024



On Sun, 11 Aug 2024, Arkadiusz Drabczyk wrote:

> In most packages manual page index caches are not updated which leads
> to the following situation:
>
> $ man -k zathura
> zathura: nothing appropriate.
>
> man -k can find the manpages only when caches are updated:
>
> $ sudo mandb -c
> $ man -k zathura
> zathura (1)          - a document viewer
> zathurarc (5)        - zathura configuration file
>
> Unfortunately it takes some time, for example 10 seconds on my system.

It takes a lot longer than 10 seconds on my system... long enough that
users would be highly annoyed if they had to wait for it to finish
every time they install or remove a package (and wait for it *twice*
when doing upgradepkg, since it does both installpkg and removepkg).

I just ran your command (sudo mandb -c) and it took 9 minutes and 25
seconds. And that's on a machine that uses a pretty fast SSD. Hate to
think how long it would take with a spinning-platter hard disk.

Actually... are you sure your "10 seconds" figure is based on running
with the -c option? Try "time mandb -c", as root.

> sbopkglint already has 60-usr_info.t.sh, should a similar error
> regarding manpages also be addded?

I think the overhead of constantly regenerating the man database is
just too high. Users who never even use "man -k" would be forced to
pay the penalty for it.

> I know there is /etc/cron.daily/man-db but the command specified there
> does not traverse /usr/man/man1/ where zathura manpages are located
> for some reason:
>
> $ man -w zathura
> /usr/man/man1/zathura.1.gz

Looking at it... the main difference is that your command has "-c",
and the cron job doesn't. -c means "create database from scratch"
instead of updating it if it already exists. Leaving off the -c makes
it run much faster.

However, it appears that leaving off the -c also prevents mandb from
adding the zathura man page to its database. I wonder if this is the
intended behaviour, or if it might be considered a bug in mandb.

The flip side of the coin: After "removepkg zathura", it still shows
up in the man database. Doing "mandb" without the -c does remove it,
and takes about 8 seconds. Behold:

---------------
<root at xiphos:~># man -k zathura
zathura (1)          - a document viewer
zathurarc (5)        - zathura configuration file
<root at xiphos:~># removepkg zathura &> /dev/null
<root at xiphos:~># man -k zathura
zathura (1)          - a document viewer
zathurarc (5)        - zathura configuration file
<root at xiphos:~># time mandb &>/dev/null

real	0m7.254s
user	0m5.198s
sys	0m5.093s
<root at xiphos:~># man -k zathura
zathura: nothing appropriate.
---------------

So it might be considered OK to run mandb (without -c) in a
douninst.sh script. I hate to make it a hard requirement though.

For the doinst.sh, here's a thing: The mandb command has a -f option
that makes it add a single man page to the database. It runs quickly
(less than 1 second), and seems to work fine. Right after installing
the zathura package:

---------------
<root at xiphos:~># man -k zathura
zathura: nothing appropriate.
<root at xiphos:~># mandb -f /usr/man/man1/zathura.1.gz 
mandb: warning: $MANPATH set, inserting /etc/man_db.conf
Processing manual pages under /usr/man...
1 man subdirectory contained newer manual pages.
1 manual page was added.
<root at xiphos:~># mandb -f /usr/man/man5/zathurarc.5.gz 
mandb: warning: $MANPATH set, inserting /etc/man_db.conf
Processing manual pages under /usr/man...
1 man subdirectory contained newer manual pages.
1 manual page was added.
<root at xiphos:~># man -k zathura
zathura (1)          - a document viewer
zathurarc (5)        - zathura configuration file
---------------

So... for doinst.sh, it would make sense to have a "mandb -f" command
for each man page in the package.

Unfortunately the -f option doesn't help with removing entries from
the database. "mandb -c" is the only way I've found to do that, and it
takes forever.

We may add "mandb -f" to our doinst.sh template. If I add a check for
it to sbopkglint, it will be a "note" (not an error or a warning),
since we have thousands of existing SlackBuilds that will fail the
check. Each one would have to be updated (a doinst.sh added, or the
existing one modified), to make it lint-compliant, if it were an error
or warning.

None of this is set in stone. Discussion is welcome.


More information about the SlackBuilds-users mailing list