summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorharlowja <harlowja@virtualbox.rhel>2012-06-26 07:55:21 -0700
committerharlowja <harlowja@virtualbox.rhel>2012-06-26 07:55:21 -0700
commit060844af4ec1f9d2d2d7c8763988b4131043dc91 (patch)
treeae7eb3169ef8a13e24bf622aee42ee21dfe42e78
parent12d6cdce560be0b4788ae198f75d783a12b893c2 (diff)
downloadvyos-cloud-init-060844af4ec1f9d2d2d7c8763988b4131043dc91.tar.gz
vyos-cloud-init-060844af4ec1f9d2d2d7c8763988b4131043dc91.zip
Add check that the changelog version is the same as the code version
-rwxr-xr-xtools/read-version21
1 files changed, 20 insertions, 1 deletions
diff --git a/tools/read-version b/tools/read-version
index 4458c712..e6167a2c 100755
--- a/tools/read-version
+++ b/tools/read-version
@@ -5,6 +5,15 @@ import os
import sys
import re
+from distutils import version as ver
+
+possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
+ sys.argv[0]), os.pardir, os.pardir))
+if os.path.exists(os.path.join(possible_topdir, "cloudinit", "__init__.py")):
+ sys.path.insert(0, possible_topdir)
+
+from cloudinit import version as cver
+
def parse_versions(fn):
with open(fn, 'r') as fh:
lines = fh.read().splitlines()
@@ -47,5 +56,15 @@ if __name__ == '__main__':
sys.stderr.write("No versions found in %s!\n" % (fn))
sys.exit(1)
else:
- sys.stdout.write(versions[0].strip())
+ # Check that the code version is the same
+ # as the version we found!
+ ch_ver = versions[0].strip()
+ code_ver = cver.version()
+ ch_ver_obj = ver.StrictVersion(ch_ver)
+ if ch_ver_obj != code_ver:
+ sys.stderr.write(("Code version %s does not match"
+ " changelog version %s\n") %
+ (code_ver, ch_ver_obj))
+ sys.exit(1)
+ sys.stdout.write(ch_ver)
sys.exit(0)