sl@0: #!/bin/sh sl@0: sl@0: ZIP=: sl@0: while true; do sl@0: case $1 in sl@0: -s | --symlinks ) S="-s ";; sl@0: -z | --compress ) ZIP=$2; shift ;; sl@0: -e | --extension ) Z=$2; shift ;; sl@0: -s | --suffix ) SUFFIX=$2; shift ;; sl@0: *) break ;; sl@0: esac sl@0: shift sl@0: done sl@0: if test "$#" != 2; then sl@0: echo "Usage: installManPages file dir" sl@0: exit 1 sl@0: fi sl@0: sl@0: MANPAGE=$1 sl@0: DIR=$2 sl@0: test -z "$S" && S="$DIR/" sl@0: sl@0: # A sed script to parse the alternative names out of a man page. sl@0: # sl@0: # /^\\.SH NAME/{ ;# Look for a line, that starts with .SH NAME sl@0: # s/^.*$// ;# Delete the content of this line from the buffer sl@0: # n ;# Read next line sl@0: # s/,//g ;# Remove all commas ... sl@0: # s/\\\ //g ;# .. and backslash-escaped spaces. sl@0: # s/ \\\-.*// ;# Delete from \- to the end of line sl@0: # p ;# print the result sl@0: # q ;# exit sl@0: # } sl@0: # sl@0: # Backslashes are trippled in the sed script, because it is in sl@0: # backticks which don't pass backslashes literally. sl@0: # sl@0: # Please keep the commented version above updated if you sl@0: # change anything to the script below. sl@0: NAMES=`sed -n ' sl@0: /^\\.SH NAME/{ sl@0: s/^.*$// sl@0: n sl@0: s/,//g sl@0: s/\\\ //g sl@0: s/ \\\-.*// sl@0: p sl@0: q sl@0: }' $MANPAGE` sl@0: sl@0: SECTION=`echo $MANPAGE | sed 's/.*\(.\)$/\1/'` sl@0: SRCDIR=`dirname $MANPAGE` sl@0: FIRST="" sl@0: for f in $NAMES; do sl@0: f=$f.$SECTION$SUFFIX sl@0: if test -z "$FIRST" ; then sl@0: FIRST=$f sl@0: rm -f $DIR/$FIRST $DIR/$FIRST.* sl@0: sed -e "/man\.macros/r $SRCDIR/man.macros" -e "/man\.macros/d" \ sl@0: $MANPAGE > $DIR/$FIRST sl@0: chmod 444 $DIR/$FIRST sl@0: $ZIP $DIR/$FIRST sl@0: else sl@0: rm -f $DIR/$f $DIR/$f.* sl@0: ln $S$FIRST$Z $DIR/$f$Z sl@0: fi sl@0: done