[Spice-devel] server: add dist-hook to prevent spice version configure/spice.h difference

Submitted by Alon Levy on Sept. 3, 2012, 7:31 a.m.

Details

Message ID 1346657472-13883-1-git-send-email-alevy@redhat.com
State Accepted
Commit 078742b0ee05120c5f7a6f06d117ce10c68afe7a
Headers show

Not browsing as part of any series.

Commit Message

Alon Levy Sept. 3, 2012, 7:31 a.m.
---
 server/Makefile.am                 |  3 +++
 server/tests/test_spice_version.sh | 42 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100755 server/tests/test_spice_version.sh

Patch hide | download patch | download mbox

diff --git a/server/Makefile.am b/server/Makefile.am
index 16c8b6d..18a9d8a 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -127,3 +127,6 @@  EXTRA_DIST =					\
 	$(NULL)
 
 BUILT_SOURCES = $(spice_built_sources)
+
+dist-hook:
+	if ! ./tests/test_spice_version.sh ; then exit 1; fi
diff --git a/server/tests/test_spice_version.sh b/server/tests/test_spice_version.sh
new file mode 100755
index 0000000..5e5b173
--- /dev/null
+++ b/server/tests/test_spice_version.sh
@@ -0,0 +1,42 @@ 
+#!/bin/bash
+
+ROOT=$(dirname $0)/../../
+INCLUDE="-I$ROOT -I$ROOT/spice-common/spice-protocol/"
+TEMP=`mktemp -d`
+
+cat > $TEMP/check_version.c <<EOF
+#include <stdio.h>
+#include "server/spice.h"
+
+int main(void)
+{
+        printf("%d.%d.%d\n", SPICE_SERVER_VERSION >> 16,
+               (SPICE_SERVER_VERSION >> 8) & 0xff,
+               SPICE_SERVER_VERSION & 0xff);
+        return 0;
+}
+EOF
+
+if ! gcc -o $TEMP/check_version $INCLUDE $TEMP/check_version.c ; then
+    echo "failed to compile tester"
+    exit -1
+fi
+
+INCLUDE_VERSION=`$TEMP/check_version`
+rm -Rf $TEMP
+
+CONF_MAJOR=`cat $ROOT/configure.ac | grep 'm4_define(\[SPICE_MAJOR\]' | sed -e 's/m4_define(\[SPICE_MAJOR\],\(.*\))/\1/'`
+CONF_MINOR=`cat $ROOT/configure.ac | grep 'm4_define(\[SPICE_MINOR\]' | sed -e 's/m4_define(\[SPICE_MINOR\],\(.*\))/\1/'`
+CONF_MICRO=`cat $ROOT/configure.ac | grep 'm4_define(\[SPICE_MICRO\]' | sed -e 's/m4_define(\[SPICE_MICRO\],\(.*\))/\1/'`
+CONF_VERSION=`printf %d.%d.%d $CONF_MAJOR $CONF_MINOR $CONF_MICRO`
+if [ $CONF_VERSION != $INCLUDE_VERSION ] ; then
+    echo "BAD: version in server/spice.h"
+    echo $INCLUDE_VERSION
+    echo "doesn't match version in configure.ac"
+    echo $CONF_VERSION
+    echo "please fix before doing a release"
+    exit 1
+else
+    echo "OK: both versions are $CONF_VERSION"
+fi
+exit 0