| 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 |
| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 raise TypeError('Build number must be numerical') | 185 raise TypeError('Build number must be numerical') |
| 186 elif option in {'-k', '--key'}: | 186 elif option in {'-k', '--key'}: |
| 187 kwargs['keyFile'] = value | 187 kwargs['keyFile'] = value |
| 188 elif option in {'-r', '--release'}: | 188 elif option in {'-r', '--release'}: |
| 189 kwargs['releaseBuild'] = True | 189 kwargs['releaseBuild'] = True |
| 190 if len(args) > 0: | 190 if len(args) > 0: |
| 191 kwargs['outFile'] = args[0] | 191 kwargs['outFile'] = args[0] |
| 192 | 192 |
| 193 if type in {'chrome', 'gecko-webext'}: | 193 if type in {'chrome', 'gecko-webext'}: |
| 194 import buildtools.packagerChrome as packager | 194 import buildtools.packagerChrome as packager |
| 195 elif type == 'safari': | |
| 196 import buildtools.packagerSafari as packager | |
| 197 elif type == 'edge': | 195 elif type == 'edge': |
| 198 import buildtools.packagerEdge as packager | 196 import buildtools.packagerEdge as packager |
| 199 | 197 |
| 200 packager.createBuild(baseDir, type=type, **kwargs) | 198 packager.createBuild(baseDir, type=type, **kwargs) |
| 201 | 199 |
| 202 | 200 |
| 203 def createDevEnv(baseDir, scriptName, opts, args, type): | 201 def createDevEnv(baseDir, scriptName, opts, args, type): |
| 204 if type == 'safari': | 202 import buildtools.packagerChrome as packager |
| 205 import buildtools.packagerSafari as packager | |
| 206 else: | |
| 207 import buildtools.packagerChrome as packager | |
| 208 | 203 |
| 209 file = StringIO() | 204 file = StringIO() |
| 210 packager.createBuild(baseDir, type=type, outFile=file, devenv=True, releaseB
uild=True) | 205 packager.createBuild(baseDir, type=type, outFile=file, devenv=True, releaseB
uild=True) |
| 211 | 206 |
| 212 from buildtools.packager import getDevEnvPath | 207 from buildtools.packager import getDevEnvPath |
| 213 devenv_dir = getDevEnvPath(baseDir, type) | 208 devenv_dir = getDevEnvPath(baseDir, type) |
| 214 | 209 |
| 215 shutil.rmtree(devenv_dir, ignore_errors=True) | 210 shutil.rmtree(devenv_dir, ignore_errors=True) |
| 216 | 211 |
| 217 file.seek(0) | 212 file.seek(0) |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 if len(args) == 0: | 370 if len(args) == 0: |
| 376 print 'No version number specified for the release' | 371 print 'No version number specified for the release' |
| 377 usage(scriptName, type, 'release') | 372 usage(scriptName, type, 'release') |
| 378 return | 373 return |
| 379 version = args[0] | 374 version = args[0] |
| 380 if re.search(r'[^\d\.]', version): | 375 if re.search(r'[^\d\.]', version): |
| 381 print 'Wrong version number format' | 376 print 'Wrong version number format' |
| 382 usage(scriptName, type, 'release') | 377 usage(scriptName, type, 'release') |
| 383 return | 378 return |
| 384 | 379 |
| 385 if type in {'chrome', 'safari'} and keyFile is None: | 380 if type == 'chrome' and keyFile is None: |
| 386 print >>sys.stderr, 'Error: you must specify a key file for this release
' | 381 print >>sys.stderr, 'Error: you must specify a key file for this release
' |
| 387 usage(scriptName, type, 'release') | 382 usage(scriptName, type, 'release') |
| 388 return | 383 return |
| 389 | 384 |
| 390 import buildtools.releaseAutomation as releaseAutomation | 385 import buildtools.releaseAutomation as releaseAutomation |
| 391 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo) | 386 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo) |
| 392 | 387 |
| 393 | 388 |
| 394 def updatePSL(baseDir, scriptName, opts, args, type): | 389 def updatePSL(baseDir, scriptName, opts, args, type): |
| 395 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater | 390 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater |
| 396 publicSuffixListUpdater.updatePSL(baseDir) | 391 publicSuffixListUpdater.updatePSL(baseDir) |
| 397 | 392 |
| 398 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName,
type), ('help', '-h', '--help')) as command: | 393 with addCommand(lambda baseDir, scriptName, opts, args, type: usage(scriptName,
type), ('help', '-h', '--help')) as command: |
| 399 command.shortDescription = 'Show this message' | 394 command.shortDescription = 'Show this message' |
| 400 | 395 |
| 401 with addCommand(runBuild, 'build') as command: | 396 with addCommand(runBuild, 'build') as command: |
| 402 command.shortDescription = 'Create a build' | 397 command.shortDescription = 'Create a build' |
| 403 command.description = 'Creates an extension build with given file name. If o
utput_file is missing a default name will be chosen.' | 398 command.description = 'Creates an extension build with given file name. If o
utput_file is missing a default name will be chosen.' |
| 404 command.params = '[options] [output_file]' | 399 command.params = '[options] [output_file]' |
| 405 command.addOption('Use given build number (if omitted the build number will
be retrieved from Mercurial)', short='b', long='build', value='num') | 400 command.addOption('Use given build number (if omitted the build number will
be retrieved from Mercurial)', short='b', long='build', value='num') |
| 406 command.addOption('File containing private key and certificates required to
sign the package', short='k', long='key', value='file', types=('chrome', 'safari
')) | 401 command.addOption('File containing private key and certificates required to
sign the package', short='k', long='key', value='file', types=('chrome')) |
| 407 command.addOption('Create a release build', short='r', long='release') | 402 command.addOption('Create a release build', short='r', long='release') |
| 408 command.supportedTypes = ('gecko-webext', 'chrome', 'safari', 'edge') | 403 command.supportedTypes = ('gecko-webext', 'chrome', 'edge') |
| 409 | 404 |
| 410 with addCommand(createDevEnv, 'devenv') as command: | 405 with addCommand(createDevEnv, 'devenv') as command: |
| 411 command.shortDescription = 'Set up a development environment' | 406 command.shortDescription = 'Set up a development environment' |
| 412 command.description = 'Will set up or update the devenv folder as an unpacke
d extension folder for development.' | 407 command.description = 'Will set up or update the devenv folder as an unpacke
d extension folder for development.' |
| 413 command.supportedTypes = ('gecko-webext', 'chrome', 'safari') | 408 command.supportedTypes = ('gecko-webext', 'chrome') |
| 414 | 409 |
| 415 with addCommand(setupTranslations, 'setuptrans') as command: | 410 with addCommand(setupTranslations, 'setuptrans') as command: |
| 416 command.shortDescription = 'Sets up translation languages' | 411 command.shortDescription = 'Sets up translation languages' |
| 417 command.description = 'Sets up translation languages for the project on crow
din.net.' | 412 command.description = 'Sets up translation languages for the project on crow
din.net.' |
| 418 command.params = '[options] project-key' | 413 command.params = '[options] project-key' |
| 419 command.supportedTypes = ('chrome', 'generic') | 414 command.supportedTypes = ('chrome', 'generic') |
| 420 | 415 |
| 421 with addCommand(updateTranslationMaster, 'translate') as command: | 416 with addCommand(updateTranslationMaster, 'translate') as command: |
| 422 command.shortDescription = 'Updates translation master files' | 417 command.shortDescription = 'Updates translation master files' |
| 423 command.description = 'Updates the translation master files in the project o
n crowdin.net.' | 418 command.description = 'Updates the translation master files in the project o
n crowdin.net.' |
| (...skipping 16 matching lines...) Expand all Loading... |
| 440 command.shortDescription = 'Generate documentation (requires node.js)' | 435 command.shortDescription = 'Generate documentation (requires node.js)' |
| 441 command.description = ('Generate documentation files and write them into ' | 436 command.description = ('Generate documentation files and write them into ' |
| 442 'the specified directory.') | 437 'the specified directory.') |
| 443 command.addOption('Suppress JsDoc output', short='q', long='quiet') | 438 command.addOption('Suppress JsDoc output', short='q', long='quiet') |
| 444 command.params = '[options] <directory>' | 439 command.params = '[options] <directory>' |
| 445 command.supportedTypes = ('chrome') | 440 command.supportedTypes = ('chrome') |
| 446 | 441 |
| 447 with addCommand(runReleaseAutomation, 'release') as command: | 442 with addCommand(runReleaseAutomation, 'release') as command: |
| 448 command.shortDescription = 'Run release automation' | 443 command.shortDescription = 'Run release automation' |
| 449 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.' | 444 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.' |
| 450 command.addOption('File containing private key and certificates required to
sign the release.', short='k', long='key', value='file', types=('chrome', 'safar
i', 'edge')) | 445 command.addOption('File containing private key and certificates required to
sign the release.', short='k', long='key', value='file', types=('chrome', 'edge'
)) |
| 451 command.addOption('Directory containing downloads repository (if omitted ../
downloads is assumed)', short='d', long='downloads', value='dir') | 446 command.addOption('Directory containing downloads repository (if omitted ../
downloads is assumed)', short='d', long='downloads', value='dir') |
| 452 command.params = '[options] <version>' | 447 command.params = '[options] <version>' |
| 453 command.supportedTypes = ('chrome', 'safari', 'edge') | 448 command.supportedTypes = ('chrome', 'edge') |
| 454 | 449 |
| 455 with addCommand(updatePSL, 'updatepsl') as command: | 450 with addCommand(updatePSL, 'updatepsl') as command: |
| 456 command.shortDescription = 'Updates Public Suffix List' | 451 command.shortDescription = 'Updates Public Suffix List' |
| 457 command.description = 'Downloads Public Suffix List (see http://publicsuffix
.org/) and generates lib/publicSuffixList.js from it.' | 452 command.description = 'Downloads Public Suffix List (see http://publicsuffix
.org/) and generates lib/publicSuffixList.js from it.' |
| 458 command.supportedTypes = ('chrome',) | 453 command.supportedTypes = ('chrome',) |
| 459 | 454 |
| 460 | 455 |
| 461 def getType(baseDir, scriptName, args): | 456 def getType(baseDir, scriptName, args): |
| 462 # Look for an explicit type parameter (has to be the first parameter) | 457 # Look for an explicit type parameter (has to be the first parameter) |
| 463 if len(args) >= 2 and args[0] == '-t': | 458 if len(args) >= 2 and args[0] == '-t': |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 if option in ('-h', '--help'): | 518 if option in ('-h', '--help'): |
| 524 usage(scriptName, type, command) | 519 usage(scriptName, type, command) |
| 525 sys.exit() | 520 sys.exit() |
| 526 commands[command](baseDir, scriptName, opts, args, type) | 521 commands[command](baseDir, scriptName, opts, args, type) |
| 527 else: | 522 else: |
| 528 print 'Command %s is not supported for this application type' % comm
and | 523 print 'Command %s is not supported for this application type' % comm
and |
| 529 usage(scriptName, type) | 524 usage(scriptName, type) |
| 530 else: | 525 else: |
| 531 print 'Command %s is unrecognized' % command | 526 print 'Command %s is unrecognized' % command |
| 532 usage(scriptName, type) | 527 usage(scriptName, type) |
| OLD | NEW |