|
1 # |
|
2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 |
|
17 import re, shutil, sys, os.path, traceback, zipfile |
|
18 from optparse import OptionParser |
|
19 |
|
20 class J9PackageConverter: |
|
21 def __init__(self, srcRoot, destRoot): |
|
22 self.srcRoot = srcRoot + "/j9_s60" |
|
23 self.destRoot = destRoot |
|
24 self.wastebasket = set() |
|
25 self.currentSrcRoot = None |
|
26 self.currentDestRoot = None |
|
27 |
|
28 def convert(self): |
|
29 self.createPackages("weme") |
|
30 self.createPackages("wece") |
|
31 return |
|
32 |
|
33 |
|
34 def createPackages(self, delivery): |
|
35 self.currentSrcRoot = self.srcRoot + "/" + delivery |
|
36 |
|
37 dirToDelete = self.currentSrcRoot + "/opt" |
|
38 if os.path.exists(dirToDelete): |
|
39 shutil.rmtree(dirToDelete) |
|
40 |
|
41 self.currentSrcRoot += "/non-opt/epoc32/release/" |
|
42 |
|
43 self.currentDestRoot = self.destRoot + "/" + delivery +"/" |
|
44 if not os.path.exists(self.currentDestRoot): |
|
45 os.makedirs(self.currentDestRoot) |
|
46 |
|
47 self.dozip("armv592.zip", j9ArmFiles) |
|
48 self.dozip("winscw92.zip", j9WinsFiles) |
|
49 self.dozip("locale.variants.fp.zip", j9LocaleVariantFilesFp) |
|
50 self.dozip("locale.variants.cdc.zip", j9LocaleVariantFilesCdc) |
|
51 #self.doCopy(j9IncFiles, root) |
|
52 self.dozip("properties.zip", j9PropertyFiles) |
|
53 self.dozip("security.zip", j9SecurityFiles) |
|
54 self.dozip("misc.zip", j9MiscFiles) |
|
55 self.doCopy(j9FilesToCopy) |
|
56 self.doDelete(j9FilesToIgnore) |
|
57 if delivery == "wece": |
|
58 self.doCopy(j9JavaSrcFiles) |
|
59 else: |
|
60 self.doDelete(j9WemeFilesToIgnore) |
|
61 |
|
62 def clean(self): |
|
63 for file in self.wastebasket: |
|
64 if os.path.exists(file): |
|
65 #print "Removing file "+file |
|
66 os.remove(file) |
|
67 |
|
68 def visitFun(arg, dirname, names): |
|
69 for file in names: |
|
70 if os.path.isfile(dirname + "/" + file): |
|
71 print "ERROR: Dir " + dirname + " contained file " + file |
|
72 |
|
73 os.path.walk(self.srcRoot, visitFun, None) |
|
74 return |
|
75 |
|
76 |
|
77 def dozip(self, filename, files): |
|
78 zipFileName = self.currentDestRoot + "/" + filename |
|
79 if os.path.exists(zipFileName): |
|
80 os.remove(zipFileName) |
|
81 #print zipFileName |
|
82 zipF = zipfile.ZipFile(zipFileName, "w", zipfile.ZIP_DEFLATED) |
|
83 for file in files: |
|
84 srcFile = file[0] |
|
85 dstFile = os.path.basename(srcFile) |
|
86 if len(file) > 1: |
|
87 dstFile = file[1] + '/' + dstFile |
|
88 srcFile = self.currentSrcRoot + srcFile |
|
89 if os.path.exists(srcFile): |
|
90 #print srcFile + "-->" + dstFile |
|
91 zipF.write(srcFile, dstFile) |
|
92 self.wastebasket.add(srcFile) |
|
93 else: |
|
94 print "ERROR: Missing file " + srcFile |
|
95 raise Exception('Copy failed because file was missing') |
|
96 zipF.close() |
|
97 |
|
98 def doDelete(self, files): |
|
99 for file in files: |
|
100 src = file[0] |
|
101 src = self.currentSrcRoot + src |
|
102 if os.path.exists(src): |
|
103 self.wastebasket.add(src) |
|
104 else: |
|
105 print "INFO: File marked to be ignored was missing " + src |
|
106 |
|
107 |
|
108 def doCopy(self, files): |
|
109 for file in files: |
|
110 src, dst = file |
|
111 src = self.currentSrcRoot + src |
|
112 if os.path.exists(src): |
|
113 if dst == None: |
|
114 dst = os.path.basename(src) |
|
115 dst = self.currentDestRoot + "/" + dst |
|
116 directory = os.path.dirname(dst) |
|
117 if not os.path.exists(directory): |
|
118 os.makedirs(directory) |
|
119 shutil.copy(src, dst) |
|
120 self.wastebasket.add(src) |
|
121 else: |
|
122 print "ERROR: Missing file " + src |
|
123 raise Exception('Copy failed because file was missing') |
|
124 |
|
125 |
|
126 def main(): |
|
127 parser = OptionParser( |
|
128 usage = "python -u %prog [options] <src root> <dst root>", |
|
129 description = "Converts the J9 delivery to S60 format. " + \ |
|
130 "The <src root> must point to dircetory containing the unzipped " + \ |
|
131 "j9_s60_xxxxxx.zip file received as apart of IBM delivery " + \ |
|
132 "i.e. the <src root> must contain directory j9_s60. " + \ |
|
133 "By default the tool converts weme binaries and deletes the " + \ |
|
134 "original files. If <src root> is omitted then the src root " + \ |
|
135 "is the current directory. If <dst root> is omitted then " + \ |
|
136 "it will be <src root>") |
|
137 |
|
138 parser.add_option("--no-delete", dest="noDel", |
|
139 action="store_true", default=False, |
|
140 help="Do not delete the original files") |
|
141 |
|
142 |
|
143 (opts, args) = parser.parse_args() |
|
144 |
|
145 if len(args) > 0: |
|
146 srcRoot = args[0] |
|
147 else: |
|
148 srcRoot = "." |
|
149 |
|
150 if len(args) > 1: |
|
151 destRoot = args[1] |
|
152 else: |
|
153 destRoot = root |
|
154 try: |
|
155 j9PackageConverter = J9PackageConverter(srcRoot, destRoot) |
|
156 j9PackageConverter.convert() |
|
157 except: |
|
158 print "Error during conversion!" |
|
159 traceback.print_exc() |
|
160 sys.exit(-1) |
|
161 |
|
162 if not opts.noDel: |
|
163 j9PackageConverter.clean() |
|
164 |
|
165 |
|
166 j9ArmFiles = [ |
|
167 ('armv5/urel/j9.dll',), |
|
168 ('armv5/urel/j9dbg23.dll',), |
|
169 ('armv5/urel/j9dmp23.dll',), |
|
170 ('armv5/urel/j9fdm23.dll',), |
|
171 ('armv5/urel/j9gcchk23.dll',), |
|
172 ('armv5/urel/j9jpi23.dll',), |
|
173 ('armv5/urel/j9jvmti23.dll',), |
|
174 ('armv5/urel/j9mjit23.dll',), |
|
175 ('armv5/urel/j9mjitd23.dll',), |
|
176 ('armv5/urel/j9prf23.dll',), |
|
177 ('armv5/urel/j9vmall23.dll',), |
|
178 ('armv5/urel/j9vrb23.dll',), |
|
179 ('armv5/urel/jclcdc11_23.dll',), |
|
180 ('armv5/urel/jclcldc11_23.dll',), |
|
181 ('armv5/urel/jclfoun11_23.dll',), |
|
182 ('armv5/urel/jnichk.dll',), |
|
183 ('armv5/urel/j9.dll.map',), |
|
184 ('armv5/urel/j9dbg23.dll.map',), |
|
185 ('armv5/urel/j9dmp23.dll.map',), |
|
186 ('armv5/urel/j9fdm23.dll.map',), |
|
187 ('armv5/urel/j9gcchk23.dll.map',), |
|
188 ('armv5/urel/j9jpi23.dll.map',), |
|
189 ('armv5/urel/j9jvmti23.dll.map',), |
|
190 ('armv5/urel/j9mjit23.dll.map',), |
|
191 ('armv5/urel/j9mjitd23.dll.map',), |
|
192 ('armv5/urel/j9prf23.dll.map',), |
|
193 ('armv5/urel/j9vmall23.dll.map',), |
|
194 ('armv5/urel/j9vrb23.dll.map',), |
|
195 ('armv5/urel/jclcdc11_23.dll.map',), |
|
196 ('armv5/urel/jclcldc11_23.dll.map',), |
|
197 ('armv5/urel/jclfoun11_23.dll.map',), |
|
198 ('armv5/urel/jnichk.dll.map',) |
|
199 ] |
|
200 |
|
201 j9WinsFiles = [ |
|
202 ('winscw/udeb/j9.dll',), |
|
203 ('winscw/udeb/j9dbg23.dll',), |
|
204 ('winscw/udeb/j9dmp23.dll',), |
|
205 ('winscw/udeb/j9fdm23.dll',), |
|
206 ('winscw/udeb/j9gcchk23.dll',), |
|
207 ('winscw/udeb/j9jpi23.dll',), |
|
208 ('winscw/udeb/j9jvmti23.dll',), |
|
209 ('winscw/udeb/j9mjit23.dll',), |
|
210 ('winscw/udeb/j9mjitd23.dll',), |
|
211 ('winscw/udeb/j9prf23.dll',), |
|
212 ('winscw/udeb/j9vmall23.dll',), |
|
213 ('winscw/udeb/j9vrb23.dll',), |
|
214 ('winscw/udeb/jclcdc11_23.dll',), |
|
215 ('winscw/udeb/jclcldc11_23.dll',), |
|
216 ('winscw/udeb/jclfoun11_23.dll',), |
|
217 ('winscw/udeb/jnichk.dll',) |
|
218 ] |
|
219 |
|
220 j9IncFiles = [ |
|
221 ('inc/j9cfg.h','inc/'), |
|
222 ('inc/j9comp.h','inc/'), |
|
223 ('inc/jni.h','inc/'), |
|
224 ('inc/jniport.h','inc/'), |
|
225 ('inc/jvmpi.h','inc/'), |
|
226 ('inc/jvmri.h','inc/') |
|
227 ] |
|
228 |
|
229 j9LocaleVariantFilesFp = [ |
|
230 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var1.zip',), |
|
231 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var2.zip',), |
|
232 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var3.zip',), |
|
233 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var4.zip',), |
|
234 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var5.zip',), |
|
235 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var6.zip',), |
|
236 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var7.zip',), |
|
237 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var8.zip',), |
|
238 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var9.zip',), |
|
239 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var10.zip',), |
|
240 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var11.zip',), |
|
241 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var12.zip',), |
|
242 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var13.zip',), |
|
243 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var14.zip',), |
|
244 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var15.zip',), |
|
245 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var16.zip',), |
|
246 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var17.zip',), |
|
247 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var18.zip',), |
|
248 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var19.zip',), |
|
249 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale-variants/locale_var20.zip',) |
|
250 ] |
|
251 |
|
252 j9LocaleVariantFilesCdc = [ |
|
253 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var1.zip',), |
|
254 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var2.zip',), |
|
255 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var3.zip',), |
|
256 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var4.zip',), |
|
257 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var5.zip',), |
|
258 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var6.zip',), |
|
259 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var7.zip',), |
|
260 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var8.zip',), |
|
261 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var9.zip',), |
|
262 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var10.zip',), |
|
263 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var11.zip',), |
|
264 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var12.zip',), |
|
265 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var13.zip',), |
|
266 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var14.zip',), |
|
267 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var15.zip',), |
|
268 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var16.zip',), |
|
269 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var17.zip',), |
|
270 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var18.zip',), |
|
271 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var19.zip',), |
|
272 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale-variants/locale_var20.zip',), |
|
273 ] |
|
274 |
|
275 |
|
276 j9PropertyFiles = [ |
|
277 ('winscw/udeb/z/resource/ive/bin/java.properties',), |
|
278 ('winscw/udeb/z/resource/ive/bin/java_ca.properties',), |
|
279 ('winscw/udeb/z/resource/ive/bin/java_cs.properties',), |
|
280 ('winscw/udeb/z/resource/ive/bin/java_de.properties',), |
|
281 ('winscw/udeb/z/resource/ive/bin/java_es.properties',), |
|
282 ('winscw/udeb/z/resource/ive/bin/java_fr.properties',), |
|
283 ('winscw/udeb/z/resource/ive/bin/java_hu.properties',), |
|
284 ('winscw/udeb/z/resource/ive/bin/java_it.properties',), |
|
285 ('winscw/udeb/z/resource/ive/bin/java_ja.properties',), |
|
286 ('winscw/udeb/z/resource/ive/bin/java_ko.properties',), |
|
287 ('winscw/udeb/z/resource/ive/bin/java_pl.properties',), |
|
288 ('winscw/udeb/z/resource/ive/bin/java_pt_BR.properties',), |
|
289 ('winscw/udeb/z/resource/ive/bin/java_ru.properties',), |
|
290 ('winscw/udeb/z/resource/ive/bin/java_sk.properties',), |
|
291 ('winscw/udeb/z/resource/ive/bin/java_sl.properties',), |
|
292 ('winscw/udeb/z/resource/ive/bin/java_tr.properties',), |
|
293 ('winscw/udeb/z/resource/ive/bin/java_zh.properties',), |
|
294 ('winscw/udeb/z/resource/ive/bin/java_zh_TW.properties',) |
|
295 ] |
|
296 |
|
297 j9SecurityFiles = [ |
|
298 ('winscw/udeb/z/resource/ive/lib/security/java.policy',), |
|
299 ('winscw/udeb/z/resource/ive/lib/security/java.security',) |
|
300 ] |
|
301 |
|
302 j9MiscFiles = [ |
|
303 ('winscw/udeb/z/resource/ive/lib/romclass_cln.prf',), |
|
304 ('winscw/udeb/z/resource/ive/lib/romclass_cln.sym',), |
|
305 ('winscw/udeb/z/resource/ive/lib/romclass_fdn11.prf',), |
|
306 ('winscw/udeb/z/resource/ive/lib/romclass_fdn11.sym',), |
|
307 ('winscw/udeb/z/resource/ive/lib/jclCdc11/classes.jxe', 'jclCdc11'), |
|
308 ('winscw/udeb/z/resource/ive/lib/jclCdc11/classes.sym', 'jclCdc11'), |
|
309 ('winscw/udeb/z/resource/ive/lib/jclCldc11/classes.jxe', 'jclCldc11'), |
|
310 ('winscw/udeb/z/resource/ive/lib/jclCldc11/classes.sym', 'jclCldc11'), |
|
311 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/classes.jxe', 'jclFoundation11'), |
|
312 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/classes.sym', 'jclFoundation11'), |
|
313 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/ext/j9jce.jar', 'jclFoundation11/ext'), |
|
314 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/ext/j9jsse.jar', 'jclFoundation11/ext'), |
|
315 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/ext/jdbc.jar', 'jclFoundation11/ext'), |
|
316 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/ext/rmip.jar', 'jclFoundation11/ext'), |
|
317 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/opt-ext/j9jceprov.jar', 'jclFoundation11/opt_ext') |
|
318 ] |
|
319 |
|
320 |
|
321 j9FilesToCopy = [ |
|
322 ('winscw/udeb/z/resource/ive/lib/jclCldc11/classes.zip', 'classes.cldc.zip'), |
|
323 ('winscw/udeb/z/resource/ive/lib/jclCdc11/classes.zip', 'classes.cdc.zip'), |
|
324 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/classes.zip', 'classes.fp.zip'), |
|
325 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/locale.zip', 'locale.fp.zip'), |
|
326 ('winscw/udeb/z/resource/ive/lib/jclCdc11/locale.zip', 'locale.cdc.zip'), |
|
327 ('../../../../../../info.txt', None), |
|
328 ('../../../../copyright.txt', None), |
|
329 ('../../../../../ReleaseNotes-12-10-2009.doc', 'releasenotes/ReleaseNotes.doc') |
|
330 ] |
|
331 |
|
332 j9FilesToIgnore = [ |
|
333 ('../../j9_s60.pkg',) |
|
334 ] |
|
335 |
|
336 j9WemeFilesToIgnore = [ |
|
337 ('winscw/udeb/z/resource/ive/lib/jclCldc11/source/source.zip',), |
|
338 ('winscw/udeb/z/resource/ive/lib/jclCdc11/source/source.zip',), |
|
339 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/source/source.zip',) |
|
340 ] |
|
341 |
|
342 j9JavaSrcFiles = [ |
|
343 ('winscw/udeb/z/resource/ive/lib/jclCldc11/source/source.zip','javasrc/source.cldc11.zip'), |
|
344 ('winscw/udeb/z/resource/ive/lib/jclCdc11/source/source.zip', 'javasrc/source.cdc11.zip'), |
|
345 ('winscw/udeb/z/resource/ive/lib/jclCdc11/source/locale-src.zip', 'javasrc/source.locale.zip'), |
|
346 ('winscw/udeb/z/resource/ive/lib/jclFoundation11/source/source.zip', 'javasrc/source.foundation11.zip') |
|
347 ] |
|
348 |
|
349 if __name__ == "__main__": |
|
350 main() |