[rtems-source-builder commit] VERSION is an INI format file.

Chris Johns chrisj at rtems.org
Fri Dec 11 05:27:11 UTC 2015


Module:    rtems-source-builder
Branch:    4.11
Commit:    c07ee80c2c4e76bb458aad084974f72dcc330132
Changeset: http://git.rtems.org/rtems-source-builder/commit/?id=c07ee80c2c4e76bb458aad084974f72dcc330132

Author:    Chris Johns <chrisj at rtems.org>
Date:      Fri Dec 11 16:22:00 2015 +1100

VERSION is an INI format file.

VERSION is an INI format file with 2 sections:

 1. version
  The version of the release. It contains:
    release = version-string
 2. hashes
  A list of hashes for packages that are formed when creating a release.
  A hash entry is:
    file-name = hash-type checksum

The approach means we do not need to hold hash values in configuration files
which need to be updated when a release is made. The release scripts can
generate the hashes when creating the release.

---

 source-builder/sb/options.py |  5 +++++
 source-builder/sb/version.py | 51 +++++++++++++++++++++++++++-----------------
 2 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py
index 890ae2b..ecfc5b8 100644
--- a/source-builder/sb/options.py
+++ b/source-builder/sb/options.py
@@ -624,6 +624,11 @@ def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc'):
     o.process()
     o.post_process()
 
+    #
+    # Load the release hashes
+    #
+    version.load_release_hashes(o.defaults)
+
     return o
 
 def run(args):
diff --git a/source-builder/sb/version.py b/source-builder/sb/version.py
index 95b58cf..50dbf5f 100644
--- a/source-builder/sb/version.py
+++ b/source-builder/sb/version.py
@@ -27,15 +27,14 @@ import sys
 import error
 import git
 import path
-
-major = 4
-minor = 11
-revision = 0
+import sources
 
 #
 # Default to an internal string.
 #
-_version_str =  '%d.%d.%d' % (major, minor, revision)
+_version = '4.11'
+_revision = 'not_released'
+_version_str = '%s.%s' % (_version, _revision)
 _released = False
 _git = False
 
@@ -45,19 +44,23 @@ def _top():
         top = '.'
     return top
 
-def _load_released_version():
-    global _released
-    global _version_str
+def _load_released_version_config():
     top = _top()
     for ver in [top, '..']:
         if path.exists(path.join(ver, 'VERSION')):
-            try:
-                with open(path.join(ver, 'VERSION')) as v:
-                    _version_str = v.readline().strip()
-                v.close()
-                _released = True
-            except:
-                raise error.general('Cannot access the VERSION file')
+            import ConfigParser
+            v = ConfigParser.SafeConfigParser()
+            v.read(path.join(ver, 'VERSION'))
+            return v
+    return None
+
+def _load_released_version():
+    global _released
+    global _version_str
+    v = _load_released_version_config()
+    if v is not None:
+        _version_str = v.get('version', 'release')
+        _released = True
     return _released
 
 def _load_git_version():
@@ -70,7 +73,7 @@ def _load_git_version():
             modified = ' modified'
         else:
             modified = ''
-        _version_str = '%d.%d.%d (%s%s)' % (major, minor, revision, head[0:12], modified)
+        _version_str = '%s (%s%s)' % (_version, head[0:12], modified)
         _git = True
     return _git
 
@@ -86,8 +89,18 @@ def str():
             _load_git_version()
     return _version_str
 
+def load_release_hashes(macros):
+    def hash_error(msg):
+        raise error.general(msg)
+
+    if released():
+        v = _load_released_version_config()
+        if v is not None:
+            for hash in v.items('hashes'):
+                hs = hash[1].split()
+                if len(hs) != 2:
+                    raise error.general('invalid release hash in VERSION')
+                sources.hash((hs[0], hash[0], hs[1]), macros, hash_error)
+
 if __name__ == '__main__':
-    print 'major = %d' % (major)
-    print 'minor = %d' % (minor)
-    print 'revision = %d' % (revision)
     print 'Version: %s' % (str())



More information about the vc mailing list