Stamping the snapshot builds with the short version of the current git hash.
Change-Id: I141437694b5b8e1b33925d60b09f35d2ae59de10
diff --git a/buck-tools/onos_stage.py b/buck-tools/onos_stage.py
index 23002c6..8991dfa 100755
--- a/buck-tools/onos_stage.py
+++ b/buck-tools/onos_stage.py
@@ -8,6 +8,7 @@
import tarfile
import time
from cStringIO import StringIO
+import subprocess
written_files = set()
@@ -34,9 +35,18 @@
file.close()
written_files.add(dest)
+def getHash():
+ p = subprocess.Popen('git rev-parse --verify HEAD --short', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+ (output, err) = p.communicate()
+ return output if p.wait() == 0 else '0000000000'
+
def stageOnos(output, version, files=[]):
base = 'onos-%s/' % version
+ runtimeVersion = version
+ if version.endswith('-SNAPSHOT'):
+ runtimeVersion = version.replace('-SNAPSHOT', '.%s' % getHash())
+
# Note this is not a compressed zip
with tarfile.open(output, 'w:gz') as output:
for file in files:
@@ -68,7 +78,7 @@
with open(file) as f:
addFile(output, dest, f, os.stat(file).st_size)
addString(output, base + 'apps/org.onosproject.drivers/active', '')
- addString(output, base + 'VERSION', version)
+ addString(output, base + 'VERSION', runtimeVersion)
if __name__ == '__main__':
import sys