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 use Debian::Debhelper::Dh_Lib;
11 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
12 $TMP=tmpdir($PACKAGE);
13 $file=pkgfile($PACKAGE,"docs");
15 # If this is a symlink, leave it alone.
16 if ( ! -d "$TMP/usr/share/doc/$PACKAGE" &&
17 ! -l "$TMP/usr/share/doc/$PACKAGE") {
18 doit("install","-g",0,"-o",0,"-d","$TMP/usr/share/doc/$PACKAGE");
24 @docs=filearray($file);
27 if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
32 doit("cp", "-a",@docs,"$TMP/usr/share/doc/$PACKAGE/");
33 doit("chown","-R","0.0","$TMP/usr/share/doc");
34 doit("chmod","-R","go=rX","$TMP/usr/share/doc");
35 doit("chmod","-R","u+rw","$TMP/usr/share/doc");
38 # .Debian is correct, according to policy, but I'm easy.
39 $readme_debian=pkgfile($PACKAGE,'README.Debian');
40 if (! $readme_debian) {
41 $readme_debian=pkgfile($PACKAGE,'README.debian');
44 doit("install","-g",0,"-o",0,"-m","644","-p","$readme_debian",
45 "$TMP/usr/share/doc/$PACKAGE/README.Debian");
48 $todo=pkgfile($PACKAGE,'TODO');
50 if (isnative($PACKAGE)) {
51 doit("install","-g",0,"-o",0,"-m","644","-p",$todo,
52 "$TMP/usr/share/doc/$PACKAGE/TODO");
55 doit("install","-g",0,"-o",0,"-m","644","-p",$todo,
56 "$TMP/usr/share/doc/$PACKAGE/TODO.Debian");
60 # Support debian/package.copyright, but if not present, fall back
61 # on debian/copyright for all packages, not just the main binary
63 $copyright=pkgfile($PACKAGE,'copyright');
64 if (! $copyright && -e "debian/copyright") {
65 $copyright="debian/copyright";
68 doit("install","-g",0,"-o",0,"-m","644","-p",$copyright,
69 "$TMP/usr/share/doc/$PACKAGE/copyright");
72 # Add in the /usr/doc compatability symlinks code.
73 if (! $dh{NOSCRIPTS}) {
74 autoscript($PACKAGE,"postinst","postinst-doc",
75 "s/#PACKAGE#/$PACKAGE/g",
77 autoscript($PACKAGE,"prerm","prerm-doc",
78 "s/#PACKAGE#/$PACKAGE/g",
82 # Handle doc-base files. There are two filename formats, the usual
83 # plus an extended format (debian/package.*).
86 opendir(DEB,"debian/") || error("can't read debian directory: $!");
87 # If this is the main package, we need to handle unprefixed filenames.
88 # For all packages, we must support both the usual filename format plus
89 # that format with a period an something appended.
90 my $regexp="\Q$PACKAGE\E\.";
91 if ($PACKAGE eq $dh{MAINPACKAGE}) {
94 foreach my $fn (grep {/^${regexp}doc-base(\..*)?$/} readdir(DEB)) {
95 # Parse the file to get the doc id.
96 open (IN, "debian/$fn") || die "Cannot read debian/$fn.";
98 if (/^Document:\s+(.*)(\s+)?/) {
108 if (! -d "$TMP/usr/share/doc-base/") {
109 doit("install","-g",0,"-o",0,"-d","$TMP/usr/share/doc-base/");
112 foreach my $fn (keys %doc_ids) {
113 doit("install","-g",0,"-o",0,"-m644","-p","debian/$fn",
114 "$TMP/usr/share/doc-base/$doc_ids{$fn}");
115 if (! $dh{NOSCRIPTS}) {
116 autoscript($PACKAGE,"postinst","postinst-doc-base",
117 "s/#DOC-ID#/$doc_ids{$fn}/",
119 autoscript($PACKAGE,"prerm","prerm-doc-base",
120 "s/#DOC-ID#/$doc_ids{$fn}/",