#!/bin/sh
VERSION_SRC1=`grep ^VERSION= update-apt-xapian-index | sed -re 's/^.+"([^"]+)".*/\1/'`
VERSION_SRC2=`grep ^VERSION= axi-cache | sed -re 's/^.+"([^"]+)".*/\1/'`
VERSION_DEB=`head -n 1 debian/changelog | sed -re 's/[^(]+\(([^)]+)\).+/\1/'`
VERSION="$VERSION_SRC1"

if [ "$VERSION_SRC1" != "$VERSION_DEB" ]
then
	echo "Version mismatch between update-a-x-i source ($VERSION_SRC1) and debian/changelog ($VERSION_DEB)" >&2
	exit 1
fi

if [ "$VERSION_SRC2" != "$VERSION_DEB" ]
then
	echo "Version mismatch between axi-cache source ($VERSION_SRC2) and debian/changelog ($VERSION_DEB)" >&2
	exit 1
fi

echo "$VERSION"
exit 0
