/usr/share/man-db/chconfig is in man-db 2.6.1-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | #! /usr/bin/perl -w
# chconfig
# Copyright (C) 1999 Fabrizio Polacco <fpolacco@prosa.it>
#
# This file is part of man-db.
#
# man-db is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# man-db is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with man-db; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# tool to convert the man-db configuration file to the FHS.
# it slurps the file in argument (default /etc/manpath.config) and,
# unless exists in it a single line containing the keyword
# NOFHS
# it tries to make the changes to comply with FHS.
push @ARGV, "/etc/manpath.config" unless @ARGV;
print " Upgrading $ARGV[0]\n";
my $myum = 0;
my $myusm = 0;
my $mh = 0;
my $mhug = 0;
my $mhob = 0;
my $mhos = 0;
my $mbusm = 0;
my $mbom = 0;
push @IN, " # config file rewritten by tool chconfig\n";
while (<>) {
warn " Respecting NOFHS directive.\n" and exit 0
if m,^\s*NOFHS\s*$,i;
warn " Configuration file already processed.\n" and exit 0
if m/$IN[0]/;
push @IN, $_;
# first section
$myum = $#IN if m,^MANDATORY_MANPATH\s+/usr/man\s*$, ;
$myusm = $#IN if m,^MANDATORY_MANPATH\s+/usr/share/man\s*$, ;
# second section
$mhug = $#IN if m,^MANPATH_MAP\s+/usr/games\s+, ;
$mhob = $#IN if m,^MANPATH_MAP\s+/opt/bin\s+, ;
$mhos = $#IN if m,^MANPATH_MAP\s+/opt/sbin\s+, ;
$mh = $#IN if m,^MANPATH_MAP\s+, ;
# third section
if ( m,^MANDB_MAP\s+(/\S+)(?:\s+.*)?$, ) {
$w = $1 ;
push @IN3, ( $w =~ s,/,,g) . " $_";
$mbusm = $#IN if m,^MANDB_MAP\s+/usr/share/man(?:\s+.*)?$, ;
$mbom = $#IN if m,^MANDB_MAP\s+/opt/man(?:\s+.*)?$, ;
}
}
# In the third section, if needed, add the lines
# MANDB_MAP /usr/share/man /var/cache/man/share
# MANDB_MAP /opt/man /var/cache/man/opt
push @IN3, "3 MANDB_MAP\t/usr/share/man\t/var/cache/man/share\n" unless $mbusm;
push @IN3, "2 MANDB_MAP\t/opt/man\t/var/cache/man/opt\n" unless $mbom;
$saved = $ARGV . ".orig";
rename $ARGV, ( -e $saved ? $ARGV . "~" : $saved );
open OUT, ">$ARGV" or die "Cannot open output file $ARGV: $!\n";
foreach $j (0..$#IN) {
$_ = $IN[$j];
# first section
# MANDATORY_MANPATH section:
# we have to add
# MANDATORY_MANPATH /usr/share/man
# just after the usual line
# MANDATORY_MANPATH /usr/man
# which we leave in place.
if ( ! $myusm and $j == $myum ) {
print OUT ;
print OUT "MANDATORY_MANPATH\t\t\t/usr/share/man\n";
next;
}
# second section
# MANPATH_MAP section:
# we change all the manpath_elements from /usr/man to /usr/share/man.
# we also add the lines
# MANPATH_MAP /usr/games /usr/share/man
# MANPATH_MAP /opt/bin /opt/man
# MANPATH_MAP /opt/sbin /opt/man
# if they were missing.
if ( m,^MANPATH_MAP\s+, ) {
s,(\s+)/usr/man\s*$,$1/usr/share/man\n,;
print OUT ;
# only after the last entry of the section!
if ( $j == $mh ) {
print OUT "MANPATH_MAP\t/usr/games\t\t/usr/share/man\n"
unless $mhug;
print OUT "MANPATH_MAP\t/opt/bin\t\t/opt/man\n"
unless $mhob;
print OUT "MANPATH_MAP\t/opt/sbin\t\t/opt/man\n"
unless $mhos;
}
next;
}
# third section
# MANDB_MAP section:
# in the relative_catpath field, we change all occurrences of
# /var/catman with /var/cache/man.
# we also reorder the entries to have longer manpath before.
if ( m,^MANDB_MAP\s+, ) {
if ( @IN3 ) {
foreach (reverse sort @IN3) {
($w,$t,$m,$c) = split;
$c = "/var/cache/man/$c"
if !$c or $c =~ m/^FSSTND$/i;
$c =~ s,/var/catman,/var/cache/man,;
print OUT $t, "\t", $m, "\t\t", $c, "\n";
}
@IN3 = ();
}
next;
}
# default
print OUT;
}
__END__
|