]> git.donarmstrong.com Git - debhelper.git/blob - dh_installdocs
r157: Initial Import
[debhelper.git] / dh_installdocs
1 #!/usr/bin/perl -w
2 #
3 # Reads debian/docs, installs all files listed there into /usr/doc/$PACKAGE
4 # Also installs the debian/copyright and debian/README.debian and debian/TODO
5 # and handles debian/doc-base.
6
7 BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
8 use Dh_Lib;
9 init();
10
11 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
12         $TMP=tmpdir($PACKAGE);
13         $file=pkgfile($PACKAGE,"docs");
14
15         if ( ! -d "$TMP/usr/doc/$PACKAGE") {
16                 doit("install","-d","$TMP/usr/doc/$PACKAGE");
17         }
18
19         undef @docs;
20
21         if ($file) {
22                 @docs=filearray($file);
23         }
24
25         if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
26                 push @docs, @ARGV;
27         }
28
29         if (@docs) {
30                 doit("cp","-a",@docs,"$TMP/usr/doc/$PACKAGE/");
31                 doit("chmod","-R","go=rX","$TMP/usr/doc");
32                 doit("chmod","-R","u+rw","$TMP/usr/doc");
33         }
34
35         # .Debian is correct, according to policy, but I'm easy.
36         $readme_debian=pkgfile($PACKAGE,'README.Debian');
37         if (! $readme_debian) {
38                 $readme_debian=pkgfile($PACKAGE,'README.debian');
39         }
40         if ($readme_debian) {
41                 doit("install","-m","644","-p","$readme_debian","$TMP/usr/doc/$PACKAGE/README.Debian");
42         }
43
44         $todo=pkgfile($PACKAGE,'TODO');
45         if ($todo) {
46                 if (isnative($PACKAGE)) {
47                         doit("install","-m","644","-p",$todo,"$TMP/usr/doc/$PACKAGE/TODO");
48                 }
49                 else {
50                         doit("install","-m","644","-p",$todo,"$TMP/usr/doc/$PACKAGE/TODO.Debian");
51                 }
52         }
53
54         # Support debian/package.copyright, but if not present, fall back
55         # on debian/copyright for all packages, not just the main binary
56         # package.
57         $copyright=pkgfile($PACKAGE,'copyright');
58         if (! $copyright && -e "debian/copyright") {
59                 $copyright="debian/copyright";
60         }
61         if ($copyright) {
62                         doit("install","-m","644","-p",$copyright,"$TMP/usr/doc/$PACKAGE/copyright");
63         }
64         
65         # Handle doc-base files.
66         $file=pkgfile($PACKAGE,"doc-base");
67         if ($file) {
68                 if (! -d "$TMP/usr/share/doc-base/") {
69                         doit("install","-d","$TMP/usr/share/doc-base/");
70                 }
71                 doit("install","-p","-m644",$file,
72                      "$TMP/usr/share/doc-base/$PACKAGE");
73                 if (! $dh{NOSCRIPTS}) {
74                         autoscript($PACKAGE,"postinst","postinst-doc-base");
75                         autoscript($PACKAGE,"postrm","postrm-doc-base")
76                 }
77         }
78 }