diff mbox

[ovs-dev] automake: Consolidate schema checksum check.

Message ID 1443801910-16535-1-git-send-email-gshetty@nicira.com
State Accepted
Headers show

Commit Message

Gurucharan Shetty Oct. 2, 2015, 4:05 p.m. UTC
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
---
 Makefile.am                  |    1 +
 build-aux/cksum-schema-check |   15 +++++++++++++++
 ovn/automake.mk              |   20 ++------------------
 vswitchd/automake.mk         |   10 +---------
 vtep/automake.mk             |   10 +---------
 5 files changed, 20 insertions(+), 36 deletions(-)
 create mode 100755 build-aux/cksum-schema-check

Comments

Ben Pfaff Oct. 2, 2015, 5:09 p.m. UTC | #1
On Fri, Oct 02, 2015 at 09:05:10AM -0700, Gurucharan Shetty wrote:
> Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>

It looks correct, though I did not test it.  Thanks!

Acked-by: Ben Pfaff <blp@nicira.com>
diff mbox

Patch

diff --git a/Makefile.am b/Makefile.am
index ab1a135..14da875 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -102,6 +102,7 @@  EXTRA_DIST = \
 	.travis/prepare.sh \
 	boot.sh \
 	build-aux/cccl \
+	build-aux/cksum-schema-check \
 	build-aux/dist-docs \
 	build-aux/sodepends.pl \
 	build-aux/soexpand.pl \
diff --git a/build-aux/cksum-schema-check b/build-aux/cksum-schema-check
new file mode 100755
index 0000000..75fcd6e
--- /dev/null
+++ b/build-aux/cksum-schema-check
@@ -0,0 +1,15 @@ 
+#!/bin/sh
+
+schema=$1
+stamp=$2
+
+sum=`sed '/cksum/d' $schema | cksum`
+expected=`sed -n 's/.*"cksum": "\(.*\)".*/\1/p' $schema`
+if test "X$sum" = "X$expected"; then
+    touch $stamp
+else
+    ln=`sed -n '/"cksum":/=' $schema`
+    echo >&2 "$schema:$ln: The checksum \"$sum\" was calculated from the schema file and does not match cksum field in the schema file - you should probably update the version number and the checksum in the schema file with the value listed here."
+    exit 1
+fi
+
diff --git a/ovn/automake.mk b/ovn/automake.mk
index 4b6a836..f3f40e5 100644
--- a/ovn/automake.mk
+++ b/ovn/automake.mk
@@ -78,29 +78,13 @@  EXTRA_DIST += \
 # Version checking for ovn-nb.ovsschema.
 ALL_LOCAL += ovn/ovn-nb.ovsschema.stamp
 ovn/ovn-nb.ovsschema.stamp: ovn/ovn-nb.ovsschema
-	@sum=`sed '/cksum/d' $? | cksum`; \
-	expected=`sed -n 's/.*"cksum": "\(.*\)".*/\1/p' $?`; \
-	if test "X$$sum" = "X$$expected"; then \
-		touch $@; \
-	else \
-		ln=`sed -n '/"cksum":/=' $?`; \
-		echo >&2 "$?:$$ln: The checksum \"$$sum\" was calculated from the schema file and does not match cksum field in the schema file - you should probably update the version number and the checksum in the schema file with the value listed here."; \
-		exit 1; \
-	fi
+	$(srcdir)/build-aux/cksum-schema-check $? $@
 CLEANFILES += ovn/ovn-nb.ovsschema.stamp
 
 # Version checking for ovn-sb.ovsschema.
 ALL_LOCAL += ovn/ovn-sb.ovsschema.stamp
 ovn/ovn-sb.ovsschema.stamp: ovn/ovn-sb.ovsschema
-	@sum=`sed '/cksum/d' $? | cksum`; \
-	expected=`sed -n 's/.*"cksum": "\(.*\)".*/\1/p' $?`; \
-	if test "X$$sum" = "X$$expected"; then \
-		touch $@; \
-	else \
-		ln=`sed -n '/"cksum":/=' $?`; \
-		echo >&2 "$?:$$ln: The checksum \"$$sum\" was calculated from the schema file and does not match cksum field in the schema file - you should probably update the version number and the checksum in the schema file with the value listed here."; \
-		exit 1; \
-	fi
+	$(srcdir)/build-aux/cksum-schema-check $? $@
 CLEANFILES += ovn/ovn-sb.ovsschema.stamp
 
 include ovn/controller/automake.mk
diff --git a/vswitchd/automake.mk b/vswitchd/automake.mk
index 81f201a..8d7f3ea 100644
--- a/vswitchd/automake.mk
+++ b/vswitchd/automake.mk
@@ -57,15 +57,7 @@  vswitchd/ovs-vswitchd.conf.db.5: \
 # Version checking for vswitch.ovsschema.
 ALL_LOCAL += vswitchd/vswitch.ovsschema.stamp
 vswitchd/vswitch.ovsschema.stamp: vswitchd/vswitch.ovsschema
-	@sum=`sed '/cksum/d' $? | cksum`; \
-	expected=`sed -n 's/.*"cksum": "\(.*\)".*/\1/p' $?`; \
-	if test "X$$sum" = "X$$expected"; then \
-	  touch $@; \
-	else \
-	  ln=`sed -n '/"cksum":/=' $?`; \
-	  echo >&2 "$?:$$ln: The checksum \"$$sum\" was calculated from the schema file and does not match cksum field in the schema file - you should probably update the version number and the checksum in the schema file with the value listed here."; \
-	  exit 1; \
-	fi
+	$(srcdir)/build-aux/cksum-schema-check $? $@
 CLEANFILES += vswitchd/vswitch.ovsschema.stamp
 
 # Clean up generated files from older OVS versions.  (This is important so that
diff --git a/vtep/automake.mk b/vtep/automake.mk
index 6027fd2..de028b6 100644
--- a/vtep/automake.mk
+++ b/vtep/automake.mk
@@ -80,13 +80,5 @@  vtep/vtep.5: \
 # Version checking for vtep.ovsschema.
 ALL_LOCAL += vtep/vtep.ovsschema.stamp
 vtep/vtep.ovsschema.stamp: vtep/vtep.ovsschema
-	@sum=`sed '/cksum/d' $? | cksum`; \
-	expected=`sed -n 's/.*"cksum": "\(.*\)".*/\1/p' $?`; \
-	if test "X$$sum" = "X$$expected"; then \
-	  touch $@; \
-	else \
-	  ln=`sed -n '/"cksum":/=' $?`; \
-	  echo >&2 "$?:$$ln: The checksum \"$$sum\" was calculated from the schema file and does not match cksum field in the schema file - you should probably update the version number and the checksum in the schema file with the value listed here."; \
-	  exit 1; \
-	fi
+	$(srcdir)/build-aux/cksum-schema-check $? $@
 CLEANFILES += vtep/vtep.ovsschema.stamp