]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_installdocs
r389: * Completed the fix from the last version.
[debhelper.git] / dh_installdocs
index 20862bfe3211a420aa96c4bb470687e5b6d07d62..7af380947bd1a27853ea870896b286052c3dca76 100755 (executable)
@@ -1,19 +1,21 @@
 #!/usr/bin/perl -w
 #
-# Reads debian/docs, installs all files listed there into /usr/doc/$PACKAGE
+# Reads debian/docs, installs all files listed there into
+# /usr/share/doc/$PACKAGE
 # Also installs the debian/copyright and debian/README.debian and debian/TODO
 # and handles debian/doc-base.
 
-BEGIN { push @INC, "debian", "/usr/share/debhelper" }
-use Dh_Lib;
+use Debian::Debhelper::Dh_Lib;
 init();
 
 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
        $TMP=tmpdir($PACKAGE);
        $file=pkgfile($PACKAGE,"docs");
 
-       if ( ! -d "$TMP/usr/doc/$PACKAGE") {
-               doit("install","-d","$TMP/usr/doc/$PACKAGE");
+       # If this is a symlink, leave it alone.
+       if ( ! -d "$TMP/usr/share/doc/$PACKAGE" &&
+            ! -l "$TMP/usr/share/doc/$PACKAGE") {
+               doit("install","-g",0,"-o",0,"-d","$TMP/usr/share/doc/$PACKAGE");
        }
 
        undef @docs;
@@ -27,9 +29,10 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
        }
 
        if (@docs) {
-               doit("cp","-a",@docs,"$TMP/usr/doc/$PACKAGE/");
-               doit("chmod","-R","go=rX","$TMP/usr/doc");
-               doit("chmod","-R","u+rw","$TMP/usr/doc");
+               doit("cp", "-a",@docs,"$TMP/usr/share/doc/$PACKAGE/");
+               doit("chown","-R","0.0","$TMP/usr/share/doc");
+               doit("chmod","-R","go=rX","$TMP/usr/share/doc");
+               doit("chmod","-R","u+rw","$TMP/usr/share/doc");
        }
 
        # .Debian is correct, according to policy, but I'm easy.
@@ -38,30 +41,49 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
                $readme_debian=pkgfile($PACKAGE,'README.debian');
        }
        if ($readme_debian) {
-               doit("install","-m","644","-p","$readme_debian","$TMP/usr/doc/$PACKAGE/README.Debian");
+               doit("install","-g",0,"-o",0,"-m","644","-p","$readme_debian",
+                       "$TMP/usr/share/doc/$PACKAGE/README.Debian");
        }
 
        $todo=pkgfile($PACKAGE,'TODO');
        if ($todo) {
                if (isnative($PACKAGE)) {
-                       doit("install","-m","644","-p",$todo,"$TMP/usr/doc/$PACKAGE/TODO");
+                       doit("install","-g",0,"-o",0,"-m","644","-p",$todo,
+                               "$TMP/usr/share/doc/$PACKAGE/TODO");
                }
                else {
-                       doit("install","-m","644","-p",$todo,"$TMP/usr/doc/$PACKAGE/TODO.Debian");
+                       doit("install","-g",0,"-o",0,"-m","644","-p",$todo,
+                               "$TMP/usr/share/doc/$PACKAGE/TODO.Debian");
                }
        }
 
-       # Support debian/package.copyright, but if not present, fall back
-       # on debian/copyright for all packages, not just the main binary
-       # package.
-       $copyright=pkgfile($PACKAGE,'copyright');
-       if (! $copyright && -e "debian/copyright") {
-               $copyright="debian/copyright";
+       # If the "directory" is a dangling symlink, then don't install
+       # the copyright file. This is useful for multibinary packages 
+       # that share a doc directory.
+       if (-d "$TMP/usr/share/doc/$PACKAGE") {
+               # Support debian/package.copyright, but if not present, fall
+               # back on debian/copyright for all packages, not just the 
+               # main binary package.
+               $copyright=pkgfile($PACKAGE,'copyright');
+               if (! $copyright && -e "debian/copyright") {
+                       $copyright="debian/copyright";
+               }
+               if ($copyright) {
+                               doit("install","-g",0,"-o",0,"-m","644","-p",$copyright,
+                                       "$TMP/usr/share/doc/$PACKAGE/copyright");
+               }
        }
-       if ($copyright) {
-                       doit("install","-m","644","-p",$copyright,"$TMP/usr/doc/$PACKAGE/copyright");
+
+       # Add in the /usr/doc compatability symlinks code.
+       if (! $dh{NOSCRIPTS}) {
+               autoscript($PACKAGE,"postinst","postinst-doc",
+                       "s/#PACKAGE#/$PACKAGE/g",
+               );
+               autoscript($PACKAGE,"prerm","prerm-doc",
+                       "s/#PACKAGE#/$PACKAGE/g",
+               );
        }
-       
+
        # Handle doc-base files. There are two filename formats, the usual
        # plus an extended format (debian/package.*).
        my %doc_ids;
@@ -89,11 +111,11 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
        
        if (%doc_ids) {
                if (! -d "$TMP/usr/share/doc-base/") {
-                       doit("install","-d","$TMP/usr/share/doc-base/");
+                       doit("install","-g",0,"-o",0,"-d","$TMP/usr/share/doc-base/");
                }
        }
        foreach my $fn (keys %doc_ids) {
-               doit("install","-m644","-p","debian/$fn",
+               doit("install","-g",0,"-o",0,"-m644","-p","debian/$fn",
                     "$TMP/usr/share/doc-base/$doc_ids{$fn}");
                if (! $dh{NOSCRIPTS}) {
                        autoscript($PACKAGE,"postinst","postinst-doc-base",