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.
9 use Debian::Debhelper::Dh_Lib;
12 foreach my $package (@{$dh{DOPACKAGES}}) {
13 my $tmp=tmpdir($package);
14 my $file=pkgfile($package,"docs");
16 # If this is a symlink, leave it alone.
17 if ( ! -d "$tmp/usr/share/doc/$package" &&
18 ! -l "$tmp/usr/share/doc/$package") {
19 doit("install","-g",0,"-o",0,"-d","$tmp/usr/share/doc/$package");
25 @docs=filearray($file, ".");
28 if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
33 doit("cp", "-a",@docs,"$tmp/usr/share/doc/$package/");
34 doit("chown","-R","0.0","$tmp/usr/share/doc");
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 my $readme_debian=pkgfile($package,'README.Debian');
41 if (! $readme_debian) {
42 $readme_debian=pkgfile($package,'README.debian');
45 doit("install","-g",0,"-o",0,"-m","644","-p","$readme_debian",
46 "$tmp/usr/share/doc/$package/README.Debian");
49 my $todo=pkgfile($package,'TODO');
51 if (isnative($package)) {
52 doit("install","-g",0,"-o",0,"-m","644","-p",$todo,
53 "$tmp/usr/share/doc/$package/TODO");
56 doit("install","-g",0,"-o",0,"-m","644","-p",$todo,
57 "$tmp/usr/share/doc/$package/TODO.Debian");
61 # If the "directory" is a dangling symlink, then don't install
62 # the copyright file. This is useful for multibinary packages
63 # that share a doc directory.
64 if (-d "$tmp/usr/share/doc/$package") {
65 # Support debian/package.copyright, but if not present, fall
66 # back on debian/copyright for all packages, not just the
67 # main binary package.
68 my $copyright=pkgfile($package,'copyright');
69 if (! $copyright && -e "debian/copyright") {
70 $copyright="debian/copyright";
73 doit("install","-g",0,"-o",0,"-m","644","-p",$copyright,
74 "$tmp/usr/share/doc/$package/copyright");
78 # Add in the /usr/doc compatability symlinks code.
79 if (! $dh{NOSCRIPTS}) {
80 autoscript($package,"postinst","postinst-doc",
81 "s/#PACKAGE#/$package/g",
83 autoscript($package,"prerm","prerm-doc",
84 "s/#PACKAGE#/$package/g",
88 # Handle doc-base files. There are two filename formats, the usual
89 # plus an extended format (debian/package.*).
92 opendir(DEB,"debian/") || error("can't read debian directory: $!");
93 # If this is the main package, we need to handle unprefixed filenames.
94 # For all packages, we must support both the usual filename format plus
95 # that format with a period an something appended.
96 my $regexp="\Q$package\E\.";
97 if ($package eq $dh{MAINPACKAGE}) {
100 foreach my $fn (grep {/^${regexp}doc-base(\..*)?$/} readdir(DEB)) {
101 # Parse the file to get the doc id.
102 open (IN, "debian/$fn") || die "Cannot read debian/$fn.";
104 if (/^Document:\s+(.*)(\s+)?/) {
114 if (! -d "$tmp/usr/share/doc-base/") {
115 doit("install","-g",0,"-o",0,"-d","$tmp/usr/share/doc-base/");
118 foreach my $fn (keys %doc_ids) {
119 doit("install","-g",0,"-o",0,"-m644","-p","debian/$fn",
120 "$tmp/usr/share/doc-base/$doc_ids{$fn}");
121 if (! $dh{NOSCRIPTS}) {
122 autoscript($package,"postinst","postinst-doc-base",
123 "s/#DOC-ID#/$doc_ids{$fn}/",
125 autoscript($package,"prerm","prerm-doc-base",
126 "s/#DOC-ID#/$doc_ids{$fn}/",