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 next if is_udeb($package);
131 my $tmp=tmpdir($package);
133 # Find all filenames that look like man pages.
135 @allpackages=getpackages('');
136 find(\&find_man,'.'); # populates @manpages
138 foreach my $page (@manpages) {
139 $page=~s:^\./::; # just for looks
141 my $basename=basename($page);
143 # Skip all files listed on command line.
145 foreach my $skip (@ARGV) {
146 # Look at basename of what's on connect line
147 # for backwards compatibility.
148 if ($basename eq basename($skip)) {
156 # Handle X man pages specially.
157 if ($basename=~/x$/) {
161 my ($section)=$basename=~m/.*\.([1-9])/;
163 my $destdir="$tmp/usr/$extdir/man/man$section/";
165 # Handle translated man pages.
166 my $instname=$basename;
167 my ($langcode)=$basename=~m/.*\.([a-z][a-z])\.([1-9])/;
168 if (defined $langcode && $langcode ne '') {
169 $destdir="$tmp/usr/$extdir/man/$langcode/man$section/";
170 $instname=~s/\.$langcode\./\./;
173 $destdir=~tr:/:/:s; # just for looks
175 if (! -e "$destdir/$basename" && !-l "$destdir/$basename") {
177 doit "install","-d",$destdir;
179 doit "install","-p","-m644",$page,$destdir.$instname;
184 # Now the .so conversion.
185 @sofiles=@sodests=();
186 foreach my $dir (qw{usr/share/man usr/X11R6/man}) {
187 if (-e "$tmp/$dir") {
188 find(\&find_so_man, "$tmp/$dir");
191 foreach my $sofile (@sofiles) {
192 my $sodest=shift(@sodests);
193 doit "rm","-f",$sofile;
194 doit "ln","-sf",$sodest,$sofile;
202 This program is a part of debhelper.
206 Joey Hess <joeyh@debian.org>