5 dh_installman - install man pages into package build directories
11 use Debian::Debhelper::Dh_Lib;
15 dh_installman [debhelper options] [manpage ...]
19 dh_installman is a debhelper program that handles for installing
20 man pages into the correct locations in package build directories. You tell
21 it what man pages go in your packages, and it figures out where to
22 install them based on the section field in their .TH line and their filename
25 Any man page filenames specified as parameters will be installed into the
26 first package dh_installman is told to act on. By default, this is the
27 first binary package in debian/control, but if you use -p, -i, or -a flags,
28 it will be the first package specified by those flags.
30 Files named debian/package.manpages can list other man pages to be
33 After the man page installation step, dh_installman will check to see if
34 any of the man pages in the temporary directories of any of the packages it
35 is acting on contain ".so" links. If so, it changes them to symlinks.
43 Install all files specified by command line parameters in ALL packages
48 Install these man pages into the first package acted on. (Or in all
49 packages if -A is specified).
55 An older version of this program, L<dh_installmanpages(1)>, is still used
56 by some packages, and so is still included in debhelper.
57 It is, however, deprecated, due to its counterintuitive and inconsistent
58 interface. Use this program instead.
67 foreach my $package (@{$dh{DOPACKAGES}}) {
68 my $tmp=tmpdir($package);
69 my $file=pkgfile($package,"manpages");
73 @manpages=filearray($file, ".");
76 if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
77 push @manpages, @ARGV;
80 foreach my $page (@manpages) {
81 my $basename=Debian::Debhelper::Dh_Lib::basename($page);
83 # Support compressed pages.
85 if ($basename=~m/(.*)(\.gz)/) {
91 # See if there is a .TH entry in the man page. If so,
92 # we'll pull the section field from that.
94 open (IN, "zcat $page|") or die "$page: $!";
97 open (IN, $page) or die "$page: $!";
100 if (/^\.TH\s+\S+\s+(\d+\S*)\s/) {
105 # Failing that, we can try to get it from the filename.
107 ($section)=$basename=~m/.*\.([1-9]\S*)/;
110 # Now get the numeric component of the section.
111 my ($realsection)=$section=~m/^(\d)/ if defined $section;
113 # If there is no numeric section, bail.
114 if (! $realsection) {
115 error("Could not determine section for $page");
118 my $destdir="$tmp/usr/share/man/man$realsection/";
119 # Translated man pages are typically specified by adding the
120 # language code to the filename, so detect that and
121 # redirect to appropriate directory.
122 my ($langcode)=$basename=~m/.*\.([a-z][a-z](?:_[A-Z][A-Z])?)\.(?:[1-9]|man)/;
123 if (defined $langcode && $langcode ne '') {
124 $destdir="$tmp/usr/share/man/$langcode/man$section/";
126 $destdir=~tr:/:/:s; # just for looks
128 # Get the man page's name -- everything up to the last dot.
129 my ($instname)=$basename=~m/^(.*)\./;
131 if (! -e "$destdir/$instname.$section" &&
132 ! -l "$destdir/$instname.$section") {
134 doit "install","-d",$destdir;
136 doit "install","-p","-m644",$page,
137 "$destdir$instname.$section$gz";
142 # Now the .so conversion.
143 @sofiles=@sodests=();
144 foreach my $dir (qw{usr/share/man usr/X11R6/man}) {
145 if (-e "$tmp/$dir") {
146 find(\&find_so_man, "$tmp/$dir");
149 foreach my $sofile (@sofiles) {
150 my $sodest=shift(@sodests);
151 doit "rm","-f",$sofile;
152 doit "ln","-sf",$sodest,$sofile;
156 # Check if a file is a .so man page, for use by File::Find.
158 # The -s test is becuase a .so file tends to be small. We don't want
159 # to open every man page. 1024 is arbitrary.
160 if (! -f $_ || -s $_ > 1024) {
164 # Test first line of file for the .so thing.
168 if ($l=~m/\.so\s+(.*)/) {
170 # This test is here to prevent links like ... man8/../man8/foo.8
171 if (Debian::Debhelper::Dh_Lib::basename($File::Find::dir) eq
172 Debian::Debhelper::Dh_Lib::dirname($solink)) {
173 $solink=Debian::Debhelper::Dh_Lib::basename($solink);
176 $solink="../$solink";
179 push @sofiles,"$File::Find::dir/$_";
180 push @sodests,$solink;
188 This program is a part of debhelper.
192 Joey Hess <joeyh@debian.org>