3 # Automatically find and install man pages. However, do not install any man
4 # pages listed on the command line.
5 # Also change man pages with .so commands in them into symlinks.
7 # This is a little bit (hah!) DWIMish, but still very handy.
10 BEGIN { push @INC, "debian", "/usr/share/debhelper" }
14 # Check if a file is a man page, for use by File::Find.
18 # Does its filename look like a man page?
19 # .ex files are examples installed by deb-make,
20 # we don't want those, or .in files, which are
22 if (! (-f $_ && /^.*\.[1-9].*$/ && ! /\.(ex|in)$/)) {
26 # It's not in a tmp directory is it?
27 if ($File::Find::dir=~m:debian/.*tmp.*:) {
30 foreach $dir (@allpackages) {
31 if ($File::Find::dir=~m:debian/\Q$dir\E:) {
36 # And file does think it's a real man page?
37 my $type=`file -z $_`;
38 if ($type !~ m/:.*roff/) {
43 push @manpages,"$File::Find::dir/$_";
46 # Check if a file is a .so man page, for use by File::Find.
50 # The -s test is becuase a .so file tends to be small. We don't want
51 # to open every man page. 1024 is arbitrary.
52 if (! -f $_ || -s $_ > 1024) {
56 # Test first line of file for the .so thing.
60 if ($l=~m/\.so\s+(.*)/) {
62 # This test is here to prevent links like ... man8/../man8/foo.8
63 if (Dh_Lib::basename($File::Find::dir) eq Dh_Lib::dirname($solink)) {
64 $solink=Dh_Lib::basename($solink);
70 push @sofiles,"$File::Find::dir/$_";
71 push @sodests,$solink;
75 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
76 $TMP=tmpdir($PACKAGE);
78 # Find all filenames that look like man pages.
80 @allpackages=GetPackages('');
81 find(\&find_man,'.'); # populates @manpages
83 foreach $page (@manpages) {
84 $page=~s:^\./::; # just for looks
86 $basename=Dh_Lib::basename($page);
88 # Skip all files listed on command line.
90 foreach $skip (@ARGV) {
91 # Look at basename of what's on connect line
92 # for backwards compatability.
93 if ($basename eq Dh_Lib::basename($skip)) {
101 # Handle X man pages specially.
102 if ($basename=~/x$/) {
106 my ($section)=$basename=~m/.*\.([1-9])/;
108 my $destdir="$TMP/usr/$extdir/man/man$section/";
109 $destdir=~tr:/:/:s; # just for looks
110 if (! -e "$destdir/$basename" && !-l "$destdir/$basename") {
112 doit "install","-d",$destdir;
114 doit "install","-p","-m644",$page,$destdir;
119 # Now the .so conversion.
120 @sofiles=@sodests=();
121 foreach $dir (qw{usr/share/man usr/X11R6/man}) {
122 if (-e "$TMP/$dir") {
123 find(\&find_so_man, "$TMP/$dir");
126 foreach $sofile (@sofiles) {
127 my $sodest=shift(@sodests);
128 doit "rm","-f",$sofile;
129 doit "ln","-sf",$sodest,$sofile;