5 dh_installmanpages - old-style man page installer
11 use Debian::Debhelper::Dh_Lib;
15 B<dh_installmanpages> [S<I<debhelper options>>] [S<I<file ...>>]
19 dh_installmanpages is a debhelper program that is responsible for
20 automatically installing man pages into usr/share/man/ and usr/X11R6/man/
21 in package build directories.
23 This is a DWIM-style program, with an interface unlike the rest of
24 debhelper. You are encouraged to use L<dh_installman(1)> instead.
26 dh_installmanpages scans the current directory and all subdirectories for
27 filenames that look like man pages. (Note that only real files are looked
28 at; symlinks are ignored.) It uses L<file(1)> to verify that the files are
29 in the correct format. Then, based on the files' extensions, it installs
30 them into the correct man directory.
32 All filenames specified as parameters will be skipped by dh_installmanpages.
33 This is useful if by default it installs some man pages that you do not
36 After the man page installation step, dh_installmanpages will check to see
37 if any of the man pages are ".so" links. If so, it changes them to symlinks.
45 Do not install these files as man pages, even if they look like valid man
52 dh_installmanpages will install the man pages it finds into B<all> packages
53 you tell it to act on, since it can't tell what package the man
54 pages belong in. This is almost never what you really want (use -p to work
55 around this, or use the much better L<dh_installman(1)> program instead).
57 Files ending in I<.man> will be ignored.
59 Files specified as parameters that contain spaces in their filenames will
60 not be processed properly.
66 # Check if a file is a man page, for use by File::Find.
70 # Does its filename look like a man page?
71 # .ex files are examples installed by deb-make,
72 # we don't want those, or .in files, which are
73 # from configure, nor do we want CVS .#* files.
74 if (! (-f $_ && /^.*\.[1-9].*$/ && ! /\.(ex|in)$/ && ! /^\.#/)) {
78 # It's not in a tmp directory is it?
79 if ($File::Find::dir=~m:debian/.*tmp.*:) {
82 foreach my $dir (@allpackages) {
83 if ($File::Find::dir=~m:debian/\Q$dir\E:) {
88 # And file does think it's a real man page?
89 my $type=`file -z $_`;
90 if ($type !~ m/:.*roff/) {
95 push @manpages,"$File::Find::dir/$_";
98 # Check if a file is a .so man page, for use by File::Find.
102 # The -s test is becuase a .so file tends to be small. We don't want
103 # to open every man page. 1024 is arbitrary.
104 if (! -f $_ || -s $_ > 1024) {
108 # Test first line of file for the .so thing.
112 if ($l=~m/\.so\s+(.*)/) {
114 # This test is here to prevent links like ... man8/../man8/foo.8
115 if (basename($File::Find::dir) eq
117 $solink=basename($solink);
120 $solink="../$solink";
123 push @sofiles,"$File::Find::dir/$_";
124 push @sodests,$solink;
128 foreach my $package (@{$dh{DOPACKAGES}}) {
129 my $tmp=tmpdir($package);
131 # Find all filenames that look like man pages.
133 @allpackages=GetPackages('');
134 find(\&find_man,'.'); # populates @manpages
136 foreach my $page (@manpages) {
137 $page=~s:^\./::; # just for looks
139 my $basename=basename($page);
141 # Skip all files listed on command line.
143 foreach my $skip (@ARGV) {
144 # Look at basename of what's on connect line
145 # for backwards compatibility.
146 if ($basename eq basename($skip)) {
154 # Handle X man pages specially.
155 if ($basename=~/x$/) {
159 my ($section)=$basename=~m/.*\.([1-9])/;
161 my $destdir="$tmp/usr/$extdir/man/man$section/";
163 # Handle translated man pages.
164 my $instname=$basename;
165 my ($langcode)=$basename=~m/.*\.([a-z][a-z])\.([1-9])/;
166 if (defined $langcode && $langcode ne '') {
167 $destdir="$tmp/usr/$extdir/man/$langcode/man$section/";
168 $instname=~s/\.$langcode\./\./;
171 $destdir=~tr:/:/:s; # just for looks
173 if (! -e "$destdir/$basename" && !-l "$destdir/$basename") {
175 doit "install","-d",$destdir;
177 doit "install","-p","-m644",$page,$destdir.$instname;
182 # Now the .so conversion.
183 @sofiles=@sodests=();
184 foreach my $dir (qw{usr/share/man usr/X11R6/man}) {
185 if (-e "$tmp/$dir") {
186 find(\&find_so_man, "$tmp/$dir");
189 foreach my $sofile (@sofiles) {
190 my $sodest=shift(@sodests);
191 doit "rm","-f",$sofile;
192 doit "ln","-sf",$sodest,$sofile;
200 This program is a part of debhelper.
204 Joey Hess <joeyh@debian.org>