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

Side by Side Diff: packagerChrome.py

Issue 11544056: Prepared buildtools for Safari (Closed)
Patch Set: Created Sept. 20, 2013, 4:05 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 162
163 def convertFirstRunPage(params, files):
Felix Dahlke 2013/10/15 16:24:38 As I said in the other review, I think it'd be fin
Sebastian Noack 2013/10/15 17:06:56 My intention was to don't make the change on the f
Felix Dahlke 2013/10/15 22:46:11 Fair enough, sure.
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,
Felix Dahlke 2013/10/15 16:24:38 Seems like the indentation is off here.
Sebastian Noack 2013/10/15 17:06:56 True, I'll fix that.
175 lstrip_blocks=True
176 )
177
178 files['firstRun.html'] = env.from_string(files['firstRun.html']).render(type=p arams['type'])
179
163 def importGeckoLocales(params, files): 180 def importGeckoLocales(params, files):
164 import localeTools 181 import localeTools
165 182
166 localeCodeMapping = { 183 localeCodeMapping = {
167 'ar': 'ar', 184 'ar': 'ar',
168 'bg': 'bg', 185 'bg': 'bg',
169 'ca': 'ca', 186 'ca': 'ca',
170 'cs': 'cs', 187 'cs': 'cs',
171 'da': 'da', 188 'da': 'da',
172 'de': 'de', 189 'de': 'de',
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 'pt': 'pt_PT', 289 'pt': 'pt_PT',
273 } 290 }
274 for chromeLocale, operaLocale in operaMapping.iteritems(): 291 for chromeLocale, operaLocale in operaMapping.iteritems():
275 chromeFile = '_locales/%s/messages.json' % chromeLocale 292 chromeFile = '_locales/%s/messages.json' % chromeLocale
276 operaFile = '_locales/%s/messages.json' % operaLocale if operaLocale != No ne else None 293 operaFile = '_locales/%s/messages.json' % operaLocale if operaLocale != No ne else None
277 if chromeFile in files: 294 if chromeFile in files:
278 if operaFile != None: 295 if operaFile != None:
279 files[operaFile] = files[chromeFile] 296 files[operaFile] = files[chromeFile]
280 del files[chromeFile] 297 del files[chromeFile]
281 298
282 # Hack: Replace "Chrome" by "Opera" in the locales 299 if params['type'] in ('opera', 'safari'):
300 # Hack: Replace "Chrome" by "Opera" or "Safari" in the locales
283 for path, data in files.iteritems(): 301 for path, data in files.iteritems():
284 if path.startswith("_locales/") and path.endswith("/messages.json"): 302 if path.startswith("_locales/") and path.endswith("/messages.json"):
285 files[path] = re.sub(r"\bChrome\b", "Opera", data) 303 files[path] = re.sub(r"\bChrome\b", params['type'].capitalize(), data)
286 304
287 def signBinary(zipdata, keyFile): 305 def signBinary(zipdata, keyFile):
288 import M2Crypto 306 import M2Crypto
289 if not os.path.exists(keyFile): 307 if not os.path.exists(keyFile):
290 M2Crypto.RSA.gen_key(1024, 65537, callback=lambda x: None).save_key(keyFile, cipher=None) 308 M2Crypto.RSA.gen_key(1024, 65537, callback=lambda x: None).save_key(keyFile, cipher=None)
291 key = M2Crypto.EVP.load_key(keyFile) 309 key = M2Crypto.EVP.load_key(keyFile)
292 key.sign_init() 310 key.sign_init()
293 key.sign_update(zipdata) 311 key.sign_update(zipdata)
294 return key.final() 312 return key.final()
295 313
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 files = Files(getPackageFiles(params), getIgnoredFiles(params), 346 files = Files(getPackageFiles(params), getIgnoredFiles(params),
329 process=lambda path, data: processFile(path, data, params)) 347 process=lambda path, data: processFile(path, data, params))
330 files['manifest.json'] = createManifest(params) 348 files['manifest.json'] = createManifest(params)
331 if metadata.has_section('mapping'): 349 if metadata.has_section('mapping'):
332 files.readMappedFiles(metadata.items('mapping')) 350 files.readMappedFiles(metadata.items('mapping'))
333 files.read(baseDir) 351 files.read(baseDir)
334 352
335 if metadata.has_section('convert_js'): 353 if metadata.has_section('convert_js'):
336 convertJS(params, files) 354 convertJS(params, files)
337 355
356 if metadata.has_section('convert_img'):
357 from imageConversion import convertImages
358 convertImages(params, files)
359
360 if 'firstRun.html' in files:
361 convertFirstRunPage(params, files)
362
338 if metadata.has_section('import_locales'): 363 if metadata.has_section('import_locales'):
339 importGeckoLocales(params, files) 364 importGeckoLocales(params, files)
340 365
341 if devenv: 366 if devenv:
342 files['devenvPoller__.js'] = createPoller(params) 367 files['devenvPoller__.js'] = createPoller(params)
343 368
344 if (metadata.has_option('general', 'backgroundScripts') and 369 if (metadata.has_option('general', 'backgroundScripts') and
345 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip ts')) and 370 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip ts')) and
346 'lib/info.js' not in files): 371 'lib/info.js' not in files):
347 files['lib/info.js'] = createInfoModule(params) 372 files['lib/info.js'] = createInfoModule(params)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 def shutdown_server(server): 404 def shutdown_server(server):
380 time.sleep(10) 405 time.sleep(10)
381 server.shutdown() 406 server.shutdown()
382 thread.start_new_thread(shutdown_server, (server,)) 407 thread.start_new_thread(shutdown_server, (server,))
383 server.serve_forever() 408 server.serve_forever()
384 409
385 if connections[0] == 0: 410 if connections[0] == 0:
386 print 'Warning: No incoming connections, extension probably not active in th e browser yet' 411 print 'Warning: No incoming connections, extension probably not active in th e browser yet'
387 else: 412 else:
388 print 'Handled %i connection(s)' % connections[0] 413 print 'Handled %i connection(s)' % connections[0]
OLDNEW

Powered by Google App Engine
This is Rietveld