LEFT | RIGHT |
1 # This Source Code Form is subject to the terms of the Mozilla Public | 1 # This Source Code Form is subject to the terms of the Mozilla Public |
2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | 4 |
5 import ConfigParser | 5 import ConfigParser |
6 import errno | 6 import errno |
7 import glob | 7 import glob |
8 import io | 8 import io |
9 import json | 9 import json |
10 import os | 10 import os |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 relpath='devenvPoller__.js', | 347 relpath='devenvPoller__.js', |
348 ) | 348 ) |
349 files['devenvVersion__'] = str(random.random()) | 349 files['devenvVersion__'] = str(random.random()) |
350 | 350 |
351 if metadata.has_option('general', 'testScripts'): | 351 if metadata.has_option('general', 'testScripts'): |
352 files['qunit/index.html'] = createScriptPage( | 352 files['qunit/index.html'] = createScriptPage( |
353 params, 'testIndex.html.tmpl', ('general', 'testScripts'), | 353 params, 'testIndex.html.tmpl', ('general', 'testScripts'), |
354 ) | 354 ) |
355 | 355 |
356 | 356 |
357 def addRevisionFile(files): | |
358 try: | |
359 cmd = ['git', 'rev-parse', 'HEAD'] | |
360 files['.revision'] = subprocess.check_output(cmd).strip() | |
361 except subprocess.CalledProcessError: | |
362 pass | |
363 | |
364 | |
365 def createBuild(baseDir, type='chrome', outFile=None, buildNum=None, releaseBuil
d=False, keyFile=None, devenv=False): | 357 def createBuild(baseDir, type='chrome', outFile=None, buildNum=None, releaseBuil
d=False, keyFile=None, devenv=False): |
366 metadata = readMetadata(baseDir, type) | 358 metadata = readMetadata(baseDir, type) |
367 version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum) | 359 version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum) |
368 | 360 |
369 if outFile == None: | 361 if outFile == None: |
370 file_extension = get_extension(type, keyFile is not None) | 362 file_extension = get_extension(type, keyFile is not None) |
371 outFile = getDefaultFileName(metadata, version, file_extension) | 363 outFile = getDefaultFileName(metadata, version, file_extension) |
372 | 364 |
373 params = { | 365 params = { |
374 'type': type, | 366 'type': type, |
(...skipping 18 matching lines...) Expand all Loading... |
393 if metadata.has_section('preprocess'): | 385 if metadata.has_section('preprocess'): |
394 files.preprocess( | 386 files.preprocess( |
395 [f for f, _ in metadata.items('preprocess')], | 387 [f for f, _ in metadata.items('preprocess')], |
396 {'needsExt': True}, | 388 {'needsExt': True}, |
397 ) | 389 ) |
398 | 390 |
399 if metadata.has_section('import_locales'): | 391 if metadata.has_section('import_locales'): |
400 import_locales(params, files) | 392 import_locales(params, files) |
401 | 393 |
402 files['manifest.json'] = createManifest(params, files) | 394 files['manifest.json'] = createManifest(params, files) |
403 | 395 building_from_git = os.path.exists(os.path.join(baseDir, '.git')) |
404 if not releaseBuild and not devenv: | 396 if not releaseBuild and not devenv and building_from_git: |
405 addRevisionFile(files) | 397 cmd = ['git', 'rev-parse', 'HEAD'] |
| 398 files['.revision'] = subprocess.check_output(cmd, cwd=baseDir) |
406 | 399 |
407 if type == 'chrome': | 400 if type == 'chrome': |
408 fix_translations_for_chrome(files) | 401 fix_translations_for_chrome(files) |
409 | 402 |
410 if devenv: | 403 if devenv: |
411 add_devenv_requirements(files, metadata, params) | 404 add_devenv_requirements(files, metadata, params) |
412 | 405 |
413 zipdata = files.zipToString() | 406 zipdata = files.zipToString() |
414 signature = None | 407 signature = None |
415 pubkey = None | 408 pubkey = None |
416 if keyFile != None: | 409 if keyFile != None: |
417 signature = signBinary(zipdata, keyFile) | 410 signature = signBinary(zipdata, keyFile) |
418 pubkey = getPublicKey(keyFile) | 411 pubkey = getPublicKey(keyFile) |
419 writePackage(outFile, pubkey, signature, zipdata) | 412 writePackage(outFile, pubkey, signature, zipdata) |
LEFT | RIGHT |