#!/usr/bin/perl -w # # Reads debian/docs, installs all files listed there into /usr/doc/$PACKAGE # Also installs the debian/copyright and debian/README.debian and debian/TODO # and handles debian/doc-base. BEGIN { push @INC, "debian", "/usr/lib/debhelper" } use 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"); } undef @docs; if ($file) { @docs=filearray($file); } if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) { push @docs, @ARGV; } 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"); } # .Debian is correct, according to policy, but I'm easy. $readme_debian=pkgfile($PACKAGE,'README.Debian'); if (! $readme_debian) { $readme_debian=pkgfile($PACKAGE,'README.debian'); } if ($readme_debian) { doit("install","-m","644","-p","$readme_debian","$TMP/usr/doc/$PACKAGE/README.Debian"); } $todo=pkgfile($PACKAGE,'TODO'); if ($todo) { if (isnative($PACKAGE)) { doit("install","-m","644","-p",$todo,"$TMP/usr/doc/$PACKAGE/TODO"); } else { doit("install","-m","644","-p",$todo,"$TMP/usr/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 ($copyright) { doit("install","-m","644","-p",$copyright,"$TMP/usr/doc/$PACKAGE/copyright"); } # Handle doc-base files. There are two filename formats, the usual plus # an extended format (debian/package.doc-base.). Have to # come up with good document-id's too. my %doc_ids; opendir(DEB,"debian/") || error("can't read debian directory: $!"); foreach (grep {/^\Q$PACKAGE\E\.doc-base\..*$/} readdir(DEB)) { $id=$_; $id=~s/\.doc-base\./-/; $doc_ids{$id}="debian/$_"; } closedir(DEB); # These next lines handle the format debian/doc-base., # which is in for completeness. if ($PACKAGE eq $dh{MAINPACKAGE}) { opendir(DEB,"debian/") || error("can't read debian directory: $!"); foreach (grep {/^doc-base\..*$/} readdir(DEB)) { $id=$_; $id=~s/doc-base\./$PACKAGE-/; $doc_ids{$id}="debian/$_"; } closedir(DEB); } # And this handles the normal format of course. $file=pkgfile($PACKAGE,"doc-base"); if ($file ne '') { $doc_ids{$PACKAGE}=$file; } if (%doc_ids) { if (! -d "$TMP/usr/share/doc-base/") { doit("install","-d","$TMP/usr/share/doc-base/"); } } foreach $doc_id (keys %doc_ids) { doit("install","-m644","-p",$doc_ids{$doc_id}, "$TMP/usr/share/doc-base/$doc_id"); if (! $dh{NOSCRIPTS}) { autoscript($PACKAGE,"postinst","postinst-doc-base", "s/#DOC-ID#/$doc_id/", ); autoscript($PACKAGE,"prerm","prerm-doc-base", "s/#DOC-ID#/$doc_id/", ); } } }