Music Player Daemon Community Wiki

Patching man-db to make symlinked man files first-class

525pages on
this wiki
Add New Page
Add New Page Talk0

The instructions given on building MPD suggest to use stow to keep track of the locally-built version.

One downside of this strategy, at least on some systems, is that if you have both locally- and distro-built versions of mpd or mpc, you will get the manpage for the distro-built version rather than the locally-built version.

This is because stow makes a symlink for these manpages from the /usr/local/share/man/man1 directory into the stow directory structure, and because man-db considers symlinks to be derivative manpages.  Man expects to find the original of the symlinked file, but doesn't, because stow doesn't add its directory structure to the system manpath.

After checking all of the potential candidates for the mpd or mpc manpage, man determines that because the distro-built manpages for those programs are bona fide source rather than symlinks, they should be presented.

The developers of man-db have made it quite easy to patch it such that it considers symlinks to manpages to be essentially the same as the files they link to, and thus avoids causing this problem.  The patch itself is trivial:

--- src/man.c.original    2009-10-06 20:15:33.000000000 -0300
+++ src/man.c    2009-10-06 20:15:41.000000000 -0300
@@ -209,7 +209,7 @@ static int local_man_file;
 static int findall;
 static int update;
 static int match_case;
-static int ult_flags = SO_LINK | SOFT_LINK | HARD_LINK;
+static int ult_flags = SO_LINK | HARD_LINK;
 static const char *recode = NULL;
 static int ascii;        /* insert tr in the output pipe */

Ubuntu/Debian instructions Edit

To get a patched version of man-db running on your system, these instructions may help.  I haven't tried this on a debian install, but I think in theory it should be the same deal.

If you haven't already, install the basic toolset needed to compile and build packages:

$ sudo aptitude -r install build-essential devscripts

Next you need to install the development packages that man-db depends on:

$ sudo aptitude -r build-dep man-db

To download the actual source code for man-db, change into a new (empty) directory and do

$ apt-get source man-db

Change directory into whatever subdirectory was created.  On my system (Ubuntu 8.10) it's called man-db-2.5.2

$ cd man-db-2.5.2

Now apply the patch:

$ cat $whatever_you_named_the_patch | patch -p0

For convenience and/or niftiness, those with xclip installed (aptitude install xclip) can do this last by selecting the above patch text right in the browser, switching to the terminal window, and doing

$ xclip -o | patch -p0

Now you make a note of why you're doing this:

$ dch --local softlinks "symbolic links to manpages are considered equivalent to the manpages they link to"

Next build the .deb package:

$ debuild -us -uc

And finally you're ready to install your customized version of man-db.  The name of the package will be different if you're running a different distro or you've travelled far enough forward in time from the present:

$ sudo dpkg -i ../man-db_2.5.2-2ubuntu1_amd64.deb

At this point, if you had problems viewing the up-to-date manpage because it was stowed away in a symlink, you should see an end to those problems.  Try

$ man -w mpd

to see where man thinks the mpd manpage is at.  The response should have the word 'local' in there somewhere.

That's pretty much it.  I'm not sure if aptitude/synaptic/etc will hold back on updating this version of man-db, so you may end up having to do this again somewhat unexpectedly.  There is a facility in aptitude for manually holding back packages from updating, which may be of use if you're concerned about this situation reverting at some future date for reasons you don't immediately understand.

Also on Fandom

Random Wiki