1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#!/usr/bin/perl -w
#
# Automatically find and install man pages. However, do not install any man
# pages listed on the command line.
# Also change man pages with .so commands in them into symlinks.
#
# This is a little bit (hah!) DWIMish, but still very handy.
use File::Find;
BEGIN { push @INC, "debian", "/usr/share/debhelper" }
use Dh_Lib;
init();
# Check if a file is a man page, for use by File::Find.
my @manpages;
my @allpackages;
sub find_man {
# Does its filename look like a man page?
# .ex files are examples installed by deb-make,
# we don't want those, or .in files, which are
# from configure.
if (! (-f $_ && /^.*\.[1-9].*$/ && ! /\.(ex|in)$/)) {
return;
}
# It's not in a tmp directory is it?
if ($File::Find::dir=~m:debian/.*tmp.*:) {
return;
}
foreach $dir (@allpackages) {
if ($File::Find::dir=~m:debian/\Q$dir\E:) {
return;
}
}
# And file does think it's a real man page?
my $type=`file -z $_`;
if ($type !~ m/:.*roff/) {
return;
}
# Good enough.
push @manpages,"$File::Find::dir/$_";
}
# Check if a file is a .so man page, for use by File::Find.
my @sofiles;
my @sodests;
sub find_so_man {
# The -s test is becuase a .so file tends to be small. We don't want
# to open every man page. 1024 is arbitrary.
if (! -f $_ || -s $_ > 1024) {
return;
}
# Test first line of file for the .so thing.
open (SOTEST,$_);
my $l=<SOTEST>;
close SOTEST;
if ($l=~m/\.so\s+(.*)/) {
my $solink=$1;
# This test is here to prevent links like ... man8/../man8/foo.8
if (Dh_Lib::basename($File::Find::dir) eq Dh_Lib::dirname($solink)) {
$solink=Dh_Lib::basename($solink);
}
else {
$solink="../$solink";
}
push @sofiles,"$File::Find::dir/$_";
push @sodests,$solink;
}
}
foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
$TMP=tmpdir($PACKAGE);
# Find all filenames that look like man pages.
@manpages=();
@allpackages=GetPackages('');
find(\&find_man,'.'); # populates @manpages
foreach $page (@manpages) {
$page=~s:^\./::; # just for looks
$basename=Dh_Lib::basename($page);
# Skip all files listed on command line.
my $install=1;
foreach $skip (@ARGV) {
# Look at basename of what's on connect line
# for backwards compatability.
if ($basename eq Dh_Lib::basename($skip)) {
$install=undef;
last;
}
}
if ($install) {
my $extdir="";
# Handle X man pages specially.
if ($basename=~/x$/) {
$extdir="X11R6";
}
my ($section)=$basename=~m/.*\.([1-9])/;
my $destdir="$TMP/usr/$extdir/man/man$section/";
$destdir=~tr:/:/:s; # just for looks
if (! -e "$destdir/$basename" && !-l "$destdir/$basename") {
if (! -d $destdir) {
doit "install","-d",$destdir;
}
doit "install","-p","-m644",$page,$destdir;
}
}
}
# Now the .so conversion.
@sofiles=@sodests=();
foreach $dir (qw{usr/man usr/X11R6/man}) {
if (-e "$TMP/$dir") {
find(\&find_so_man, "$TMP/$dir");
}
}
foreach $sofile (@sofiles) {
my $sodest=shift(@sodests);
doit "rm","-f",$sofile;
doit "ln","-sf",$sodest,$sofile;
}
}
|