OLD | NEW |
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 16 matching lines...) Expand all Loading... |
27 result = set(('store.description',)) | 27 result = set(('store.description',)) |
28 | 28 |
29 # Hack: ignore all lib subdirectories | 29 # Hack: ignore all lib subdirectories |
30 libDir = os.path.join(params['baseDir'], 'lib') | 30 libDir = os.path.join(params['baseDir'], 'lib') |
31 for file in os.listdir(libDir): | 31 for file in os.listdir(libDir): |
32 if os.path.isdir(os.path.join(libDir, file)): | 32 if os.path.isdir(os.path.join(libDir, file)): |
33 result.add(file) | 33 result.add(file) |
34 return result | 34 return result |
35 | 35 |
36 def getPackageFiles(params): | 36 def getPackageFiles(params): |
37 result = set(('_locales', 'icons', 'jquery-ui', 'lib', 'skin', 'ui',)) | 37 result = set(('_locales', 'icons', 'jquery-ui', 'lib', 'skin', 'ui', 'ext')) |
38 | 38 |
39 if params['devenv']: | 39 if params['devenv']: |
40 result.add('qunit') | 40 result.add('qunit') |
41 | 41 |
42 baseDir = params['baseDir'] | 42 baseDir = params['baseDir'] |
43 for file in os.listdir(baseDir): | 43 for file in os.listdir(baseDir): |
44 if file.endswith('.js') or file.endswith('.html') or file.endswith('.xml'): | 44 if file.endswith('.js') or file.endswith('.html') or file.endswith('.xml'): |
45 result.add(file) | 45 result.add(file) |
46 return result | 46 return result |
47 | 47 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 'pt': 'pt_PT', | 272 'pt': 'pt_PT', |
273 } | 273 } |
274 for chromeLocale, operaLocale in operaMapping.iteritems(): | 274 for chromeLocale, operaLocale in operaMapping.iteritems(): |
275 chromeFile = '_locales/%s/messages.json' % chromeLocale | 275 chromeFile = '_locales/%s/messages.json' % chromeLocale |
276 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 |
277 if chromeFile in files: | 277 if chromeFile in files: |
278 if operaFile != None: | 278 if operaFile != None: |
279 files[operaFile] = files[chromeFile] | 279 files[operaFile] = files[chromeFile] |
280 del files[chromeFile] | 280 del files[chromeFile] |
281 | 281 |
282 # Hack: Replace "Chrome" by "Opera" in the locales | 282 if params['type'] in ('opera', 'safari'): |
| 283 # Hack: Replace "Chrome" by "Opera" or "Safari" in the locales |
283 for path, data in files.iteritems(): | 284 for path, data in files.iteritems(): |
284 if path.startswith("_locales/") and path.endswith("/messages.json"): | 285 if path.startswith("_locales/") and path.endswith("/messages.json"): |
285 files[path] = re.sub(r"\bChrome\b", "Opera", data) | 286 # Hack: There is exactly one text (in the first run page) that contains |
| 287 # "Google Chrome" and means Google Chrome, even though it is only shown |
| 288 # on Safari. |
| 289 files[path] = re.sub(r"\b(?<!Google )Chrome\b", params['type'].capitaliz
e(), data) |
286 | 290 |
287 def signBinary(zipdata, keyFile): | 291 def signBinary(zipdata, keyFile): |
288 import M2Crypto | 292 import M2Crypto |
289 if not os.path.exists(keyFile): | 293 if not os.path.exists(keyFile): |
290 M2Crypto.RSA.gen_key(1024, 65537, callback=lambda x: None).save_key(keyFile,
cipher=None) | 294 M2Crypto.RSA.gen_key(1024, 65537, callback=lambda x: None).save_key(keyFile,
cipher=None) |
291 key = M2Crypto.EVP.load_key(keyFile) | 295 key = M2Crypto.EVP.load_key(keyFile) |
292 key.sign_init() | 296 key.sign_init() |
293 key.sign_update(zipdata) | 297 key.sign_update(zipdata) |
294 return key.final() | 298 return key.final() |
295 | 299 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 files = Files(getPackageFiles(params), getIgnoredFiles(params), | 332 files = Files(getPackageFiles(params), getIgnoredFiles(params), |
329 process=lambda path, data: processFile(path, data, params)) | 333 process=lambda path, data: processFile(path, data, params)) |
330 files['manifest.json'] = createManifest(params) | 334 files['manifest.json'] = createManifest(params) |
331 if metadata.has_section('mapping'): | 335 if metadata.has_section('mapping'): |
332 files.readMappedFiles(metadata.items('mapping')) | 336 files.readMappedFiles(metadata.items('mapping')) |
333 files.read(baseDir) | 337 files.read(baseDir) |
334 | 338 |
335 if metadata.has_section('convert_js'): | 339 if metadata.has_section('convert_js'): |
336 convertJS(params, files) | 340 convertJS(params, files) |
337 | 341 |
| 342 if metadata.has_section('convert_img'): |
| 343 from imageConversion import convertImages |
| 344 convertImages(params, files) |
| 345 |
| 346 if metadata.has_section('preprocess'): |
| 347 files.preprocess( |
| 348 [f for f, _ in metadata.items('preprocess')], |
| 349 {'needsExt': True} |
| 350 ) |
| 351 |
338 if metadata.has_section('import_locales'): | 352 if metadata.has_section('import_locales'): |
339 importGeckoLocales(params, files) | 353 importGeckoLocales(params, files) |
340 | 354 |
341 if devenv: | 355 if devenv: |
342 files['devenvPoller__.js'] = createPoller(params) | 356 files['devenvPoller__.js'] = createPoller(params) |
343 | 357 |
344 if (metadata.has_option('general', 'backgroundScripts') and | 358 if (metadata.has_option('general', 'backgroundScripts') and |
345 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip
ts')) and | 359 'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScrip
ts')) and |
346 'lib/info.js' not in files): | 360 'lib/info.js' not in files): |
347 files['lib/info.js'] = createInfoModule(params) | 361 files['lib/info.js'] = createInfoModule(params) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 def shutdown_server(server): | 393 def shutdown_server(server): |
380 time.sleep(10) | 394 time.sleep(10) |
381 server.shutdown() | 395 server.shutdown() |
382 thread.start_new_thread(shutdown_server, (server,)) | 396 thread.start_new_thread(shutdown_server, (server,)) |
383 server.serve_forever() | 397 server.serve_forever() |
384 | 398 |
385 if connections[0] == 0: | 399 if connections[0] == 0: |
386 print 'Warning: No incoming connections, extension probably not active in th
e browser yet' | 400 print 'Warning: No incoming connections, extension probably not active in th
e browser yet' |
387 else: | 401 else: |
388 print 'Handled %i connection(s)' % connections[0] | 402 print 'Handled %i connection(s)' % connections[0] |
OLD | NEW |