#!/bin/bash
#
# Prepare a new delivery of the same version by changing TAG
#
# $Id$
#
# Syntax: mknewtag
#

dname=`dirname $0`
prem=`echo $dname |cut -c1`
if [ _${prem} = _"/" ]; then
	export TOOLHOME=$dname
else
	export TOOLHOME=${PWD}/$dname
fi

if [ "$1" = "" ]; then
	mods="mindi mondo mondo-doc mindi-busybox mindi-kernel"
else
	mods="$*"
fi

cd $TOOLHOME/..
nb=`svn diff | wc -l`
if [ $nb -gt 0 ]; then
	echo "You'll have to check in before updating the TAG"
	exit -1
else
	for p in $mods; do
		grep -q "${v}" $p/ChangeLog
		if [ $? -ne 0 ]; then
			echo "You'll have to document in ${p}'s ChangeLog for ${v} related modifications"
			exit -1
		fi
	done
	for p in $mods; do
		TAG=`cat $p/TAG`
		v=`cat $p/VERSION`
		echo -n "Changing TAG of $p-$v value from $TAG to "
		((TAG=$TAG+1))
		echo "$TAG"
		echo "$TAG" > $p/TAG
	done
	svn ci -m "Automatic update of TAGs" ; svn up
fi
