summaryrefslogtreecommitdiff
path: root/dh_installmanpages
diff options
context:
space:
mode:
authorjoey <joey>1999-09-06 05:47:41 +0000
committerjoey <joey>1999-09-06 05:47:41 +0000
commit37c69d4e7124fb03edf46bea4eb38f6721f2aa2a (patch)
tree2ab81f9330d3cb5b01d3600ec41d1f1988b17f68 /dh_installmanpages
parentda7d6c32c080678dc672f7c6e680c11569f46eda (diff)
r266: * FHS complience. Patch from Johnie Ingram <johnie@netgod.net>.
For the most part, this was a straight-forward substitution, dh_installmanpages needed a non-obvious change though. * Closes: #42489, #42587, #41732. * dh_installdocs: Adds code to postinst and prerm as specified in http://www.debian.org/Lists-Archives/debian-ctte-9908/msg00038.html, to make /usr/doc/<package> a compatability symlink to /usr/share/doc/<package>. Note that currently if something exists in /usr/doc/<package> when the postinst is run, it will silently not make the symlink. I'm considering more intellingent handing of this case. * Note that if you build a package with this version of debhelper, it will use /usr/share/man, /usr/share/doc, and /usr/share/info. You may need to modify other files in your package that reference the old locations.
Diffstat (limited to 'dh_installmanpages')
-rwxr-xr-xdh_installmanpages156
1 files changed, 128 insertions, 28 deletions
diff --git a/dh_installmanpages b/dh_installmanpages
index 9dbf1c93..7e8eae6a 100755
--- a/dh_installmanpages
+++ b/dh_installmanpages
@@ -1,31 +1,131 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
#
-# Automatically find and install man pages.
-# This is a little bit DWIMish, but still very handy.
+# Automatically find and install man pages. However, do not install any man
+# pages listed on the command line.
+# Also change man pages with .so commands in them into symlinks.
+#
+# This is a little bit (hah!) DWIMish, but still very handy.
+
+use File::Find;
+BEGIN { push @INC, "debian", "/usr/share/debhelper" }
+use Dh_Lib;
+init();
+
+# Check if a file is a man page, for use by File::Find.
+my @manpages;
+my @allpackages;
+sub find_man {
+ # Does its filename look like a man page?
+ # .ex files are examples installed by deb-make,
+ # we don't want those, or .in files, which are
+ # from configure.
+ if (! (-f $_ && /^.*\.[1-9].*$/ && ! /\.(ex|in)$/)) {
+ return;
+ }
+
+ # It's not in a tmp directory is it?
+ if ($File::Find::dir=~m:debian/.*tmp.*:) {
+ return;
+ }
+ foreach $dir (@allpackages) {
+ if ($File::Find::dir=~m:debian/\Q$dir\E:) {
+ return;
+ }
+ }
+
+ # And file does think it's a real man page?
+ my $type=`file -z $_`;
+ if ($type !~ m/:.*roff/) {
+ return;
+ }
+
+ # Good enough.
+ push @manpages,"$File::Find::dir/$_";
+}
+
+# Check if a file is a .so man page, for use by File::Find.
+my @sofiles;
+my @sodests;
+sub find_so_man {
+ # The -s test is becuase a .so file tends to be small. We don't want
+ # to open every man page. 1024 is arbitrary.
+ if (! -f $_ || -s $_ > 1024) {
+ return;
+ }
+
+ # Test first line of file for the .so thing.
+ open (SOTEST,$_);
+ my $l=<SOTEST>;
+ close SOTEST;
+ if ($l=~m/\.so\s+(.*)/) {
+ my $solink=$1;
+ # This test is here to prevent links like ... man8/../man8/foo.8
+ if (Dh_Lib::basename($File::Find::dir) eq Dh_Lib::dirname($solink)) {
+ $solink=Dh_Lib::basename($solink);
+ }
+ else {
+ $solink="../$solink";
+ }
+
+ push @sofiles,"$File::Find::dir/$_";
+ push @sodests,$solink;
+ }
+}
-PATH=debian:$PATH:/usr/lib/debhelper
-source dh_lib
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+ $TMP=tmpdir($PACKAGE);
-# Note: this was mostly copied from debstd, and not verified to work.
-# Find all filenames that look like man pages.
-for file in `find * -name "*.[1-9]*" ! -name "*.ex" ! -name "*.in"`; do
- # Make sure they arn't alreadt in debian/tmp
- if ! expr $file : 'debian/tmp/.*' >/dev/null; then
- # Make sure file thinks they are man pages.
- if file $file|grep -q roff; then
- if echo $file|grep -q /; then
- NAME=`expr $file : '.*/\(.*\)'`
- else
- NAME=$file
- fi
- SECTION=man`expr $NAME : '.*\.\([123456789]\)'`
- if [ ! -e debian/tmp/usr/man/$SECTION/$NAME -a \
- ! -e debian/tmp/usr/X11*/man/$SECTION/$NAME ]; then
- if [ ! -d debian/tmp/usr/man/$SECTION ]; then
- doit "install -d debian/tmp/usr/man/$SECTION"
- fi
- doit "install -p -m644 $file debian/tmp/usr/man/$SECTION/$NAME"
- fi
- fi
- fi
-done
+ # Find all filenames that look like man pages.
+ @manpages=();
+ @allpackages=GetPackages('');
+ find(\&find_man,'.'); # populates @manpages
+
+ foreach $page (@manpages) {
+ $page=~s:^\./::; # just for looks
+
+ $basename=Dh_Lib::basename($page);
+
+ # Skip all files listed on command line.
+ my $install=1;
+ foreach $skip (@ARGV) {
+ # Look at basename of what's on connect line
+ # for backwards compatability.
+ if ($basename eq Dh_Lib::basename($skip)) {
+ $install=undef;
+ last;
+ }
+ }
+
+ if ($install) {
+ my $extdir="share";
+ # Handle X man pages specially.
+ if ($basename=~/x$/) {
+ $extdir="X11R6";
+ }
+
+ my ($section)=$basename=~m/.*\.([1-9])/;
+
+ my $destdir="$TMP/usr/$extdir/man/man$section/";
+ $destdir=~tr:/:/:s; # just for looks
+ if (! -e "$destdir/$basename" && !-l "$destdir/$basename") {
+ if (! -d $destdir) {
+ doit "install","-d",$destdir;
+ }
+ doit "install","-p","-m644",$page,$destdir;
+ }
+ }
+ }
+
+ # Now the .so conversion.
+ @sofiles=@sodests=();
+ foreach $dir (qw{usr/share/man usr/X11R6/man}) {
+ if (-e "$TMP/$dir") {
+ find(\&find_so_man, "$TMP/$dir");
+ }
+ }
+ foreach $sofile (@sofiles) {
+ my $sodest=shift(@sodests);
+ doit "rm","-f",$sofile;
+ doit "ln","-sf",$sodest,$sofile;
+ }
+}