]> git.donarmstrong.com Git - debhelper.git/blob - dh_undocumented
r496: * Man page cleanups, Closes: #119335
[debhelper.git] / dh_undocumented
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_undocumented - make symlinks to undocumented.7.gz man page
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_undocumented> [S<I<debhelper options>>] [B<-A>] [S<I<manpage ...>>]
15
16 =head1 DESCRIPTION
17
18 dh_undocumented is a debhelper program that is responsible for making
19 symlinks to L<undocumented(7)> for man pages that are not present in your
20 package.
21
22 The program takes a list of man pages that should be symlinked to
23 L<undocumented(7)>. It examines the extension to see what section the man
24 page belongs in. After figuring this out, it generates the necessary
25 symlinks.
26
27 The lists of man pages that need symlinks can be specified in two ways. Any
28 man page names specified as
29 parameters will be set up in the first package dh_undocumented is told
30 to act on. By default, this is the first binary package in debian/control,
31 but if you use -p, -i, or -a flags, it will be the first package specified
32 by those flags.
33
34 Also, a file named debian/package.undocumented can list other man page
35 names to set up.
36
37 =head1 OPTIONS
38
39 =over 4
40
41 =item B<-A>, B<--all>
42
43 Install undocumented man page symlinks for any man pages specified by
44 command line parameters in ALL packages acted on. I doubt anyone will find
45 this useful, it's here for consitency with other debhelper programs.
46
47 =item I<manpage ...>
48
49 Install undocumented man page symlinks for each of these man pages
50 into the first package acted on. (Or in all packages acted on if -A is
51 specified.)
52
53 =back NOTES
54
55 Note that Debian policy prohibits links to L<undocumented(7)> unless the
56 package has an open bug report stating that it has no man page. You should
57 really just write a man page instead; this program is an easy way out.
58
59 =cut
60
61 init();
62
63 foreach my $package (@{$dh{DOPACKAGES}}) {
64         my $tmp=tmpdir($package);
65         my $undocumented=pkgfile($package,"undocumented");
66
67         my @undoc;
68         if ($undocumented) {
69                 @undoc=filearray($undocumented);
70         }
71
72         if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
73                 push @undoc, @ARGV;
74         }       
75
76         foreach my $file (@undoc) {
77                 $file=~s/.gz$//; # .gz extension is optional in input.
78
79                 # Determine what directory the file belongs in,
80                 # /usr/share/man, or /usr/X11R6/man, and how the link to
81                 # the undocumented.7 man page will look.
82                 my ($dir, $reldir);
83                 my ($section)=$file=~m/^.*\.(\d)/;
84                 if (!$section) {
85                         error("\"$file\" does not have an extension.");
86                 }       
87                 if ($section != 7) {
88                         $dir="usr/share/man/man$section";
89                         $reldir="../man7/";
90                 }
91                 else {
92                         $dir="usr/share/man/man$section";
93                         $reldir="";
94                 }
95
96                 # If an uncompressed version of the page exists, something
97                 # is weird.
98                 if (-e "$tmp/$dir/$file") {
99                         error("A man page $tmp/$dir/$file exists.");
100                 }
101                 
102                 if (! -d "$tmp/$dir") {
103                         doit("install","-d","$tmp/$dir");
104                 }               
105                 doit("ln","-sf","${reldir}undocumented.7.gz","$tmp/$dir/$file.gz");
106         }
107 }
108
109 =head1 SEE ALSO
110
111 L<debhelper(1)>
112
113 This program is a part of debhelper.
114
115 =head1 AUTHOR
116
117 Joey Hess <joeyh@debian.org>
118
119 =cut