| 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 os | 5 import os |
| 6 import sys | 6 import sys |
| 7 import re | 7 import re |
| 8 import subprocess | 8 import subprocess |
| 9 import shutil | 9 import shutil |
| 10 import buildtools | 10 import buildtools |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 'name': command.name, | 171 'name': command.name, |
| 172 'params': command.params, | 172 'params': command.params, |
| 173 'description': description, | 173 'description': description, |
| 174 'options': '\n'.join(options) | 174 'options': '\n'.join(options) |
| 175 } | 175 } |
| 176 | 176 |
| 177 | 177 |
| 178 def runBuild(baseDir, scriptName, opts, args, type): | 178 def runBuild(baseDir, scriptName, opts, args, type): |
| 179 kwargs = {} | 179 kwargs = {} |
| 180 for option, value in opts: | 180 for option, value in opts: |
| 181 if option in ('-l', '--locales') and type == 'gecko': | 181 if option in {'-l', '--locales'} and type == 'gecko': |
| 182 kwargs['locales'] = value.split(',') | 182 kwargs['locales'] = value.split(',') |
| 183 elif option in ('-b', '--build'): | 183 elif option in {'-b', '--build'}: |
| 184 kwargs['buildNum'] = value | 184 kwargs['buildNum'] = value |
| 185 if type != 'gecko' and not kwargs['buildNum'].isdigit(): | 185 if type != 'gecko' and not kwargs['buildNum'].isdigit(): |
| 186 raise TypeError('Build number must be numerical') | 186 raise TypeError('Build number must be numerical') |
| 187 elif option in ('-k', '--key'): | 187 elif option in {'-k', '--key'}: |
| 188 kwargs['keyFile'] = value | 188 kwargs['keyFile'] = value |
| 189 elif option in ('-m', '--multi-compartment') and type == 'gecko': | 189 elif option in {'-m', '--multi-compartment'} and type == 'gecko': |
| 190 kwargs['multicompartment'] = True | 190 kwargs['multicompartment'] = True |
| 191 elif option in ('-r', '--release'): | 191 elif option in {'-r', '--release'}: |
| 192 kwargs['releaseBuild'] = True | 192 kwargs['releaseBuild'] = True |
| 193 if len(args) > 0: | 193 if len(args) > 0: |
| 194 kwargs['outFile'] = args[0] | 194 kwargs['outFile'] = args[0] |
| 195 | 195 |
| 196 if type == 'gecko': | 196 if type == 'gecko': |
| 197 import buildtools.packagerGecko as packager | 197 import buildtools.packagerGecko as packager |
| 198 elif type == 'chrome': | 198 elif type == 'chrome': |
| 199 import buildtools.packagerChrome as packager | 199 import buildtools.packagerChrome as packager |
| 200 elif type == 'safari': | 200 elif type == 'safari': |
| 201 import buildtools.packagerSafari as packager | 201 import buildtools.packagerSafari as packager |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 if len(args) == 0: | 435 if len(args) == 0: |
| 436 print 'No version number specified for the release' | 436 print 'No version number specified for the release' |
| 437 usage(scriptName, type, 'release') | 437 usage(scriptName, type, 'release') |
| 438 return | 438 return |
| 439 version = args[0] | 439 version = args[0] |
| 440 if re.search(r'[^\d\.]', version): | 440 if re.search(r'[^\d\.]', version): |
| 441 print 'Wrong version number format' | 441 print 'Wrong version number format' |
| 442 usage(scriptName, type, 'release') | 442 usage(scriptName, type, 'release') |
| 443 return | 443 return |
| 444 | 444 |
| 445 if type == 'gecko' and len(keyFiles) == 0: | 445 if type == 'chrome' and len(keyFiles) != 2: |
| 446 print >>sys.stderr, 'Warning: no key file specified, creating an unsigne
d release build\n' | |
| 447 elif type == 'gecko' and len(keyFiles) > 1: | |
| 448 print >>sys.stderr, 'Error: too many key files, only one required' | |
| 449 usage(scriptName, type, 'release') | |
| 450 return | |
| 451 elif type == 'chrome' and len(keyFiles) != 2: | |
| 452 print >>sys.stderr, 'Error: wrong number of key files specified, two key
s (Chrome and Safari) required for the release' | 446 print >>sys.stderr, 'Error: wrong number of key files specified, two key
s (Chrome and Safari) required for the release' |
| 453 usage(scriptName, type, 'release') | 447 usage(scriptName, type, 'release') |
| 454 return | 448 return |
| 455 | 449 |
| 456 import buildtools.releaseAutomation as releaseAutomation | 450 import buildtools.releaseAutomation as releaseAutomation |
| 457 releaseAutomation.run(baseDir, type, version, keyFiles, downloadsRepo) | 451 releaseAutomation.run(baseDir, type, version, keyFiles, downloadsRepo) |
| 458 | 452 |
| 459 | 453 |
| 460 def updatePSL(baseDir, scriptName, opts, args, type): | 454 def updatePSL(baseDir, scriptName, opts, args, type): |
| 461 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater | 455 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater |
| 462 publicSuffixListUpdater.updatePSL(baseDir) | 456 publicSuffixListUpdater.updatePSL(baseDir) |
| 463 | 457 |
| 464 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName,
type), ('help', '-h', '--help')) as command: | 458 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName,
type), ('help', '-h', '--help')) as command: |
| 465 command.shortDescription = 'Show this message' | 459 command.shortDescription = 'Show this message' |
| 466 | 460 |
| 467 with addCommand(runBuild, 'build') as command: | 461 with addCommand(runBuild, 'build') as command: |
| 468 command.shortDescription = 'Create a build' | 462 command.shortDescription = 'Create a build' |
| 469 command.description = 'Creates an extension build with given file name. If o
utput_file is missing a default name will be chosen.' | 463 command.description = 'Creates an extension build with given file name. If o
utput_file is missing a default name will be chosen.' |
| 470 command.params = '[options] [output_file]' | 464 command.params = '[options] [output_file]' |
| 471 command.addOption('Only include the given locales (if omitted: all locales n
ot marked as incomplete)', short='l', long='locales', value='l1,l2,l3', types=('
gecko')) | 465 command.addOption('Only include the given locales (if omitted: all locales n
ot marked as incomplete)', short='l', long='locales', value='l1,l2,l3', types=('
gecko')) |
| 472 command.addOption('Use given build number (if omitted the build number will
be retrieved from Mercurial)', short='b', long='build', value='num') | 466 command.addOption('Use given build number (if omitted the build number will
be retrieved from Mercurial)', short='b', long='build', value='num') |
| 473 command.addOption('File containing private key and certificates required to
sign the package', short='k', long='key', value='file', types=('gecko', 'chrome'
, 'safari')) | 467 command.addOption('File containing private key and certificates required to
sign the package', short='k', long='key', value='file', types=('chrome', 'safari
')) |
| 474 command.addOption('Create a build for leak testing', short='m', long='multi-
compartment', types=('gecko')) | 468 command.addOption('Create a build for leak testing', short='m', long='multi-
compartment', types=('gecko')) |
| 475 command.addOption('Create a release build', short='r', long='release') | 469 command.addOption('Create a release build', short='r', long='release') |
| 476 command.supportedTypes = ('gecko', 'chrome', 'safari', 'edge') | 470 command.supportedTypes = ('gecko', 'chrome', 'safari', 'edge') |
| 477 | 471 |
| 478 with addCommand(runAutoInstall, 'autoinstall') as command: | 472 with addCommand(runAutoInstall, 'autoinstall') as command: |
| 479 command.shortDescription = 'Install extension automatically' | 473 command.shortDescription = 'Install extension automatically' |
| 480 command.description = 'Will automatically install the extension in a browser
running Extension Auto-Installer. If host parameter is omitted assumes that the
browser runs on localhost.' | 474 command.description = 'Will automatically install the extension in a browser
running Extension Auto-Installer. If host parameter is omitted assumes that the
browser runs on localhost.' |
| 481 command.params = '[<host>:]<port>' | 475 command.params = '[<host>:]<port>' |
| 482 command.addOption('Create a build for leak testing', short='m', long='multi-
compartment') | 476 command.addOption('Create a build for leak testing', short='m', long='multi-
compartment') |
| 483 command.supportedTypes = ('gecko') | 477 command.supportedTypes = ('gecko') |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 with addCommand(generateDocs, 'docs') as command: | 515 with addCommand(generateDocs, 'docs') as command: |
| 522 command.shortDescription = 'Generate documentation (requires node.js)' | 516 command.shortDescription = 'Generate documentation (requires node.js)' |
| 523 command.description = 'Generate documentation files and write them into the
specified directory. This operation requires JsDoc 3 to be installed.' | 517 command.description = 'Generate documentation files and write them into the
specified directory. This operation requires JsDoc 3 to be installed.' |
| 524 command.addOption('Suppress JsDoc output', short='q', long='quiet') | 518 command.addOption('Suppress JsDoc output', short='q', long='quiet') |
| 525 command.params = '[options] <directory>' | 519 command.params = '[options] <directory>' |
| 526 command.supportedTypes = ('gecko', 'chrome') | 520 command.supportedTypes = ('gecko', 'chrome') |
| 527 | 521 |
| 528 with addCommand(runReleaseAutomation, 'release') as command: | 522 with addCommand(runReleaseAutomation, 'release') as command: |
| 529 command.shortDescription = 'Run release automation' | 523 command.shortDescription = 'Run release automation' |
| 530 command.description = 'Note: If you are not the project owner then you '
"probably don't want to run this!\n\n" 'Runs release automation: crea
tes downloads for the new version, tags ' 'source code repository as well
as downloads and buildtools repository.' | 524 command.description = 'Note: If you are not the project owner then you '
"probably don't want to run this!\n\n" 'Runs release automation: crea
tes downloads for the new version, tags ' 'source code repository as well
as downloads and buildtools repository.' |
| 531 command.addOption('File containing private key and certificates required to
sign the release. Note that for Chrome releases this option needs to be specifie
d twice: first a key to sign Chrome builds, then another to sign the Safari buil
d.', short='k', long='key', value='file', types=('gecko', 'chrome')) | 525 command.addOption('File containing private key and certificates required to
sign the release. Note that for Chrome releases this option needs to be specifie
d twice: first a key to sign Chrome builds, then another to sign the Safari buil
d.', short='k', long='key', value='file', types=('chrome',)) |
| 532 command.addOption('Directory containing downloads repository (if omitted ../
downloads is assumed)', short='d', long='downloads', value='dir') | 526 command.addOption('Directory containing downloads repository (if omitted ../
downloads is assumed)', short='d', long='downloads', value='dir') |
| 533 command.params = '[options] <version>' | 527 command.params = '[options] <version>' |
| 534 command.supportedTypes = ('gecko', 'chrome') | 528 command.supportedTypes = ('gecko', 'chrome') |
| 535 | 529 |
| 536 with addCommand(updatePSL, 'updatepsl') as command: | 530 with addCommand(updatePSL, 'updatepsl') as command: |
| 537 command.shortDescription = 'Updates Public Suffix List' | 531 command.shortDescription = 'Updates Public Suffix List' |
| 538 command.description = 'Downloads Public Suffix List (see http://publicsuffix
.org/) and generates lib/publicSuffixList.js from it.' | 532 command.description = 'Downloads Public Suffix List (see http://publicsuffix
.org/) and generates lib/publicSuffixList.js from it.' |
| 539 command.supportedTypes = ('chrome',) | 533 command.supportedTypes = ('chrome',) |
| 540 | 534 |
| 541 | 535 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 No command given, assuming "build". For a list of commands run: | 583 No command given, assuming "build". For a list of commands run: |
| 590 | 584 |
| 591 %s help | 585 %s help |
| 592 ''' % scriptName | 586 ''' % scriptName |
| 593 | 587 |
| 594 command = args[0] | 588 command = args[0] |
| 595 if command in commands: | 589 if command in commands: |
| 596 if commands[command].isSupported(type): | 590 if commands[command].isSupported(type): |
| 597 try: | 591 try: |
| 598 opts, args = commands[command].parseArgs(type, args[1:]) | 592 opts, args = commands[command].parseArgs(type, args[1:]) |
| 599 except GetoptError, e: | 593 except GetoptError as e: |
| 600 print str(e) | 594 print str(e) |
| 601 usage(scriptName, type, command) | 595 usage(scriptName, type, command) |
| 602 sys.exit(2) | 596 sys.exit(2) |
| 603 for option, value in opts: | 597 for option, value in opts: |
| 604 if option in ('-h', '--help'): | 598 if option in ('-h', '--help'): |
| 605 usage(scriptName, type, command) | 599 usage(scriptName, type, command) |
| 606 sys.exit() | 600 sys.exit() |
| 607 commands[command](baseDir, scriptName, opts, args, type) | 601 commands[command](baseDir, scriptName, opts, args, type) |
| 608 else: | 602 else: |
| 609 print 'Command %s is not supported for this application type' % comm
and | 603 print 'Command %s is not supported for this application type' % comm
and |
| 610 usage(scriptName, type) | 604 usage(scriptName, type) |
| 611 else: | 605 else: |
| 612 print 'Command %s is unrecognized' % command | 606 print 'Command %s is unrecognized' % command |
| 613 usage(scriptName, type) | 607 usage(scriptName, type) |
| LEFT | RIGHT |