Subversion Repositories mkgmap

Rev

Rev 2464 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/bin/bash

PROGDIR=$(dirname $(readlink -f $0))
PATH=$JAVA_HOME/bin:/opt/jars/apache-ant-1.8.2/bin:/opt/jars/apache-ant-1.7.1/bin:/usr/bin:/bin:/usr/local/bin:$PROGDIR

typeset -i VERSION
while getopts "r:d:" c
do
        case $c in
        r) VERSION=$OPTARG;;
        d) SNAPDIR=$OPTARG;;
        esac
done
shift $[OPTIND-1]

PRODUCT=$1
if [ "$PRODUCT" = "" ]; then
        echo Usage: "mksnap [-d dir] [-r vers] <product>"
        exit
fi

source mksnapfuncs

export LANG=en_GB.UTF-8

export JAVA_HOME=/opt/java

SVN=http://svn.parabola.me.uk/$PRODUCT
if [ "$VERSION" = "" ]; then
VERSION=$(svn log --xml --limit 1 $SVN/trunk 2> /dev/null | sed \
        -n 's/revision="\([0-9]*\)".*/\1/p' | head -1)
LATEST=1
fi
SPACE='&nbsp;&nbsp;&nbsp;'

SNAPDIR=${SNAPDIR:-$HOME/www/mkgmap.org.uk/docroot/download}
RELNAME=$PRODUCT-r$VERSION
TARGET=$SNAPDIR/$RELNAME.tar.gz
TARGET_SRC=$SNAPDIR/$RELNAME-src.tar.gz
TARGET_SRC_LATEST_TAR=$SNAPDIR/$PRODUCT-src.tar.gz
TARGET_SRC_LATEST_ZIP=$SNAPDIR/$PRODUCT-src.zip
TARGET_ZIP=$SNAPDIR/$RELNAME.zip

BUILD_DIST=1
BUILD_TARGETS='dist'
case "$PRODUCT" in
display)
        BUILD_DIST=0
        ;;
mkgmap)
        BUILD_TARGETS='dist obtain-test-input-files test'
        ;;
splitter)
        BUILD_TARGETS='dist run.tests'
        ;;
esac

if [ ! -f $TARGET ]; then
        echo Rebuilding
        cd /usr/tmp

        BUILD_DIR=/usr/tmp/build-mkgmap/$RELNAME
        mkdir -p $(dirname $BUILD_DIR)
        trap "rm -rf $BUILD_DIR" 0

        svn export -q -r$VERSION $SVN/trunk $BUILD_DIR

        # Create a pure source distribution
        tar czCf $(dirname $BUILD_DIR) $TARGET_SRC $RELNAME
        ln -f $TARGET_SRC $TARGET_SRC_LATEST_TAR
        rm -f $TARGET_SRC_LATEST_ZIP
        (cd $(dirname $BUILD_DIR); zip -r $TARGET_SRC_LATEST_ZIP $RELNAME) > /dev/null

        cd $BUILD_DIR
        if [ -d resources ]; then
                echo "svn.version: $VERSION" > resources/$PRODUCT-version.properties
                echo "build.timestamp: $(date -Iseconds)" >> resources/$PRODUCT-version.properties
        fi

        if [ "$BUILD_DIST" = 1 ]; then
                echo BUILDING TARGET
                ant -Dhave.version=1 $BUILD_TARGETS || exit 1

                if [ -x $PROGDIR/mkdoc ]; then
                        mkdoc $PRODUCT
                fi

                mv dist $RELNAME
                tar czf $TARGET $RELNAME
                zip -r $TARGET_ZIP $RELNAME
        fi
fi

cd $SNAPDIR
rm -f $PRODUCT-latest.tar.gz

if [ "$LATEST" = 1 -a "$BUILD_DIST" = 1 ]; then
        ln $RELNAME.tar.gz $PRODUCT-latest.tar.gz
fi

if [ "$BUILD_DIST" = 1 ]; then
        mksnap_setdate $RELNAME.tar.gz $VERSION
fi

mksnapindex -d $SNAPDIR $PRODUCT