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 from getopt import getopt, GetoptError | 10 from getopt import getopt, GetoptError |
11 from StringIO import StringIO | 11 from StringIO import StringIO |
12 from zipfile import ZipFile | 12 from zipfile import ZipFile |
13 | 13 |
14 knownTypes = ('gecko-webext', 'chrome', 'safari', 'generic', 'edge') | 14 knownTypes = ('gecko-webext', 'chrome', 'generic', 'edge') |
15 | 15 |
16 | 16 |
17 class Command(object): | 17 class Command(object): |
18 name = property(lambda self: self._name) | 18 name = property(lambda self: self._name) |
19 shortDescription = property( | 19 shortDescription = property( |
20 lambda self: self._shortDescription, | 20 lambda self: self._shortDescription, |
21 lambda self, value: self.__dict__.update({'_shortDescription': value}) | 21 lambda self, value: self.__dict__.update({'_shortDescription': value}) |
22 ) | 22 ) |
23 description = property( | 23 description = property( |
24 lambda self: self._description, | 24 lambda self: self._description, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 raise TypeError('Build number must be numerical') | 183 raise TypeError('Build number must be numerical') |
184 elif option in {'-k', '--key'}: | 184 elif option in {'-k', '--key'}: |
185 kwargs['keyFile'] = value | 185 kwargs['keyFile'] = value |
186 elif option in {'-r', '--release'}: | 186 elif option in {'-r', '--release'}: |
187 kwargs['releaseBuild'] = True | 187 kwargs['releaseBuild'] = True |
188 if len(args) > 0: | 188 if len(args) > 0: |
189 kwargs['outFile'] = args[0] | 189 kwargs['outFile'] = args[0] |
190 | 190 |
191 if type in {'chrome', 'gecko-webext'}: | 191 if type in {'chrome', 'gecko-webext'}: |
192 import buildtools.packagerChrome as packager | 192 import buildtools.packagerChrome as packager |
193 elif type == 'safari': | |
194 import buildtools.packagerSafari as packager | |
195 elif type == 'edge': | 193 elif type == 'edge': |
196 import buildtools.packagerEdge as packager | 194 import buildtools.packagerEdge as packager |
197 | 195 |
198 packager.createBuild(baseDir, type=type, **kwargs) | 196 packager.createBuild(baseDir, type=type, **kwargs) |
199 | 197 |
200 | 198 |
201 def createDevEnv(baseDir, scriptName, opts, args, type): | 199 def createDevEnv(baseDir, scriptName, opts, args, type): |
202 if type == 'safari': | 200 import buildtools.packagerChrome as packager |
203 import buildtools.packagerSafari as packager | |
204 else: | |
205 import buildtools.packagerChrome as packager | |
206 | 201 |
207 file = StringIO() | 202 file = StringIO() |
208 packager.createBuild(baseDir, type=type, outFile=file, devenv=True, releaseB
uild=True) | 203 packager.createBuild(baseDir, type=type, outFile=file, devenv=True, releaseB
uild=True) |
209 | 204 |
210 from buildtools.packager import getDevEnvPath | 205 from buildtools.packager import getDevEnvPath |
211 devenv_dir = getDevEnvPath(baseDir, type) | 206 devenv_dir = getDevEnvPath(baseDir, type) |
212 | 207 |
213 shutil.rmtree(devenv_dir, ignore_errors=True) | 208 shutil.rmtree(devenv_dir, ignore_errors=True) |
214 | 209 |
215 file.seek(0) | 210 file.seek(0) |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 if len(args) == 0: | 358 if len(args) == 0: |
364 print 'No version number specified for the release' | 359 print 'No version number specified for the release' |
365 usage(scriptName, type, 'release') | 360 usage(scriptName, type, 'release') |
366 return | 361 return |
367 version = args[0] | 362 version = args[0] |
368 if re.search(r'[^\d\.]', version): | 363 if re.search(r'[^\d\.]', version): |
369 print 'Wrong version number format' | 364 print 'Wrong version number format' |
370 usage(scriptName, type, 'release') | 365 usage(scriptName, type, 'release') |
371 return | 366 return |
372 | 367 |
373 if type in {'chrome', 'safari'} and keyFile is None: | 368 if type == 'chrome' and keyFile is None: |
374 print >>sys.stderr, 'Error: you must specify a key file for this release
' | 369 print >>sys.stderr, 'Error: you must specify a key file for this release
' |
375 usage(scriptName, type, 'release') | 370 usage(scriptName, type, 'release') |
376 return | 371 return |
377 | 372 |
378 import buildtools.releaseAutomation as releaseAutomation | 373 import buildtools.releaseAutomation as releaseAutomation |
379 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo) | 374 releaseAutomation.run(baseDir, type, version, keyFile, downloadsRepo) |
380 | 375 |
381 | 376 |
382 def updatePSL(baseDir, scriptName, opts, args, type): | 377 def updatePSL(baseDir, scriptName, opts, args, type): |
383 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater | 378 import buildtools.publicSuffixListUpdater as publicSuffixListUpdater |
384 publicSuffixListUpdater.updatePSL(baseDir) | 379 publicSuffixListUpdater.updatePSL(baseDir) |
385 | 380 |
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',)) |
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 | 403 |
409 with addCommand(updateTranslationMaster, 'translate') as command: | 404 with addCommand(updateTranslationMaster, 'translate') as command: |
410 command.shortDescription = 'Updates translation master files' | 405 command.shortDescription = 'Updates translation master files' |
411 command.description = 'Updates the translation master files in the project o
n crowdin.net.' | 406 command.description = 'Updates the translation master files in the project o
n crowdin.net.' |
412 command.params = '[options] project-key' | 407 command.params = '[options] project-key' |
(...skipping 12 matching lines...) Expand all Loading... |
425 command.shortDescription = 'Generate documentation (requires node.js)' | 420 command.shortDescription = 'Generate documentation (requires node.js)' |
426 command.description = ('Generate documentation files and write them into ' | 421 command.description = ('Generate documentation files and write them into ' |
427 'the specified directory.') | 422 'the specified directory.') |
428 command.addOption('Suppress JsDoc output', short='q', long='quiet') | 423 command.addOption('Suppress JsDoc output', short='q', long='quiet') |
429 command.params = '[options] <directory>' | 424 command.params = '[options] <directory>' |
430 command.supportedTypes = ('chrome',) | 425 command.supportedTypes = ('chrome',) |
431 | 426 |
432 with addCommand(runReleaseAutomation, 'release') as command: | 427 with addCommand(runReleaseAutomation, 'release') as command: |
433 command.shortDescription = 'Run release automation' | 428 command.shortDescription = 'Run release automation' |
434 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.' | 429 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.' |
435 command.addOption('File containing private key and certificates required to
sign the release.', short='k', long='key', value='file', types=('chrome', 'safar
i', 'edge')) | 430 command.addOption('File containing private key and certificates required to
sign the release.', short='k', long='key', value='file', types=('chrome', 'edge'
)) |
436 command.addOption('Directory containing downloads repository (if omitted ../
downloads is assumed)', short='d', long='downloads', value='dir') | 431 command.addOption('Directory containing downloads repository (if omitted ../
downloads is assumed)', short='d', long='downloads', value='dir') |
437 command.params = '[options] <version>' | 432 command.params = '[options] <version>' |
438 command.supportedTypes = ('chrome', 'safari', 'edge') | 433 command.supportedTypes = ('chrome', 'edge') |
439 | 434 |
440 with addCommand(updatePSL, 'updatepsl') as command: | 435 with addCommand(updatePSL, 'updatepsl') as command: |
441 command.shortDescription = 'Updates Public Suffix List' | 436 command.shortDescription = 'Updates Public Suffix List' |
442 command.description = 'Downloads Public Suffix List (see http://publicsuffix
.org/) and generates lib/publicSuffixList.js from it.' | 437 command.description = 'Downloads Public Suffix List (see http://publicsuffix
.org/) and generates lib/publicSuffixList.js from it.' |
443 command.supportedTypes = ('chrome',) | 438 command.supportedTypes = ('chrome',) |
444 | 439 |
445 | 440 |
446 def getType(baseDir, scriptName, args): | 441 def getType(baseDir, scriptName, args): |
447 # Look for an explicit type parameter (has to be the first parameter) | 442 # Look for an explicit type parameter (has to be the first parameter) |
448 if len(args) >= 2 and args[0] == '-t': | 443 if len(args) >= 2 and args[0] == '-t': |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 if option in ('-h', '--help'): | 503 if option in ('-h', '--help'): |
509 usage(scriptName, type, command) | 504 usage(scriptName, type, command) |
510 sys.exit() | 505 sys.exit() |
511 commands[command](baseDir, scriptName, opts, args, type) | 506 commands[command](baseDir, scriptName, opts, args, type) |
512 else: | 507 else: |
513 print 'Command %s is not supported for this application type' % comm
and | 508 print 'Command %s is not supported for this application type' % comm
and |
514 usage(scriptName, type) | 509 usage(scriptName, type) |
515 else: | 510 else: |
516 print 'Command %s is unrecognized' % command | 511 print 'Command %s is unrecognized' % command |
517 usage(scriptName, type) | 512 usage(scriptName, type) |
OLD | NEW |