| author | sl |
| Tue, 10 Jun 2014 14:32:02 +0200 | |
| changeset 1 | 260cb5ec6c19 |
| permissions | -rw-r--r-- |
| sl@0 | 1 |
#!/bin/sh |
| sl@0 | 2 |
|
| sl@0 | 3 |
ZIP=: |
| sl@0 | 4 |
while true; do |
| sl@0 | 5 |
case $1 in |
| sl@0 | 6 |
-s | --symlinks ) S="-s ";; |
| sl@0 | 7 |
-z | --compress ) ZIP=$2; shift ;; |
| sl@0 | 8 |
-e | --extension ) Z=$2; shift ;; |
| sl@0 | 9 |
-s | --suffix ) SUFFIX=$2; shift ;; |
| sl@0 | 10 |
*) break ;; |
| sl@0 | 11 |
esac |
| sl@0 | 12 |
shift |
| sl@0 | 13 |
done |
| sl@0 | 14 |
if test "$#" != 2; then |
| sl@0 | 15 |
echo "Usage: installManPages <options> file dir" |
| sl@0 | 16 |
exit 1 |
| sl@0 | 17 |
fi |
| sl@0 | 18 |
|
| sl@0 | 19 |
MANPAGE=$1 |
| sl@0 | 20 |
DIR=$2 |
| sl@0 | 21 |
test -z "$S" && S="$DIR/" |
| sl@0 | 22 |
|
| sl@0 | 23 |
# A sed script to parse the alternative names out of a man page. |
| sl@0 | 24 |
# |
| sl@0 | 25 |
# /^\\.SH NAME/{ ;# Look for a line, that starts with .SH NAME
|
| sl@0 | 26 |
# s/^.*$// ;# Delete the content of this line from the buffer |
| sl@0 | 27 |
# n ;# Read next line |
| sl@0 | 28 |
# s/,//g ;# Remove all commas ... |
| sl@0 | 29 |
# s/\\\ //g ;# .. and backslash-escaped spaces. |
| sl@0 | 30 |
# s/ \\\-.*// ;# Delete from \- to the end of line |
| sl@0 | 31 |
# p ;# print the result |
| sl@0 | 32 |
# q ;# exit |
| sl@0 | 33 |
# } |
| sl@0 | 34 |
# |
| sl@0 | 35 |
# Backslashes are trippled in the sed script, because it is in |
| sl@0 | 36 |
# backticks which don't pass backslashes literally. |
| sl@0 | 37 |
# |
| sl@0 | 38 |
# Please keep the commented version above updated if you |
| sl@0 | 39 |
# change anything to the script below. |
| sl@0 | 40 |
NAMES=`sed -n ' |
| sl@0 | 41 |
/^\\.SH NAME/{
|
| sl@0 | 42 |
s/^.*$// |
| sl@0 | 43 |
n |
| sl@0 | 44 |
s/,//g |
| sl@0 | 45 |
s/\\\ //g |
| sl@0 | 46 |
s/ \\\-.*// |
| sl@0 | 47 |
p |
| sl@0 | 48 |
q |
| sl@0 | 49 |
}' $MANPAGE` |
| sl@0 | 50 |
|
| sl@0 | 51 |
SECTION=`echo $MANPAGE | sed 's/.*\(.\)$/\1/'` |
| sl@0 | 52 |
SRCDIR=`dirname $MANPAGE` |
| sl@0 | 53 |
FIRST="" |
| sl@0 | 54 |
for f in $NAMES; do |
| sl@0 | 55 |
f=$f.$SECTION$SUFFIX |
| sl@0 | 56 |
if test -z "$FIRST" ; then |
| sl@0 | 57 |
FIRST=$f |
| sl@0 | 58 |
rm -f $DIR/$FIRST $DIR/$FIRST.* |
| sl@0 | 59 |
sed -e "/man\.macros/r $SRCDIR/man.macros" -e "/man\.macros/d" \ |
| sl@0 | 60 |
$MANPAGE > $DIR/$FIRST |
| sl@0 | 61 |
chmod 444 $DIR/$FIRST |
| sl@0 | 62 |
$ZIP $DIR/$FIRST |
| sl@0 | 63 |
else |
| sl@0 | 64 |
rm -f $DIR/$f $DIR/$f.* |
| sl@0 | 65 |
ln $S$FIRST$Z $DIR/$f$Z |
| sl@0 | 66 |
fi |
| sl@0 | 67 |
done |