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/lib/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 plus
66 # an extended format (debian/package.doc-base.<doc-id>). Have to
67 # come up with good document-id's too.
70 opendir(DEB,"debian/") || error("can't read debian directory: $!");
71 foreach (grep {/^\Q$PACKAGE\E\.doc-base\..*$/} readdir(DEB)) {
73 $id=~s/\.doc-base\./-/;
74 $doc_ids{$id}="debian/$_";
78 # These next lines handle the format debian/doc-base.<doc-id>,
79 # which is in for completeness.
80 if ($PACKAGE eq $dh{MAINPACKAGE}) {
81 opendir(DEB,"debian/") || error("can't read debian directory: $!");
82 foreach (grep {/^doc-base\..*$/} readdir(DEB)) {
84 $id=~s/doc-base\./$PACKAGE-/;
85 $doc_ids{$id}="debian/$_";
90 # And this handles the normal format of course.
91 $file=pkgfile($PACKAGE,"doc-base");
93 $doc_ids{$PACKAGE}=$file;
97 if (! -d "$TMP/usr/share/doc-base/") {
98 doit("install","-d","$TMP/usr/share/doc-base/");
101 foreach $doc_id (keys %doc_ids) {
102 doit("install","-m644","-p",$doc_ids{$doc_id},
103 "$TMP/usr/share/doc-base/$doc_id");
104 if (! $dh{NOSCRIPTS}) {
105 autoscript($PACKAGE,"postinst","postinst-doc-base",
106 "s/#DOC-ID#/$doc_id/",
108 autoscript($PACKAGE,"prerm","prerm-doc-base",
109 "s/#DOC-ID#/$doc_id/",