3 # Reads debian/docs, installs all files listed there into
4 # /usr/share/doc/$PACKAGE
5 # Also installs the debian/copyright and debian/README.debian and debian/TODO
6 # and handles debian/doc-base.
8 BEGIN { push @INC, "debian", "/usr/share/debhelper" }
12 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
13 $TMP=tmpdir($PACKAGE);
14 $file=pkgfile($PACKAGE,"docs");
16 if ( ! -d "$TMP/usr/share/doc/$PACKAGE") {
17 doit("install","-d","$TMP/usr/share/doc/$PACKAGE");
23 @docs=filearray($file);
26 if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
31 doit("cp","-a",@docs,"$TMP/usr/share/doc/$PACKAGE/");
32 doit("chmod","-R","go=rX","$TMP/usr/share/doc");
33 doit("chmod","-R","u+rw","$TMP/usr/share/doc");
36 # .Debian is correct, according to policy, but I'm easy.
37 $readme_debian=pkgfile($PACKAGE,'README.Debian');
38 if (! $readme_debian) {
39 $readme_debian=pkgfile($PACKAGE,'README.debian');
42 doit("install","-m","644","-p","$readme_debian",
43 "$TMP/usr/share/doc/$PACKAGE/README.Debian");
46 $todo=pkgfile($PACKAGE,'TODO');
48 if (isnative($PACKAGE)) {
49 doit("install","-m","644","-p",$todo,
50 "$TMP/usr/share/doc/$PACKAGE/TODO");
53 doit("install","-m","644","-p",$todo,
54 "$TMP/usr/share/doc/$PACKAGE/TODO.Debian");
58 # Support debian/package.copyright, but if not present, fall back
59 # on debian/copyright for all packages, not just the main binary
61 $copyright=pkgfile($PACKAGE,'copyright');
62 if (! $copyright && -e "debian/copyright") {
63 $copyright="debian/copyright";
66 doit("install","-m","644","-p",$copyright,
67 "$TMP/usr/share/doc/$PACKAGE/copyright");
70 # Add in the /usr/doc compatability symlinks code.
71 if (! $dh{NOSCRIPTS}) {
72 autoscript($PACKAGE,"postinst","postinst-doc",
73 "s/#PACKAGE#/$PACKAGE/g",
75 autoscript($PACKAGE,"prerm","prerm-doc",
76 "s/#PACKAGE#/$PACKAGE/g",
80 # Handle doc-base files. There are two filename formats, the usual
81 # plus an extended format (debian/package.*).
84 opendir(DEB,"debian/") || error("can't read debian directory: $!");
85 # If this is the main package, we need to handle unprefixed filenames.
86 # For all packages, we must support both the usual filename format plus
87 # that format with a period an something appended.
88 my $regexp="\Q$PACKAGE\E\.";
89 if ($PACKAGE eq $dh{MAINPACKAGE}) {
92 foreach my $fn (grep {/^${regexp}doc-base(\..*)?$/} readdir(DEB)) {
93 # Parse the file to get the doc id.
94 open (IN, "debian/$fn") || die "Cannot read debian/$fn.";
96 if (/^Document:\s+(.*)(\s+)?/) {
106 if (! -d "$TMP/usr/share/doc-base/") {
107 doit("install","-d","$TMP/usr/share/doc-base/");
110 foreach my $fn (keys %doc_ids) {
111 doit("install","-m644","-p","debian/$fn",
112 "$TMP/usr/share/doc-base/$doc_ids{$fn}");
113 if (! $dh{NOSCRIPTS}) {
114 autoscript($PACKAGE,"postinst","postinst-doc-base",
115 "s/#DOC-ID#/$doc_ids{$fn}/",
117 autoscript($PACKAGE,"prerm","prerm-doc-base",
118 "s/#DOC-ID#/$doc_ids{$fn}/",