Brian O'Connor

Updating onos_stage.py to use ONOS_VERSION global

Also, fixing up the base directory for RC packaging.

Change-Id: Id3c80a75ec27bd887b01a04a3122a2660c8f281b
...@@ -9,9 +9,6 @@ import tarfile ...@@ -9,9 +9,6 @@ import tarfile
9 import time 9 import time
10 from cStringIO import StringIO 10 from cStringIO import StringIO
11 11
12 -VERSION = '1.7.0' #FIXME version, and maybe git commit hash
13 -BASE = 'onos-%s/' % VERSION
14 -
15 12
16 written_files = set() 13 written_files = set()
17 now = time.time() 14 now = time.time()
...@@ -37,7 +34,9 @@ def addString(tar, dest, string): ...@@ -37,7 +34,9 @@ def addString(tar, dest, string):
37 file.close() 34 file.close()
38 written_files.add(dest) 35 written_files.add(dest)
39 36
40 -def stageOnos(output, files=[]): 37 +def stageOnos(output, version, files=[]):
38 + base = 'onos-%s/' % version
39 +
41 # Note this is not a compressed zip 40 # Note this is not a compressed zip
42 with tarfile.open(output, 'w:gz') as output: 41 with tarfile.open(output, 'w:gz') as output:
43 for file in files: 42 for file in files:
...@@ -45,40 +44,41 @@ def stageOnos(output, files=[]): ...@@ -45,40 +44,41 @@ def stageOnos(output, files=[]):
45 with ZipFile(file, 'r') as zip_part: 44 with ZipFile(file, 'r') as zip_part:
46 for f in zip_part.infolist(): 45 for f in zip_part.infolist():
47 dest = f.filename 46 dest = f.filename
48 - if BASE not in dest: 47 + if base not in dest:
49 - dest = BASE + 'apache-karaf-3.0.5/system/' + f.filename 48 + dest = base + 'apache-karaf-3.0.5/system/' + f.filename
50 addFile(output, dest, zip_part.open(f), f.file_size) 49 addFile(output, dest, zip_part.open(f), f.file_size)
51 elif '.oar' in file: 50 elif '.oar' in file:
52 with ZipFile(file, 'r') as oar: 51 with ZipFile(file, 'r') as oar:
53 app_xml = oar.open('app.xml').read() 52 app_xml = oar.open('app.xml').read()
54 app_name = re.search('name="([^"]+)"', app_xml).group(1) 53 app_name = re.search('name="([^"]+)"', app_xml).group(1)
55 - dest = BASE + 'apps/%(name)s/%(name)s.oar' % { 'name': app_name} 54 + dest = base + 'apps/%(name)s/%(name)s.oar' % { 'name': app_name}
56 addFile(output, dest, open(file), os.stat(file).st_size) 55 addFile(output, dest, open(file), os.stat(file).st_size)
57 - dest = BASE + 'apps/%s/app.xml' % app_name 56 + dest = base + 'apps/%s/app.xml' % app_name
58 addString(output, dest, app_xml) 57 addString(output, dest, app_xml)
59 for f in oar.infolist(): 58 for f in oar.infolist():
60 filename = f.filename 59 filename = f.filename
61 if 'm2' in filename: 60 if 'm2' in filename:
62 - dest = BASE + 'apache-karaf-3.0.5/system/' + filename[3:] 61 + dest = base + 'apache-karaf-3.0.5/system/' + filename[3:]
63 if dest not in written_files: 62 if dest not in written_files:
64 addFile(output, dest, oar.open(f), f.file_size) 63 addFile(output, dest, oar.open(f), f.file_size)
65 written_files.add(dest) 64 written_files.add(dest)
66 elif 'features.xml' in file: 65 elif 'features.xml' in file:
67 - dest = BASE + 'apache-karaf-3.0.5/system/org/onosproject/onos-features/1.7.0-SNAPSHOT/' 66 + dest = base + 'apache-karaf-3.0.5/system/org/onosproject/onos-features/%s/' % version
68 - dest += 'onos-features-1.7.0-SNAPSHOT-features.xml' 67 + dest += 'onos-features-%s-features.xml' % version
69 with open(file) as f: 68 with open(file) as f:
70 addFile(output, dest, f, os.stat(file).st_size) 69 addFile(output, dest, f, os.stat(file).st_size)
71 - addString(output, BASE + 'apps/org.onosproject.drivers/active', '') 70 + addString(output, base + 'apps/org.onosproject.drivers/active', '')
72 - addString(output, BASE + 'VERSION', VERSION) 71 + addString(output, base + 'VERSION', version)
73 72
74 if __name__ == '__main__': 73 if __name__ == '__main__':
75 import sys 74 import sys
76 75
77 - if len(sys.argv) < 2: 76 + if len(sys.argv) < 3:
78 - print 'USAGE' 77 + print 'USAGE' #FIXME
79 sys.exit(1) 78 sys.exit(1)
80 79
81 output = sys.argv[1] 80 output = sys.argv[1]
82 - args = sys.argv[2:] 81 + version = sys.argv[2]
82 + args = sys.argv[3:]
83 83
84 - stageOnos(output, args) 84 + stageOnos(output, version, args)
......
...@@ -12,7 +12,7 @@ BRANDING=$4 ...@@ -12,7 +12,7 @@ BRANDING=$4
12 #FIXME karaf version 12 #FIXME karaf version
13 KARAF_VERSION="3.0.5" 13 KARAF_VERSION="3.0.5"
14 14
15 -PREFIX="onos-${ONOS_VERSION/-*/}" 15 +PREFIX="onos-${ONOS_VERSION/-SNAPSHOT/}"
16 16
17 # Unroll the Apache Karaf bits, prune them and make ONOS top-level directories. 17 # Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
18 tar xf $KARAF_TAR 18 tar xf $KARAF_TAR
......