LEFT | RIGHT |
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
4 # Copyright (C) 2006-2013 Eyeo GmbH | 4 # Copyright (C) 2006-2013 Eyeo GmbH |
5 # | 5 # |
6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify |
7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as |
8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
9 # | 9 # |
10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, |
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 # GNU General Public License for more details. | 13 # GNU General Public License for more details. |
14 # | 14 # |
15 # You should have received a copy of the GNU General Public License | 15 # You should have received a copy of the GNU General Public License |
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 |
18 """ | 18 """ |
19 | 19 |
20 Nightly builds generation script | 20 Nightly builds generation script |
21 ================================ | 21 ================================ |
22 | 22 |
23 This script generates nightly builds of extensions, together | 23 This script generates nightly builds of extensions, together |
24 with changelogs and documentation. | 24 with changelogs and documentation. |
25 | 25 |
26 """ | 26 """ |
27 | 27 |
28 import sys, os, os.path, codecs, subprocess, ConfigParser, traceback, json, hash
lib | 28 import sys, os, os.path, codecs, subprocess, ConfigParser, traceback, json, hash
lib |
29 import tempfile, re, shutil, urlparse, pipes, time, urllib2 | 29 import tempfile, re, shutil, urlparse, pipes, time, urllib2, struct |
30 from datetime import datetime | 30 from datetime import datetime |
31 from urllib import urlencode | 31 from urllib import urlencode |
32 from xml.dom.minidom import parse as parseXml | 32 from xml.dom.minidom import parse as parseXml |
33 from sitescripts.utils import get_config, setupStderr, get_template | 33 from sitescripts.utils import get_config, setupStderr, get_template |
34 from sitescripts.extensions.utils import compareVersions, Configuration | 34 from sitescripts.extensions.utils import compareVersions, Configuration |
35 | 35 |
36 MAX_BUILDS = 50 | 36 MAX_BUILDS = 50 |
37 | 37 |
38 | 38 |
39 class NightlyBuild(object): | 39 class NightlyBuild(object): |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 410 |
411 # upload a new version with the Chrome Web Store API | 411 # upload a new version with the Chrome Web Store API |
412 # https://developer.chrome.com/webstore/using_webstore_api#uploadexisitng | 412 # https://developer.chrome.com/webstore/using_webstore_api#uploadexisitng |
413 | 413 |
414 request = urllib2.Request('https://www.googleapis.com/upload/chromewebstore/
v1.1/items/' + self.config.galleryID) | 414 request = urllib2.Request('https://www.googleapis.com/upload/chromewebstore/
v1.1/items/' + self.config.galleryID) |
415 request.get_method = lambda: 'PUT' | 415 request.get_method = lambda: 'PUT' |
416 request.add_header('Authorization', '%s %s' % (response['token_type'], respo
nse['access_token'])) | 416 request.add_header('Authorization', '%s %s' % (response['token_type'], respo
nse['access_token'])) |
417 request.add_header('x-goog-api-version', '2') | 417 request.add_header('x-goog-api-version', '2') |
418 | 418 |
419 with open(self.path, 'rb') as file: | 419 with open(self.path, 'rb') as file: |
420 request.add_header('Content-Length', '%d' % os.fstat(file.fileno()).st_siz
e) | 420 if file.read(8) != 'Cr24\x02\x00\x00\x00': |
| 421 raise Exception('not a chrome extension or unknown CRX version') |
| 422 |
| 423 # skip public key and signature |
| 424 file.seek(sum(struct.unpack('<II', file.read(8))), os.SEEK_CUR) |
| 425 |
| 426 request.add_header('Content-Length', os.fstat(file.fileno()).st_size - fil
e.tell()) |
421 request.add_data(file) | 427 request.add_data(file) |
422 | 428 |
423 response = json.load(urllib2.urlopen(request)) | 429 response = json.load(urllib2.urlopen(request)) |
424 | 430 |
425 if response['uploadState'] == 'FAILURE': | 431 if response['uploadState'] == 'FAILURE': |
426 raise Exception(response['itemError']) | 432 raise Exception(response['itemError']) |
427 | 433 |
428 def run(self): | 434 def run(self): |
429 """ | 435 """ |
430 Run the nightly build process for one extension | 436 Run the nightly build process for one extension |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 | 471 |
466 if self.config.type == 'ie': | 472 if self.config.type == 'ie': |
467 self.writeIEUpdateManifest(versions) | 473 self.writeIEUpdateManifest(versions) |
468 | 474 |
469 # update index page | 475 # update index page |
470 self.updateIndex(versions) | 476 self.updateIndex(versions) |
471 | 477 |
472 # update nightlies config | 478 # update nightlies config |
473 self.config.latestRevision = self.revision | 479 self.config.latestRevision = self.revision |
474 | 480 |
475 if self.config.clientID and self.config.clientSecret and self.config.refre
shToken: | 481 if self.type == 'chrome' and self.config.clientID and self.config.clientSe
cret and self.config.refreshToken: |
476 self.uploadToChromeWebStore() | 482 self.uploadToChromeWebStore() |
477 finally: | 483 finally: |
478 # clean up | 484 # clean up |
479 if self.tempdir: | 485 if self.tempdir: |
480 shutil.rmtree(self.tempdir, ignore_errors=True) | 486 shutil.rmtree(self.tempdir, ignore_errors=True) |
481 | 487 |
482 | 488 |
483 def main(): | 489 def main(): |
484 """ | 490 """ |
485 main function for createNightlies.py | 491 main function for createNightlies.py |
(...skipping 17 matching lines...) Expand all Loading... |
503 except Exception, ex: | 509 except Exception, ex: |
504 print >>sys.stderr, "The build for %s failed:" % repo | 510 print >>sys.stderr, "The build for %s failed:" % repo |
505 traceback.print_exc() | 511 traceback.print_exc() |
506 | 512 |
507 file = open(nightlyConfigFile, 'wb') | 513 file = open(nightlyConfigFile, 'wb') |
508 nightlyConfig.write(file) | 514 nightlyConfig.write(file) |
509 | 515 |
510 | 516 |
511 if __name__ == '__main__': | 517 if __name__ == '__main__': |
512 main() | 518 main() |
LEFT | RIGHT |