imip-agent

Annotated docs/tools/make_pages.sh

1024:48b37822d2a0
2016-01-29 Paul Boddie Moved common test initialisation into a separate script.
paul@985 1
#!/bin/sh
paul@985 2
paul@985 3
DIRNAME=`dirname $0`
paul@985 4
PROGNAME=`basename $0`
paul@985 5
OUTDIR=$1
paul@985 6
PREFIX=$2
paul@985 7
paul@985 8
if [ ! "$OUTDIR" ]; then
paul@985 9
    cat 1>&2 <<EOF
paul@985 10
Usage: $PROGNAME <output filename> [ <page prefix> ]
paul@985 11
EOF
paul@985 12
    exit 1
paul@985 13
fi
paul@985 14
paul@985 15
if [ -e "$OUTDIR" ]; then
paul@985 16
    echo "Please remove $OUTDIR before generating a new package." 1>&2
paul@985 17
    exit 1
paul@985 18
fi
paul@985 19
paul@985 20
MANIFEST="$OUTDIR/MOIN_PACKAGE"
paul@985 21
paul@985 22
mkdir "$OUTDIR"
paul@985 23
cat > "$MANIFEST" <<EOF
paul@985 24
MoinMoinPackage|1
paul@985 25
EOF
paul@985 26
paul@998 27
DOCS="$DIRNAME/../wiki"
paul@985 28
paul@985 29
for FILENAME in "$DOCS/"* ; do
paul@985 30
    BASENAME=`basename "$FILENAME"`
paul@985 31
    PAGENAME=`echo "$BASENAME" | sed 's/--/\//g'`
paul@985 32
    if [ "$PREFIX" ]; then
paul@985 33
        if [ "$PAGENAME" = "FrontPage" ]; then
paul@985 34
            PAGENAME="$PREFIX"
paul@985 35
        else
paul@985 36
            PAGENAME="$PREFIX/$PAGENAME"
paul@985 37
        fi
paul@985 38
    fi
paul@985 39
    echo "AddRevision|$BASENAME|$PAGENAME" >> "$MANIFEST"
paul@985 40
done
paul@985 41
paul@985 42
cp "$DOCS/"* "$OUTDIR"
paul@985 43
zip -j "$OUTDIR" "$OUTDIR/"*