3 # Reads debian/docs, installs all files listed there into /usr/doc/$PACKAGE
4 # Also installs the debian/copyright and debian/README.debian and debian/TODO
5 # and handles debian/doc-base.
7 BEGIN { push @INC, "debian", "/usr/share/debhelper" }
11 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
12 $TMP=tmpdir($PACKAGE);
13 $file=pkgfile($PACKAGE,"docs");
15 if ( ! -d "$TMP/usr/doc/$PACKAGE") {
16 doit("install","-d","$TMP/usr/doc/$PACKAGE");
22 @docs=filearray($file);
25 if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
30 doit("cp","-a",@docs,"$TMP/usr/doc/$PACKAGE/");
31 doit("chmod","-R","go=rX","$TMP/usr/doc");
32 doit("chmod","-R","u+rw","$TMP/usr/doc");
35 # .Debian is correct, according to policy, but I'm easy.
36 $readme_debian=pkgfile($PACKAGE,'README.Debian');
37 if (! $readme_debian) {
38 $readme_debian=pkgfile($PACKAGE,'README.debian');
41 doit("install","-m","644","-p","$readme_debian","$TMP/usr/doc/$PACKAGE/README.Debian");
44 $todo=pkgfile($PACKAGE,'TODO');
46 if (isnative($PACKAGE)) {
47 doit("install","-m","644","-p",$todo,"$TMP/usr/doc/$PACKAGE/TODO");
50 doit("install","-m","644","-p",$todo,"$TMP/usr/doc/$PACKAGE/TODO.Debian");
54 # Support debian/package.copyright, but if not present, fall back
55 # on debian/copyright for all packages, not just the main binary
57 $copyright=pkgfile($PACKAGE,'copyright');
58 if (! $copyright && -e "debian/copyright") {
59 $copyright="debian/copyright";
62 doit("install","-m","644","-p",$copyright,"$TMP/usr/doc/$PACKAGE/copyright");
65 # Handle doc-base files. There are two filename formats, the usual
66 # plus an extended format (debian/package.*).
69 opendir(DEB,"debian/") || error("can't read debian directory: $!");
70 # If this is the main package, we need to handle unprefixed filenames.
71 # For all packages, we must support both the usual filename format plus
72 # that format with a period an something appended.
73 my $regexp="\Q$PACKAGE\E\.";
74 if ($PACKAGE eq $dh{MAINPACKAGE}) {
77 foreach my $fn (grep {/^${regexp}doc-base(\..*)?$/} readdir(DEB)) {
78 # Parse the file to get the doc id.
79 open (IN, "debian/$fn") || die "Cannot read debian/$fn.";
81 if (/^Document:\s+(.*)(\s+)?/) {
91 if (! -d "$TMP/usr/share/doc-base/") {
92 doit("install","-d","$TMP/usr/share/doc-base/");
95 foreach my $fn (keys %doc_ids) {
96 doit("install","-m644","-p","debian/$fn",
97 "$TMP/usr/share/doc-base/$doc_ids{$fn}");
98 if (! $dh{NOSCRIPTS}) {
99 autoscript($PACKAGE,"postinst","postinst-doc-base",
100 "s/#DOC-ID#/$doc_ids{$fn}/",
102 autoscript($PACKAGE,"prerm","prerm-doc-base",
103 "s/#DOC-ID#/$doc_ids{$fn}/",