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. It is deprecated, and you are encouraged to use
25 L<dh_installman(1)> instead.
27 dh_installmanpages scans the current directory and all subdirectories for
28 filenames that look like man pages. (Note that only real files are looked
29 at; symlinks are ignored.) It uses L<file(1)> to verify that the files are
30 in the correct format. Then, based on the files' extensions, it installs
31 them into the correct man directory.
33 All filenames specified as parameters will be skipped by dh_installmanpages.
34 This is useful if by default it installs some man pages that you do not
37 After the man page installation step, dh_installmanpages will check to see
38 if any of the man pages are ".so" links. If so, it changes them to symlinks.
46 Do not install these files as man pages, even if they look like valid man
53 dh_installmanpages will install the man pages it finds into B<all> packages
54 you tell it to act on, since it can't tell what package the man
55 pages belong in. This is almost never what you really want (use -p to work
56 around this, or use the much better L<dh_installman(1)> program instead).
58 Files ending in I<.man> will be ignored.
60 Files specified as parameters that contain spaces in their filenames will
61 not be processed properly.
65 warning("This program is deprecated, switch to dh_installman.");
69 # Check if a file is a man page, for use by File::Find.
73 # Does its filename look like a man page?
74 # .ex files are examples installed by deb-make,
75 # we don't want those, or .in files, which are
76 # from configure, nor do we want CVS .#* files.
77 if (! (-f $_ && /^.*\.[1-9].*$/ && ! /\.(ex|in)$/ && ! /^\.#/)) {
81 # It's not in a tmp directory is it?
82 if ($File::Find::dir=~m:debian/.*tmp.*:) {
85 foreach my $dir (@allpackages) {
86 if ($File::Find::dir=~m:debian/\Q$dir\E:) {
91 # And file does think it's a real man page?
92 my $type=`file -z $_`;
93 if ($type !~ m/:.*roff/) {
98 push @manpages,"$File::Find::dir/$_";
101 # Check if a file is a .so man page, for use by File::Find.
105 # The -s test is becuase a .so file tends to be small. We don't want
106 # to open every man page. 1024 is arbitrary.
107 if (! -f $_ || -s $_ > 1024) {
111 # Test first line of file for the .so thing.
115 if ($l=~m/\.so\s+(.*)/) {
117 # This test is here to prevent links like ... man8/../man8/foo.8
118 if (basename($File::Find::dir) eq
120 $solink=basename($solink);
123 $solink="../$solink";
126 push @sofiles,"$File::Find::dir/$_";
127 push @sodests,$solink;
131 foreach my $package (@{$dh{DOPACKAGES}}) {
132 next if is_udeb($package);
134 my $tmp=tmpdir($package);
136 # Find all filenames that look like man pages.
138 @allpackages=getpackages('');
139 find(\&find_man,'.'); # populates @manpages
141 foreach my $page (@manpages) {
142 $page=~s:^\./::; # just for looks
144 my $basename=basename($page);
146 # Skip all files listed on command line.
148 foreach my $skip (@ARGV) {
149 # Look at basename of what's on connect line
150 # for backwards compatibility.
151 if ($basename eq basename($skip)) {
160 my ($section)=$basename=~m/.*\.([1-9])/;
162 my $destdir="$tmp/usr/$extdir/man/man$section/";
164 # Handle translated man pages.
165 my $instname=$basename;
166 my ($langcode)=$basename=~m/.*\.([a-z][a-z])\.([1-9])/;
167 if (defined $langcode && $langcode ne '') {
168 $destdir="$tmp/usr/$extdir/man/$langcode/man$section/";
169 $instname=~s/\.$langcode\./\./;
172 $destdir=~tr:/:/:s; # just for looks
174 if (! -e "$destdir/$basename" && !-l "$destdir/$basename") {
176 doit "install","-d",$destdir;
178 doit "install","-p","-m644",$page,$destdir.$instname;
183 # Now the .so conversion.
184 @sofiles=@sodests=();
185 foreach my $dir (qw{usr/share/man usr/X11R6/man}) {
186 if (-e "$tmp/$dir") {
187 find(\&find_so_man, "$tmp/$dir");
190 foreach my $sofile (@sofiles) {
191 my $sodest=shift(@sodests);
192 doit "rm","-f",$sofile;
193 doit "ln","-sf",$sodest,$sofile;
201 This program is a part of debhelper.
205 Joey Hess <joeyh@debian.org>