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
|
#!/usr/bin/perl -w
#
# Reads debian/docs, installs all files listed there into /usr/doc/$PACKAGE
# Also installs the debian/copyright and debian/README.debian and debian/TODO
# and handles debian/doc-base.
BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
use Dh_Lib;
init();
foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
$TMP=tmpdir($PACKAGE);
$file=pkgfile($PACKAGE,"docs");
if ( ! -d "$TMP/usr/doc/$PACKAGE") {
doit("install","-d","$TMP/usr/doc/$PACKAGE");
}
undef @docs;
if ($file) {
@docs=filearray($file);
}
if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
push @docs, @ARGV;
}
if (@docs) {
doit("cp","-a",@docs,"$TMP/usr/doc/$PACKAGE/");
doit("chmod","-R","go=rX","$TMP/usr/doc");
doit("chmod","-R","u+rw","$TMP/usr/doc");
}
# .Debian is correct, according to policy, but I'm easy.
$readme_debian=pkgfile($PACKAGE,'README.Debian');
if (! $readme_debian) {
$readme_debian=pkgfile($PACKAGE,'README.debian');
}
if ($readme_debian) {
doit("install","-m","644","-p","$readme_debian","$TMP/usr/doc/$PACKAGE/README.Debian");
}
$todo=pkgfile($PACKAGE,'TODO');
if ($todo) {
if (isnative($PACKAGE)) {
doit("install","-m","644","-p",$todo,"$TMP/usr/doc/$PACKAGE/TODO");
}
else {
doit("install","-m","644","-p",$todo,"$TMP/usr/doc/$PACKAGE/TODO.Debian");
}
}
# Support debian/package.copyright, but if not present, fall back
# on debian/copyright for all packages, not just the main binary
# package.
$copyright=pkgfile($PACKAGE,'copyright');
if (! $copyright && -e "debian/copyright") {
$copyright="debian/copyright";
}
if ($copyright) {
doit("install","-m","644","-p",$copyright,"$TMP/usr/doc/$PACKAGE/copyright");
}
# Handle doc-base files. There are two filename formats, the usual plus
# an extended format (debian/package.doc-base.<doc-id>). Have to
# come up with good document-id's too.
my %doc_ids;
opendir(DEB,"debian/") || error("can't read debian directory: $!");
foreach (grep {/^$PACKAGE\.doc-base\..*$/} readdir(DEB)) {
$id=$_;
$id=~s/\.doc-base\./-/;
$doc_ids{$id}="debian/$_";
}
closedir(DEB);
# These next lines handle the format debian/doc-base.<doc-id>,
# which is in for completeness.
if ($PACKAGE eq $dh{MAINPACKAGE}) {
opendir(DEB,"debian/") || error("can't read debian directory: $!");
foreach (grep {/^doc-base\..*$/} readdir(DEB)) {
$id=$_;
$id=~s/doc-base\./$PACKAGE-/;
$doc_ids{$id}="debian/$_";
}
closedir(DEB);
}
# And this handles the normal format of course.
$file=pkgfile($PACKAGE,"doc-base");
if ($file ne '') {
$doc_ids{$PACKAGE}=$file;
}
if (%doc_ids) {
if (! -d "$TMP/usr/share/doc-base/") {
doit("install","-d","$TMP/usr/share/doc-base/");
}
}
foreach $doc_id (keys %doc_ids) {
doit("install","-m644","-p",$doc_ids{$doc_id},
"$TMP/usr/share/doc-base/$doc_id");
if (! $dh{NOSCRIPTS}) {
autoscript($PACKAGE,"postinst","postinst-doc-base",
"s/#DOC-ID#/$doc_id/",
);
autoscript($PACKAGE,"prerm","prerm-doc-base",
"s/#DOC-ID#/$doc_id/",
);
}
}
}
|