| OLD | NEW |
| 1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
| 2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
| 3 # | 3 # |
| 4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
| 5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
| 6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
| 7 # | 7 # |
| 8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 config = get_config() | 538 config = get_config() |
| 539 iss = config.get('extensions', 'amo_key') | 539 iss = config.get('extensions', 'amo_key') |
| 540 secret = config.get('extensions', 'amo_secret') | 540 secret = config.get('extensions', 'amo_secret') |
| 541 | 541 |
| 542 url = ('https://addons.mozilla.org/api/v3/addons/{}/' | 542 url = ('https://addons.mozilla.org/api/v3/addons/{}/' |
| 543 'versions/{}/').format(app_id, version) | 543 'versions/{}/').format(app_id, version) |
| 544 | 544 |
| 545 request = self.generate_jwt_request(iss, secret, url, 'GET') | 545 request = self.generate_jwt_request(iss, secret, url, 'GET') |
| 546 response = json.load(urllib2.urlopen(request)) | 546 response = json.load(urllib2.urlopen(request)) |
| 547 | 547 |
| 548 filename = '{}-{}.xpi'.format(self.basename, version) |
| 549 self.path = os.path.join( |
| 550 config.get('extensions', 'nightliesDirectory'), |
| 551 self.basename, |
| 552 filename |
| 553 ) |
| 554 |
| 548 necessary = ['passed_review', 'reviewed', 'processed', 'valid'] | 555 necessary = ['passed_review', 'reviewed', 'processed', 'valid'] |
| 549 if all(response[x] for x in necessary): | 556 if all(response[x] for x in necessary): |
| 550 download_url = response['files'][0]['download_url'] | 557 download_url = response['files'][0]['download_url'] |
| 551 checksum = response['files'][0]['hash'] | 558 checksum = response['files'][0]['hash'] |
| 552 | 559 |
| 553 filename = '{}-{}.xpi'.format(self.basename, version) | |
| 554 file_path = os.path.join( | |
| 555 config.get('extensions', 'nightliesDirectory'), | |
| 556 self.basename, | |
| 557 filename | |
| 558 ) | |
| 559 | |
| 560 request = self.generate_jwt_request(iss, secret, download_url, | 560 request = self.generate_jwt_request(iss, secret, download_url, |
| 561 'GET') | 561 'GET') |
| 562 try: | 562 try: |
| 563 response = urllib2.urlopen(request) | 563 response = urllib2.urlopen(request) |
| 564 except urllib2.HTTPError as e: | 564 except urllib2.HTTPError as e: |
| 565 logging.error(e.read()) | 565 logging.error(e.read()) |
| 566 | 566 |
| 567 # Verify the extension's integrity | 567 # Verify the extension's integrity |
| 568 file_content = response.read() | 568 file_content = response.read() |
| 569 sha256 = hashlib.sha256(file_content) | 569 sha256 = hashlib.sha256(file_content) |
| 570 returned_checksum = '{}:{}'.format(sha256.name, sha256.hexdigest()) | 570 returned_checksum = '{}:{}'.format(sha256.name, sha256.hexdigest()) |
| 571 | 571 |
| 572 if returned_checksum != checksum: | 572 if returned_checksum != checksum: |
| 573 logging.error('Checksum could not be verified: {} vs {}' | 573 logging.error('Checksum could not be verified: {} vs {}' |
| 574 ''.format(checksum, returned_checksum)) | 574 ''.format(checksum, returned_checksum)) |
| 575 | 575 |
| 576 with open(file_path, 'w') as fp: | 576 with open(self.path, 'w') as fp: |
| 577 fp.write(file_content) | 577 fp.write(file_content) |
| 578 | 578 |
| 579 self.update_link = os.path.join( | 579 self.update_link = os.path.join( |
| 580 config.get('extensions', 'nightliesURL'), | 580 config.get('extensions', 'nightliesURL'), |
| 581 self.basename, | 581 self.basename, |
| 582 filename | 582 filename |
| 583 ) | 583 ) |
| 584 | 584 |
| 585 self.remove_from_downloads_lockfile(self.config.type, | 585 self.remove_from_downloads_lockfile(self.config.type, |
| 586 'version', | 586 'version', |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 | 828 |
| 829 if self.config.type in downloads: | 829 if self.config.type in downloads: |
| 830 try: | 830 try: |
| 831 self.copyRepository() | 831 self.copyRepository() |
| 832 self.readGeckoMetadata() | 832 self.readGeckoMetadata() |
| 833 | 833 |
| 834 for data in download_info[self.config.type]: | 834 for data in download_info[self.config.type]: |
| 835 self.version = data['version'] | 835 self.version = data['version'] |
| 836 | 836 |
| 837 self.download_from_mozilla_addons(**data) | 837 self.download_from_mozilla_addons(**data) |
| 838 if os.path.exists(self.path): |
| 839 # write out changelog |
| 840 self.writeChangelog(self.getChanges()) |
| 838 | 841 |
| 839 # write out changelog | 842 # write update manifest |
| 840 self.writeChangelog(self.getChanges()) | 843 self.writeUpdateManifest() |
| 841 | 844 |
| 842 # write update manifest | 845 # retire old builds |
| 843 self.writeUpdateManifest() | 846 versions = self.retireBuilds() |
| 847 # update index page |
| 848 self.updateIndex(versions) |
| 844 | 849 |
| 845 # retire old builds | 850 # Update soft link to latest build |
| 846 versions = self.retireBuilds() | 851 baseDir = os.path.join( |
| 847 # update index page | 852 self.config.nightliesDirectory, self.basename |
| 848 self.updateIndex(versions) | 853 ) |
| 854 linkPath = os.path.join( |
| 855 baseDir, '00latest' + self.config.packageSuffix |
| 856 ) |
| 857 |
| 858 self.symlink_or_copy(self.path, linkPath) |
| 849 finally: | 859 finally: |
| 850 # clean up | 860 # clean up |
| 851 if self.tempdir: | 861 if self.tempdir: |
| 852 shutil.rmtree(self.tempdir, ignore_errors=True) | 862 shutil.rmtree(self.tempdir, ignore_errors=True) |
| 853 | 863 |
| 854 | 864 |
| 855 def main(download=False): | 865 def main(download=False): |
| 856 """ | 866 """ |
| 857 main function for createNightlies.py | 867 main function for createNightlies.py |
| 858 """ | 868 """ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 879 | 889 |
| 880 file = open(nightlyConfigFile, 'wb') | 890 file = open(nightlyConfigFile, 'wb') |
| 881 nightlyConfig.write(file) | 891 nightlyConfig.write(file) |
| 882 | 892 |
| 883 | 893 |
| 884 if __name__ == '__main__': | 894 if __name__ == '__main__': |
| 885 parser = argparse.ArgumentParser() | 895 parser = argparse.ArgumentParser() |
| 886 parser.add_argument('--download', action='store_true', default=False) | 896 parser.add_argument('--download', action='store_true', default=False) |
| 887 args = parser.parse_args() | 897 args = parser.parse_args() |
| 888 main(args.download) | 898 main(args.download) |
| OLD | NEW |