Brian O'Connor

Fixes to onos_stage to include karaf.zip

Change-Id: Iae00ae0a47150b470a7fc409260ca21824af020e
...@@ -5,6 +5,8 @@ import re ...@@ -5,6 +5,8 @@ import re
5 import os 5 import os
6 from zipfile import ZipFile 6 from zipfile import ZipFile
7 from tarfile import TarFile, TarInfo 7 from tarfile import TarFile, TarInfo
8 +import tarfile
9 +import time
8 from cStringIO import StringIO 10 from cStringIO import StringIO
9 11
10 VERSION = '1.6.0' #FIXME version, and maybe git commit hash 12 VERSION = '1.6.0' #FIXME version, and maybe git commit hash
...@@ -12,11 +14,14 @@ BASE = 'onos-%s/' % VERSION ...@@ -12,11 +14,14 @@ BASE = 'onos-%s/' % VERSION
12 14
13 15
14 written_files = set() 16 written_files = set()
17 +now = time.time()
15 18
16 def addFile(tar, dest, file, file_size): 19 def addFile(tar, dest, file, file_size):
17 if dest not in written_files: 20 if dest not in written_files:
18 info = TarInfo(dest) 21 info = TarInfo(dest)
19 info.size = file_size 22 info.size = file_size
23 + info.mtime = now
24 + info.mode = 0777
20 tar.addfile(info, fileobj=file) 25 tar.addfile(info, fileobj=file)
21 written_files.add(dest) 26 written_files.add(dest)
22 27
...@@ -25,6 +30,8 @@ def addString(tar, dest, string): ...@@ -25,6 +30,8 @@ def addString(tar, dest, string):
25 print dest, string 30 print dest, string
26 info = TarInfo(dest) 31 info = TarInfo(dest)
27 info.size = len(string) 32 info.size = len(string)
33 + info.mtime = now
34 + info.mode = 0777
28 file = StringIO(string) 35 file = StringIO(string)
29 tar.addfile(info, fileobj=file) 36 tar.addfile(info, fileobj=file)
30 file.close() 37 file.close()
...@@ -32,12 +39,13 @@ def addString(tar, dest, string): ...@@ -32,12 +39,13 @@ def addString(tar, dest, string):
32 39
33 def stageOnos(output, files=[]): 40 def stageOnos(output, files=[]):
34 # Note this is not a compressed zip 41 # Note this is not a compressed zip
35 - with TarFile(output, 'a') as output: 42 + with tarfile.open(output, 'w:gz') as output:
36 - written_files = set(output.getnames())
37 for file in files: 43 for file in files:
38 if '.zip' in file: 44 if '.zip' in file:
39 with ZipFile(file, 'r') as zip_part: 45 with ZipFile(file, 'r') as zip_part:
40 for f in zip_part.infolist(): 46 for f in zip_part.infolist():
47 + dest = f.filename
48 + if BASE not in dest:
41 dest = BASE + 'apache-karaf-3.0.5/system/' + f.filename 49 dest = BASE + 'apache-karaf-3.0.5/system/' + f.filename
42 addFile(output, dest, zip_part.open(f), f.file_size) 50 addFile(output, dest, zip_part.open(f), f.file_size)
43 elif '.oar' in file: 51 elif '.oar' in file:
......
...@@ -100,6 +100,6 @@ sources += staged_repos + staged_apps ...@@ -100,6 +100,6 @@ sources += staged_repos + staged_apps
100 genrule( 100 genrule(
101 name = 'onos-package', 101 name = 'onos-package',
102 out = 'onos.tar.gz', 102 out = 'onos.tar.gz',
103 - bash = 'cp $(location :onos-karaf) $OUT && $(exe //buck-tools:onos-stage) $OUT ' + ' '.join(sources), 103 + bash = '$(exe //buck-tools:onos-stage) $OUT $(location :onos-karaf) ' + ' '.join(sources),
104 visibility = [ 'PUBLIC' ], 104 visibility = [ 'PUBLIC' ],
105 ) 105 )
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -56,7 +56,7 @@ cp -r bin $PREFIX ...@@ -56,7 +56,7 @@ cp -r bin $PREFIX
56 cp -r init $PREFIX 56 cp -r init $PREFIX
57 cp -r etc $PREFIX/$KARAF_DIR/etc/ 57 cp -r etc $PREFIX/$KARAF_DIR/etc/
58 58
59 -tar czf $OUT $PREFIX 59 +zip -q -0 -r $OUT $PREFIX
60 60
61 #FIXME 61 #FIXME
62 # Stage all builtin ONOS apps for factory install 62 # Stage all builtin ONOS apps for factory install
......