#!/bin/sh
VERSION_PERL=$(grep "'VERSION'" perl/Makefile.PL | cut -d"'" -f4)
VERSION_PYTHON=$(grep "version = " python/setup.py | cut -d"'" -f2)
VERSION_DEB=`head -n 1 debian/changelog  | sed -re 's/.+\(([^-)]+).+/\1/'`
VERSION="$VERSION_DEB"

if [ "$VERSION_PERL" != "$VERSION_DEB" ]
then
	echo "Version mismatch between perl ($VERSION_PERL) and debian/changelog ($VERSION_DEB)" >&2
	exit 1
fi

if [ "$VERSION_PYTHON" != "$VERSION_DEB" ]
then
	echo "Version mismatch between python ($VERSION_PYTHON) and debian/changelog ($VERSION_DEB)" >&2
	exit 1
fi

echo "$VERSION"

exit 0
