| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 |
|
tlucas
2017/10/04 12:04:11
Note: All changes are the result of rebasing
| |
| 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 |
| 11 from getopt import getopt, GetoptError | 11 from getopt import getopt, GetoptError |
| 12 from StringIO import StringIO | 12 from StringIO import StringIO |
| 13 from zipfile import ZipFile | 13 from zipfile import ZipFile |
| 14 | 14 |
| 15 knownTypes = ('gecko-webext', 'chrome', 'safari', 'generic', 'edge') | 15 knownTypes = ('gecko-webext', 'chrome', 'generic', 'edge') |
| 16 | 16 |
| 17 | 17 |
| 18 class Command(object): | 18 class Command(object): |
| 19 name = property(lambda self: self._name) | 19 name = property(lambda self: self._name) |
| 20 shortDescription = property( | 20 shortDescription = property( |
| 21 lambda self: self._shortDescription, | 21 lambda self: self._shortDescription, |
| 22 lambda self, value: self.__dict__.update({'_shortDescription': value}) | 22 lambda self, value: self.__dict__.update({'_shortDescription': value}) |
| 23 ) | 23 ) |
| 24 description = property( | 24 description = property( |
| 25 lambda self: self._description, | 25 lambda self: self._description, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 raise TypeError('Build number must be numerical') | 184 raise TypeError('Build number must be numerical') |
| 185 elif option in {'-k', '--key'}: | 185 elif option in {'-k', '--key'}: |
| 186 kwargs['keyFile'] = value | 186 kwargs['keyFile'] = value |
| 187 elif option in {'-r', '--release'}: | 187 elif option in {'-r', '--release'}: |
| 188 kwargs['releaseBuild'] = True | 188 kwargs['releaseBuild'] = True |
| 189 if len(args) > 0: | 189 if len(args) > 0: |
| 190 kwargs['outFile'] = args[0] | 190 kwargs['outFile'] = args[0] |
| 191 | 191 |
| 192 if type in {'chrome', 'gecko-webext'}: | 192 if type in {'chrome', 'gecko-webext'}: |
| 193 import buildtools.packagerChrome as packager | 193 import buildtools.packagerChrome as packager |
| 194 elif type == 'safari': | |
| 195 import buildtools.packagerSafari as packager | |
| 196 elif type == 'edge': | 194 elif type == 'edge': |
| 197 import buildtools.packagerEdge as packager | 195 import buildtools.packagerEdge as packager |
| 198 | 196 |
| 199 packager.createBuild(baseDir, type=type, **kwargs) | 197 packager.createBuild(baseDir, type=type, **kwargs) |
| 200 | 198 |
| 201 | 199 |
| 202 def createDevEnv(baseDir, scriptName, opts, args, type): | 200 def createDevEnv(baseDir, scriptName, opts, args, type): |
| 203 if type == 'safari': | 201 import buildtools.packagerChrome as packager |
| 204 import buildtools.packagerSafari as packager | |
| 205 else: | |
| 206 import buildtools.packagerChrome as packager | |
| 207 | 202 |
| 208 file = StringIO() | 203 file = StringIO() |
| 209 packager.createBuild(baseDir, type=type, outFile=file, devenv=True, releaseB uild=True) | 204 packager.createBuild(baseDir, type=type, outFile=file, devenv=True, releaseB uild=True) |
| 210 | 205 |
| 211 from buildtools.packager import getDevEnvPath | 206 from buildtools.packager import getDevEnvPath |
| 212 devenv_dir = getDevEnvPath(baseDir, type) | 207 devenv_dir = getDevEnvPath(baseDir, type) |
| 213 | 208 |
| 214 shutil.rmtree(devenv_dir, ignore_errors=True) | 209 shutil.rmtree(devenv_dir, ignore_errors=True) |
| 215 | 210 |
| 216 file.seek(0) | 211 file.seek(0) |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 if len(args) == 0: | 359 if len(args) == 0: |
| 365 print 'No version number specified for the release' | 360 print 'No version number specified for the release' |
| 366 usage(scriptName, type, 'release') | 361 usage(scriptName, type, 'release') |
| 367 return | 362 return |
| 368 version = args[0] | 363 version = args[0] |
| 369 if re.search(r'[^\d\.]', version): | 364 if re.search(r'[^\d\.]', version): |
| 370 print 'Wrong version number format' | 365 print 'Wrong version number format' |
| 371 usage(scriptName, type, 'release') | 366 usage(scriptName, type, 'release') |
| 372 return | 367 return |
| 373 | 368 |
| 374 if type in {'chrome', 'safari'} and keyFile is None: | 369 if type == 'chrome' and keyFile is None: |
| 375 print >>sys.stderr, 'Error: you must specify a key file for this release ' | 370 print >>sys.stderr, 'Error: you must specify a key file for this release ' |
| 376 usage(scriptName, type, 'release') | 371 usage(scriptName, type, 'release') |
| 377 return | 372 return |
| 378 | 373 |
| 379 import buildtools.releaseAutomation as releaseAutomation | 374 import buildtools.releaseAutomation as releaseAutomation |
| 380 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo) | 375 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo) |
| 381 | 376 |
| 382 | 377 |
| 383 def updatePSL(baseDir, scriptName, opts, args, type): | 378 def updatePSL(baseDir, scriptName, opts, args, type): |
| 384 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater | 379 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater |
| 385 publicSuffixListUpdater.updatePSL(baseDir) | 380 publicSuffixListUpdater.updatePSL(baseDir) |
| 386 | 381 |
| 387 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command: | 382 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName, type), ('help', '-h', '--help')) as command: |
| 388 command.shortDescription = 'Show this message' | 383 command.shortDescription = 'Show this message' |
| 389 | 384 |
| 390 with addCommand(runBuild, 'build') as command: | 385 with addCommand(runBuild, 'build') as command: |
| 391 command.shortDescription = 'Create a build' | 386 command.shortDescription = 'Create a build' |
| 392 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.' | 387 command.description = 'Creates an extension build with given file name. If o utput_file is missing a default name will be chosen.' |
| 393 command.params = '[options] [output_file]' | 388 command.params = '[options] [output_file]' |
| 394 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') | 389 command.addOption('Use given build number (if omitted the build number will be retrieved from Mercurial)', short='b', long='build', value='num') |
| 395 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('chrome', 'safari ')) | 390 command.addOption('File containing private key and certificates required to sign the package', short='k', long='key', value='file', types=('chrome')) |
|
Vasily Kuznetsov
2017/10/05 20:45:18
Here `types` was a tuple and now became a string.
tlucas
2017/10/06 09:21:54
Done.
| |
| 396 command.addOption('Create a release build', short='r', long='release') | 391 command.addOption('Create a release build', short='r', long='release') |
| 397 command.supportedTypes = ('gecko-webext', 'chrome', 'safari', 'edge') | 392 command.supportedTypes = ('gecko-webext', 'chrome', 'edge') |
| 398 | 393 |
| 399 with addCommand(createDevEnv, 'devenv') as command: | 394 with addCommand(createDevEnv, 'devenv') as command: |
| 400 command.shortDescription = 'Set up a development environment' | 395 command.shortDescription = 'Set up a development environment' |
| 401 command.description = 'Will set up or update the devenv folder as an unpacke d extension folder for development.' | 396 command.description = 'Will set up or update the devenv folder as an unpacke d extension folder for development.' |
| 402 command.supportedTypes = ('gecko-webext', 'chrome', 'safari') | 397 command.supportedTypes = ('gecko-webext', 'chrome') |
| 403 | 398 |
| 404 with addCommand(setupTranslations, 'setuptrans') as command: | 399 with addCommand(setupTranslations, 'setuptrans') as command: |
| 405 command.shortDescription = 'Sets up translation languages' | 400 command.shortDescription = 'Sets up translation languages' |
| 406 command.description = 'Sets up translation languages for the project on crow din.net.' | 401 command.description = 'Sets up translation languages for the project on crow din.net.' |
| 407 command.params = '[options] project-key' | 402 command.params = '[options] project-key' |
| 408 command.supportedTypes = ('chrome', 'generic') | 403 command.supportedTypes = ('chrome', 'generic') |
| 409 | 404 |
| 410 with addCommand(updateTranslationMaster, 'translate') as command: | 405 with addCommand(updateTranslationMaster, 'translate') as command: |
| 411 command.shortDescription = 'Updates translation master files' | 406 command.shortDescription = 'Updates translation master files' |
| 412 command.description = 'Updates the translation master files in the project o n crowdin.net.' | 407 command.description = 'Updates the translation master files in the project o n crowdin.net.' |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 429 command.shortDescription = 'Generate documentation (requires node.js)' | 424 command.shortDescription = 'Generate documentation (requires node.js)' |
| 430 command.description = ('Generate documentation files and write them into ' | 425 command.description = ('Generate documentation files and write them into ' |
| 431 'the specified directory.') | 426 'the specified directory.') |
| 432 command.addOption('Suppress JsDoc output', short='q', long='quiet') | 427 command.addOption('Suppress JsDoc output', short='q', long='quiet') |
| 433 command.params = '[options] <directory>' | 428 command.params = '[options] <directory>' |
| 434 command.supportedTypes = ('chrome') | 429 command.supportedTypes = ('chrome') |
| 435 | 430 |
| 436 with addCommand(runReleaseAutomation, 'release') as command: | 431 with addCommand(runReleaseAutomation, 'release') as command: |
| 437 command.shortDescription = 'Run release automation' | 432 command.shortDescription = 'Run release automation' |
| 438 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.' | 433 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.' |
| 439 command.addOption('File containing private key and certificates required to sign the release.', short='k', long='key', value='file', types=('chrome', 'safar i', 'edge')) | 434 command.addOption('File containing private key and certificates required to sign the release.', short='k', long='key', value='file', types=('chrome', 'edge' )) |
| 440 command.addOption('Directory containing downloads repository (if omitted ../ downloads is assumed)', short='d', long='downloads', value='dir') | 435 command.addOption('Directory containing downloads repository (if omitted ../ downloads is assumed)', short='d', long='downloads', value='dir') |
| 441 command.params = '[options] <version>' | 436 command.params = '[options] <version>' |
| 442 command.supportedTypes = ('chrome', 'safari', 'edge') | 437 command.supportedTypes = ('chrome', 'edge') |
| 443 | 438 |
| 444 with addCommand(updatePSL, 'updatepsl') as command: | 439 with addCommand(updatePSL, 'updatepsl') as command: |
| 445 command.shortDescription = 'Updates Public Suffix List' | 440 command.shortDescription = 'Updates Public Suffix List' |
| 446 command.description = 'Downloads Public Suffix List (see http://publicsuffix .org/) and generates lib/publicSuffixList.js from it.' | 441 command.description = 'Downloads Public Suffix List (see http://publicsuffix .org/) and generates lib/publicSuffixList.js from it.' |
| 447 command.supportedTypes = ('chrome',) | 442 command.supportedTypes = ('chrome',) |
| 448 | 443 |
| 449 | 444 |
| 450 def getType(baseDir, scriptName, args): | 445 def getType(baseDir, scriptName, args): |
| 451 # Look for an explicit type parameter (has to be the first parameter) | 446 # Look for an explicit type parameter (has to be the first parameter) |
| 452 if len(args) >= 2 and args[0] == '-t': | 447 if len(args) >= 2 and args[0] == '-t': |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 if option in ('-h', '--help'): | 507 if option in ('-h', '--help'): |
| 513 usage(scriptName, type, command) | 508 usage(scriptName, type, command) |
| 514 sys.exit() | 509 sys.exit() |
| 515 commands[command](baseDir, scriptName, opts, args, type) | 510 commands[command](baseDir, scriptName, opts, args, type) |
| 516 else: | 511 else: |
| 517 print 'Command %s is not supported for this application type' % comm and | 512 print 'Command %s is not supported for this application type' % comm and |
| 518 usage(scriptName, type) | 513 usage(scriptName, type) |
| 519 else: | 514 else: |
| 520 print 'Command %s is unrecognized' % command | 515 print 'Command %s is unrecognized' % command |
| 521 usage(scriptName, type) | 516 usage(scriptName, type) |
| OLD | NEW |