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","-g","root","-o","root","-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("chown","-R","root.root","$TMP/usr/share/doc");
36 doit("chmod","-R","go=rX","$TMP/usr/share/doc");
37 doit("chmod","-R","u+rw","$TMP/usr/share/doc");
40 # .Debian is correct, according to policy, but I'm easy.
41 $readme_debian=pkgfile($PACKAGE,'README.Debian');
42 if (! $readme_debian) {
43 $readme_debian=pkgfile($PACKAGE,'README.debian');
46 doit("install","-g","root","-o","root","-m","644","-p","$readme_debian",
47 "$TMP/usr/share/doc/$PACKAGE/README.Debian");
50 $todo=pkgfile($PACKAGE,'TODO');
52 if (isnative($PACKAGE)) {
53 doit("install","-g","root","-o","root","-m","644","-p",$todo,
54 "$TMP/usr/share/doc/$PACKAGE/TODO");
57 doit("install","-g","root","-o","root","-m","644","-p",$todo,
58 "$TMP/usr/share/doc/$PACKAGE/TODO.Debian");
62 # Support debian/package.copyright, but if not present, fall back
63 # on debian/copyright for all packages, not just the main binary
65 $copyright=pkgfile($PACKAGE,'copyright');
66 if (! $copyright && -e "debian/copyright") {
67 $copyright="debian/copyright";
70 doit("install","-g","root","-o","root","-m","644","-p",$copyright,
71 "$TMP/usr/share/doc/$PACKAGE/copyright");
74 # Add in the /usr/doc compatability symlinks code.
75 if (! $dh{NOSCRIPTS}) {
76 autoscript($PACKAGE,"postinst","postinst-doc",
77 "s/#PACKAGE#/$PACKAGE/g",
79 autoscript($PACKAGE,"prerm","prerm-doc",
80 "s/#PACKAGE#/$PACKAGE/g",
84 # Handle doc-base files. There are two filename formats, the usual
85 # plus an extended format (debian/package.*).
88 opendir(DEB,"debian/") || error("can't read debian directory: $!");
89 # If this is the main package, we need to handle unprefixed filenames.
90 # For all packages, we must support both the usual filename format plus
91 # that format with a period an something appended.
92 my $regexp="\Q$PACKAGE\E\.";
93 if ($PACKAGE eq $dh{MAINPACKAGE}) {
96 foreach my $fn (grep {/^${regexp}doc-base(\..*)?$/} readdir(DEB)) {
97 # Parse the file to get the doc id.
98 open (IN, "debian/$fn") || die "Cannot read debian/$fn.";
100 if (/^Document:\s+(.*)(\s+)?/) {
110 if (! -d "$TMP/usr/share/doc-base/") {
111 doit("install","-g","root","-o","root","-d","$TMP/usr/share/doc-base/");
114 foreach my $fn (keys %doc_ids) {
115 doit("install","-g","root","-o","root","-m644","-p","debian/$fn",
116 "$TMP/usr/share/doc-base/$doc_ids{$fn}");
117 if (! $dh{NOSCRIPTS}) {
118 autoscript($PACKAGE,"postinst","postinst-doc-base",
119 "s/#DOC-ID#/$doc_ids{$fn}/",
121 autoscript($PACKAGE,"prerm","prerm-doc-base",
122 "s/#DOC-ID#/$doc_ids{$fn}/",