-# 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=Debian::Debhelper::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 Debian::Debhelper::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/";
+
+ # Handle translated man pages.
+ my $instname=$basename;
+ my ($langcode)=$basename=~m/.*\.([a-z][a-z])\.([1-9])/;
+ if (defined $langcode && $langcode ne '') {
+ $destdir="$TMP/usr/$extdir/man/$langcode/man$section/";
+ $instname=~s/\.$langcode\./\./;
+ }
+
+ $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.$instname;
+ }
+ }
+ }
+
+ # 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;
+ }
+}