imip-agent

Annotated docs/tools/make_pages.sh

1362:d96b4761e6f0
2017-10-24 Paul Boddie Remove superfluous result collection slicing and count method parameter.
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
paul@1218 7
if [ ! "$OUTDIR" ] || [ "$1" = '--help' ] ; then
paul@985 8
    cat 1>&2 <<EOF
paul@1104 9
Usage: $PROGNAME <output directory> [ <page prefix> ] [ --releases [ --sign ] ]
paul@985 10
EOF
paul@985 11
    exit 1
paul@985 12
fi
paul@985 13
paul@985 14
if [ -e "$OUTDIR" ]; then
paul@985 15
    echo "Please remove $OUTDIR before generating a new package." 1>&2
paul@985 16
    exit 1
paul@985 17
fi
paul@985 18
paul@1104 19
if [ "$2" = '--releases' ]; then
paul@1104 20
    PREFIX=
paul@1104 21
    RELEASES=$2
paul@1104 22
    SIGN=$3
paul@1104 23
else
paul@1104 24
    PREFIX=$2
paul@1104 25
    RELEASES=$3
paul@1104 26
    SIGN=$4
paul@1104 27
fi
paul@1104 28
paul@1104 29
# Generate release archives. These are held in a separate, semi-permanent
paul@1104 30
# place so that archives and signatures are not regenerated unnecessarily.
paul@1104 31
paul@1104 32
if [ "$RELEASES" ]; then
paul@1104 33
    "$DIRNAME/make_releases.sh" releases
paul@1104 34
fi
paul@1104 35
paul@1104 36
if [ "$SIGN" ]; then
paul@1104 37
    "$DIRNAME/sign_releases.sh" releases
paul@1104 38
fi
paul@1104 39
paul@1104 40
# Generate a manifest for the page package.
paul@1104 41
paul@985 42
MANIFEST="$OUTDIR/MOIN_PACKAGE"
paul@985 43
paul@985 44
mkdir "$OUTDIR"
paul@985 45
cat > "$MANIFEST" <<EOF
paul@985 46
MoinMoinPackage|1
paul@985 47
EOF
paul@985 48
paul@1104 49
# Add the pages to the manifest.
paul@1104 50
paul@998 51
DOCS="$DIRNAME/../wiki"
paul@985 52
paul@1104 53
cp "$DOCS/"* "$OUTDIR"
paul@1104 54
paul@985 55
for FILENAME in "$DOCS/"* ; do
paul@985 56
    BASENAME=`basename "$FILENAME"`
paul@985 57
    PAGENAME=`echo "$BASENAME" | sed 's/--/\//g'`
paul@985 58
    if [ "$PREFIX" ]; then
paul@985 59
        if [ "$PAGENAME" = "FrontPage" ]; then
paul@985 60
            PAGENAME="$PREFIX"
paul@985 61
        else
paul@985 62
            PAGENAME="$PREFIX/$PAGENAME"
paul@985 63
        fi
paul@985 64
    fi
paul@985 65
    echo "AddRevision|$BASENAME|$PAGENAME" >> "$MANIFEST"
paul@985 66
done
paul@985 67
paul@1226 68
if [ ! -e "releases" ]; then
paul@1226 69
    echo "No releases to add to the page package!" 1>&2
paul@1226 70
else
paul@1226 71
    # Combine the releases with the pages.
paul@1104 72
paul@1226 73
    ATTACHMENT="attachment_"
paul@1226 74
paul@1226 75
    for FILENAME in releases/* ; do
paul@1226 76
        BASENAME=`basename "$FILENAME"`
paul@1226 77
        cp "$FILENAME" "$OUTDIR/$ATTACHMENT$BASENAME"
paul@1226 78
    done
paul@1104 79
paul@1226 80
    # Add the releases to the manifest.
paul@1104 81
paul@1226 82
    for FILENAME in releases/* ; do
paul@1226 83
        BASENAME=`basename "$FILENAME"`
paul@1226 84
        PAGENAME="Downloads"
paul@1226 85
        if [ "$PREFIX" ]; then
paul@1226 86
            PAGENAME="$PREFIX/$PAGENAME"
paul@1226 87
        fi
paul@1226 88
        echo "AddAttachment|$ATTACHMENT$BASENAME|$BASENAME|$PAGENAME" >> "$MANIFEST"
paul@1226 89
    done
paul@1226 90
fi
paul@1104 91
paul@985 92
zip -j "$OUTDIR" "$OUTDIR/"*