#!/bin/sh

if [ $# -lt 1 ] ; then
    echo "Usage: bumpver <version>" >&2
    exit 1
fi
cd `dirname $0`/..
export NVER=$1
LVER=$(git describe --tags `git rev-list --tags --max-count=1`)
perl -pi -e 's/VERSION\s+[\d\.]+$/VERSION $ENV{"NVER"}/' CMakeLists.txt
perl -pi -e 's/%define\s+ver\s+.*$/%define ver $ENV{"NVER"}/' catlock.spec
sed -n -e '1,/%changelog/p' catlock.spec > $$.1
gcg -c $NVER -P v -n catlock -D unstable -O rpm -o $$.2
cat $$.1 $$.2 > catlock.spec
rm -f $$.1 $$.2
gcg -c $NVER -P v -n catlock -D unstable -O deb -o debian/changelog
