]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_installmanpages
r95: Initial Import
[debhelper.git] / dh_installmanpages
index 9dbf1c9381e68e2f2b1c9d7ec14090f4569b86a0..a8fb1e992dfda7eaa80f81644540e690efb5601b 100755 (executable)
@@ -1,31 +1,71 @@
 #!/bin/sh -e
 #
-# 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.
 
 PATH=debian:$PATH:/usr/lib/debhelper
-source dh_lib
+. dh_lib
+
+for PACKAGE in $DH_DOPACKAGES; do
+        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
+       # Find all filenames that look like man pages.
+       # .ex files are examples installed by deb-make, we don't want those, or
+       # .in files, which are from configure.
+       # We also need to exclude all debian/tmp type dirs.
+       EXCLUDE=`grep ^Package: debian/control | \
+               cut -d " " -f 2 | tr "\n" "|"`
+       for file in `find * -type f -name "*.[1-9]*" ! -name "*.ex" \
+               ! -name "*.in" | egrep -v "^debian/(${EXCLUDE}tmp)/"`
+       do
                # Make sure file thinks they are man pages.
-               if file $file|grep -q roff; then
+               if file -L $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"
+                       # Look at the command line and check if we should
+                       # install the file.
+                       install=1
+                       for notinstall in $@; do
+                               if [ "$NAME" = "$notinstall" -o \
+                                    "$file" = "$notinstall" ]; then
+                                       install=""
+                               fi
+                       done
+                       if [ "$install" ]; then
+                               SECTION=man`expr $NAME : '.*\.\([123456789]\)'`
+                               # Test to see if the filename ends with 'x',
+                               # if so, this is an X man page.
+                               if expr $NAME : '.*\.[123456789]x' >/dev/null; then
+                                       EXTDIR="X11R6"
+                               else
+                                       EXTDIR=""
+                               fi
+                               if [ ! -e $TMP/usr/man/$SECTION/$NAME -a \
+                                    ! -e $TMP/usr/X11*/man/$SECTION/$NAME ]; then
+                                       if [ ! -d $TMP/usr/$EXTDIR/man/$SECTION ]; then
+                                               doit "install -d $TMP/usr/$EXTDIR/man/$SECTION"
+                                       fi
+                                       doit "install -p -m644 $file $TMP/usr/$EXTDIR/man/$SECTION/$NAME"
                                fi
-                               doit "install -p -m644 $file debian/tmp/usr/man/$SECTION/$NAME"
                        fi
                fi
-       fi
+       done
+
+       # Now the .so conversion.
+       for file in `find $TMP/usr/man $TMP/usr/X11*/man -type f -size -256c 2>/dev/null`
+       do
+               solink=`expr "\`head -1 $file\`" : '\.so \(.*\)'`
+               if [ "$solink" ]; then
+                       doit "rm -f $file"
+                       # The .so links include the subdir the page is in, 
+                       # thus the ../
+                       doit "ln -s ../$solink $file"
+               fi
+       done
 done