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 this is a dangling symlink, leave it. The maintainer
17 # better know what they're doing.
18 if ( ! -d "$TMP/usr/share/doc/$PACKAGE" &&
19 ! -l "$TMP/usr/share/doc/$PACKAGE") {
20 doit("install","-d","$TMP/usr/share/doc/$PACKAGE");
26 @docs=filearray($file);
29 if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
34 doit("cp","-a",@docs,"$TMP/usr/share/doc/$PACKAGE/");
35 doit("chmod","-R","go=rX","$TMP/usr/share/doc");
36 doit("chmod","-R","u+rw","$TMP/usr/share/doc");
39 # .Debian is correct, according to policy, but I'm easy.
40 $readme_debian=pkgfile($PACKAGE,'README.Debian');
41 if (! $readme_debian) {
42 $readme_debian=pkgfile($PACKAGE,'README.debian');
45 doit("install","-m","644","-p","$readme_debian",
46 "$TMP/usr/share/doc/$PACKAGE/README.Debian");
49 $todo=pkgfile($PACKAGE,'TODO');
51 if (isnative($PACKAGE)) {
52 doit("install","-m","644","-p",$todo,
53 "$TMP/usr/share/doc/$PACKAGE/TODO");
56 doit("install","-m","644","-p",$todo,
57 "$TMP/usr/share/doc/$PACKAGE/TODO.Debian");
61 # Support debian/package.copyright, but if not present, fall back
62 # on debian/copyright for all packages, not just the main binary
64 $copyright=pkgfile($PACKAGE,'copyright');
65 if (! $copyright && -e "debian/copyright") {
66 $copyright="debian/copyright";
69 doit("install","-m","644","-p",$copyright,
70 "$TMP/usr/share/doc/$PACKAGE/copyright");
73 # Add in the /usr/doc compatability symlinks code.
74 if (! $dh{NOSCRIPTS}) {
75 autoscript($PACKAGE,"postinst","postinst-doc",
76 "s/#PACKAGE#/$PACKAGE/g",
78 autoscript($PACKAGE,"prerm","prerm-doc",
79 "s/#PACKAGE#/$PACKAGE/g",
83 # Handle doc-base files. There are two filename formats, the usual
84 # plus an extended format (debian/package.*).
87 opendir(DEB,"debian/") || error("can't read debian directory: $!");
88 # If this is the main package, we need to handle unprefixed filenames.
89 # For all packages, we must support both the usual filename format plus
90 # that format with a period an something appended.
91 my $regexp="\Q$PACKAGE\E\.";
92 if ($PACKAGE eq $dh{MAINPACKAGE}) {
95 foreach my $fn (grep {/^${regexp}doc-base(\..*)?$/} readdir(DEB)) {
96 # Parse the file to get the doc id.
97 open (IN, "debian/$fn") || die "Cannot read debian/$fn.";
99 if (/^Document:\s+(.*)(\s+)?/) {
109 if (! -d "$TMP/usr/share/doc-base/") {
110 doit("install","-d","$TMP/usr/share/doc-base/");
113 foreach my $fn (keys %doc_ids) {
114 doit("install","-m644","-p","debian/$fn",
115 "$TMP/usr/share/doc-base/$doc_ids{$fn}");
116 if (! $dh{NOSCRIPTS}) {
117 autoscript($PACKAGE,"postinst","postinst-doc-base",
118 "s/#DOC-ID#/$doc_ids{$fn}/",
120 autoscript($PACKAGE,"prerm","prerm-doc-base",
121 "s/#DOC-ID#/$doc_ids{$fn}/",