Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: packagerChrome.py

Issue 11544056: Prepared buildtools for Safari (Closed)
Left Patch Set: Added ext directory to includedFiles for chrome and extensions based on it. Created Oct. 23, 2013, 2:32 p.m.
Right Patch Set: Created Oct. 31, 2013, 3:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « packager.py ('k') | packagerGecko.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus build tools, 3 # This file is part of the Adblock Plus build tools,
4 # Copyright (C) 2006-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 except ValueError: 152 except ValueError:
153 pass 153 pass
154 154
155 # Source files of the conversion shouldn't be part of the build 155 # Source files of the conversion shouldn't be part of the build
156 for sourceFile in sourceFiles: 156 for sourceFile in sourceFiles:
157 if sourceFile in files: 157 if sourceFile in files:
158 del files[sourceFile] 158 del files[sourceFile]
159 159
160 sourceFiles = map(lambda f: os.path.abspath(os.path.join(baseDir, f)), sourc eFiles) 160 sourceFiles = map(lambda f: os.path.abspath(os.path.join(baseDir, f)), sourc eFiles)
161 files[file] = doRewrite(sourceFiles, args) 161 files[file] = doRewrite(sourceFiles, args)
162
163 def convertFirstRunPage(params, files):
164 import jinja2
165
166 env = jinja2.Environment(
167 block_start_string='<!-- {%',
168 block_end_string='%} -->',
169 variable_start_string='<!-- {{',
170 variable_end_string='}} -->',
171 comment_start_string='<-- {#',
172 comment_end_string='#} -->',
173
174 trim_blocks=True,
175 lstrip_blocks=True
176 )
177
178 files['firstRun.html'] = env.from_string(files['firstRun.html']).render(type=p arams['type'])
179 162
180 def importGeckoLocales(params, files): 163 def importGeckoLocales(params, files):
181 import localeTools 164 import localeTools
182 165
183 localeCodeMapping = { 166 localeCodeMapping = {
184 'ar': 'ar', 167 'ar': 'ar',
185 'bg': 'bg', 168 'bg': 'bg',
186 'ca': 'ca', 169 'ca': 'ca',
187 'cs': 'cs', 170 'cs': 'cs',
188 'da': 'da', 171 'da': 'da',
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 'pt': 'pt_PT', 272 'pt': 'pt_PT',
290 } 273 }
291 for chromeLocale, operaLocale in operaMapping.iteritems(): 274 for chromeLocale, operaLocale in operaMapping.iteritems():
292 chromeFile = '_locales/%s/messages.json' % chromeLocale 275 chromeFile = '_locales/%s/messages.json' % chromeLocale
293 operaFile = '_locales/%s/messages.json' % operaLocale if operaLocale != No ne else None 276 operaFile = '_locales/%s/messages.json' % operaLocale if operaLocale != No ne else None
294 if chromeFile in files: 277 if chromeFile in files:
295 if operaFile != None: 278 if operaFile != None:
296 files[operaFile] = files[chromeFile] 279 files[operaFile] = files[chromeFile]
297 del files[chromeFile] 280 del files[chromeFile]
298 281
299 if params['type'] in ('opera', 'safari'):
300 # Hack: Replace "Chrome" by "Opera" or "Safari" in the locales
301 for path, data in files.iteritems():
302 if path.startswith("_locales/") and path.endswith("/messages.json"):
303 files[path] = re.sub(r"\bChrome\b", params['type'].capitalize(), data)
304
305 def signBinary(zipdata, keyFile): 282 def signBinary(zipdata, keyFile):
306 import M2Crypto 283 import M2Crypto
307 if not os.path.exists(keyFile): 284 if not os.path.exists(keyFile):
308 M2Crypto.RSA.gen_key(1024, 65537, callback=lambda x: None).save_key(keyFile, cipher=None) 285 M2Crypto.RSA.gen_key(1024, 65537, callback=lambda x: None).save_key(keyFile, cipher=None)
309 key = M2Crypto.EVP.load_key(keyFile) 286 key = M2Crypto.EVP.load_key(keyFile)
310 key.sign_init() 287 key.sign_init()
311 key.sign_update(zipdata) 288 key.sign_update(zipdata)
312 return key.final() 289 return key.final()
313 290
314 def getPublicKey(keyFile): 291 def getPublicKey(keyFile):
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 files.readMappedFiles(metadata.items('mapping')) 327 files.readMappedFiles(metadata.items('mapping'))
351 files.read(baseDir) 328 files.read(baseDir)
352 329
353 if metadata.has_section('convert_js'): 330 if metadata.has_section('convert_js'):
354 convertJS(params, files) 331 convertJS(params, files)
355 332
356 if metadata.has_section('convert_img'): 333 if metadata.has_section('convert_img'):
357 from imageConversion import convertImages 334 from imageConversion import convertImages
358 convertImages(params, files) 335 convertImages(params, files)
359 336
360 if 'firstRun.html' in files: 337 if metadata.has_section('preprocess'):
361 convertFirstRunPage(params, files) 338 files.preprocess(
339 [f for f, _ in metadata.items('preprocess')],
340 {'needsExt': True}
341 )
362 342
363 if metadata.has_section('import_locales'): 343 if metadata.has_section('import_locales'):
364 importGeckoLocales(params, files) 344 importGeckoLocales(params, files)
365 345
366 if devenv: 346 if devenv:
367 files['devenvPoller__.js'] = createPoller(params) 347 files['devenvPoller__.js'] = createPoller(params)
368 348
369 if (metadata.has_option('general', 'backgroundScripts') and 349 if (metadata.has_option('general', 'backgroundScripts') and
370 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip ts')) and 350 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip ts')) and
371 'lib/info.js' not in files): 351 'lib/info.js' not in files):
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 def shutdown_server(server): 384 def shutdown_server(server):
405 time.sleep(10) 385 time.sleep(10)
406 server.shutdown() 386 server.shutdown()
407 thread.start_new_thread(shutdown_server, (server,)) 387 thread.start_new_thread(shutdown_server, (server,))
408 server.serve_forever() 388 server.serve_forever()
409 389
410 if connections[0] == 0: 390 if connections[0] == 0:
411 print 'Warning: No incoming connections, extension probably not active in th e browser yet' 391 print 'Warning: No incoming connections, extension probably not active in th e browser yet'
412 else: 392 else:
413 print 'Handled %i connection(s)' % connections[0] 393 print 'Handled %i connection(s)' % connections[0]
LEFTRIGHT

Powered by Google App Engine
This is Rietveld