[Slackbuilds-users] RFC: Proposed mandb additions to doinst/douninst template
Arkadiusz Drabczyk
arkadiusz at drabczyk.org
Sat Sep 7 17:27:34 UTC 2024
On Sun, Aug 25, 2024 at 01:42:11PM -0400, B. Watson wrote:
>
>
> On Sun, 25 Aug 2024, Arkadiusz Drabczyk wrote:
>
> > > ### in doinst.sh:
> > > # DESCRIPTION: Updates the man database (for "man -k").
> > > # Use one "man -f" command for each man page in the package.
> > > if [ -x usr/bin/mandb ]; then
> > > usr/bin/mandb -f usr/man/man1/program.1.gz
> > > fi
> >
> > so there is no easier way than to run mandb for each manpage
> > separately?
>
> No easier way that I've found yet.
>
> Well, "mandb -c" in doinst.sh would be easier, but it takes too long
> to run on Slackware 15.0.
Out of curiosity I checked how Debian is managing manpages because I
remember "Processing triggers for man-db" being printed every time a
package is installed and I verified that man -k works immediately
after the package is installed:
ja at debian:~$ man -k offlineimap
offlineimap: nothing appropriate.
ja at debian:~$ sudo apt-get -y install offlineimap3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
python3-gssapi
The following NEW packages will be installed:
offlineimap3
0 upgraded, 1 newly installed, 0 to remove and 64 not upgraded.
Need to get 0 B/155 kB of archives.
After this operation, 636 kB of additional disk space will be used.
Selecting previously unselected package offlineimap3.
(Reading database ... 158999 files and directories currently installed.)
Preparing to unpack .../offlineimap3_0.0~git20211018.e64c254+dfsg-2_all.deb ...
Unpacking offlineimap3 (0.0~git20211018.e64c254+dfsg-2) ...
Setting up offlineimap3 (0.0~git20211018.e64c254+dfsg-2) ...
Processing triggers for man-db (2.11.2-2) ...
ja at debian:~$ man -k offlineimap
offlineimap (1) - Synchronize mailboxes and Maildirs both ways or one either way.
offlineimapui (7) - The User Interfaces
To my surprise mandb is run only with -pq parameters in
/var/lib/dpkg/info/man-db.postinst. Refreshing man database can work
like that only because dpkg does not change the mtime of existing
directories by not extracting directories that already exist on the
filesystem
https://salsa.debian.org/dpkg-team/dpkg/-/blob/main/src/main/archives.c?ref_type=heads#L954. If
that check didn't exist mtime of /usr/share/man/man1 would change to
time saved in the tarball inside .deb as it happens on Slackware, for
example 2023-01-10:
ja at debian:~$ apt-get -y download offlineimap3
Get:1 http://deb.debian.org/debian bookworm/main amd64 offlineimap3 all 0.0~git20211018.e64c254+dfsg-2 [155 kB]
Fetched 155 kB in 0s (980 kB/s)
ja at debian:~$ ar x offlineimap3_0.0~git20211018.e64c254+dfsg-2_all.deb
ja at debian:~$ tar tvf data.tar.xz | grep usr/share/man/man1/$
drwxr-xr-x root/root 0 2023-01-10 16:44 ./usr/share/man/man1/
But with the check in place it doesn't - to make sure that tests make
sense remove /var/lib/man-db/auto-update to prevent
/var/lib/dpkg/info/man-db.postinst from running:
ja at debian:~$ sudo rm /var/lib/man-db/auto-update
ja at debian:~$ ls --full-time -hld /usr/share/man/man1
drwxr-xr-x 2 root root 68K 2024-09-07 12:38:34.370247176 -0400 /usr/share/man/man1
ja at debian:~$ sudo apt-get -y install offlineimap3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
python3-gssapi
The following NEW packages will be installed:
offlineimap3
0 upgraded, 1 newly installed, 0 to remove and 64 not upgraded.
Need to get 0 B/155 kB of archives.
After this operation, 636 kB of additional disk space will be used.
Selecting previously unselected package offlineimap3.
(Reading database ... 158999 files and directories currently installed.)
Preparing to unpack .../offlineimap3_0.0~git20211018.e64c254+dfsg-2_all.deb ...
Unpacking offlineimap3 (0.0~git20211018.e64c254+dfsg-2) ...
Setting up offlineimap3 (0.0~git20211018.e64c254+dfsg-2) ...
Processing triggers for man-db (2.11.2-2) ...
Not building database; man-db/auto-update is not 'true'.
ja at debian:~$ ls --full-time -hld /usr/share/man/man1
drwxr-xr-x 2 root root 68K 2024-09-07 12:38:42.478004504 -0400 /usr/share/man/man1
As we see mtime of /usr/share/man/man1 didn't go back to 2023-01-10.
But there is still an issue here as man -k lists manpages even after
package has been removed due to -p option used with mandb:
ja at debian:~$ sudo touch /var/lib/man-db/auto-update
ja at debian:~$ sudo apt-get -y remove offlineimap3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
python3-imaplib2
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
offlineimap3
0 upgraded, 0 newly installed, 1 to remove and 64 not upgraded.
After this operation, 636 kB disk space will be freed.
(Reading database ... 159069 files and directories currently installed.)
Removing offlineimap3 (0.0~git20211018.e64c254+dfsg-2) ...
Processing triggers for man-db (2.11.2-2) ...
ja at debian:~$ man -k offlineimap
offlineimap (1) - Synchronize mailboxes and Maildirs both ways or one either way.
offlineimapui (7) - The User Interfaces
Apparently it's a known issue
https://bugs-devel.debian.org/cgi-bin/bugreport.cgi?bug=539221#10. So
if man database was refreshed on package removal Slackware would be
better than Debian :D.
Coming back to the proposal, since running mandb with each manpage is
the only viable option to achieve the goal on Slackware (apart from
rolling our custom tar extractor as Debian developers did) could we
have something that could automate creating the doinst.sh? For
example, sbopkglint could try finding all manpages in the package and
suggest a bunch of lines that could be pasted verbatim into
doinst.sh. I find the current method very daunting as I said in my
previous e-mail. We could use system/openGLRefToMan to test the new
approach as its install script already calls mandb -c and installs a
lot of manpages.
--
Arkadiusz Drabczyk <arkadiusz at drabczyk.org>
More information about the SlackBuilds-users
mailing list