Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/extensions/bin/updateUpdateManifests.py

Issue 6291923287408640: Issue 1093 - Separate update manifest generation (Closed)
Left Patch Set: Created July 22, 2014, 8:03 a.m.
Right Patch Set: Fix issue Created July 23, 2014, 4:50 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/extensions/bin/updateDownloadLinks.py ('k') | sitescripts/extensions/utils.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2014 Eyeo GmbH 4 # Copyright (C) 2006-2014 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 Update update manifests 19 Generate update manifests
Wladimir Palant 2014/07/22 11:24:26 Generate update manifests?
Felix Dahlke 2014/07/22 12:01:11 Done.
20 ======================= 20 =========================
21 21
22 This script generates update manifests for all extensions and apps 22 This script generates update manifests for all extensions and apps
23 """ 23 """
24 24
25 import re
26 import subprocess
27 from buildtools.packagerGecko import KNOWN_APPS
25 from ConfigParser import SafeConfigParser 28 from ConfigParser import SafeConfigParser
29 from sitescripts.utils import get_config, get_template
26 from sitescripts.extensions.utils import (Configuration, getDownloadLinks, 30 from sitescripts.extensions.utils import (Configuration, getDownloadLinks,
27 readMetadata) 31 getSafariCertificateID)
28 from sitescripts.utils import get_config, get_template 32 from sitescripts.extensions.android import get_min_sdk_version
33
34 def readMetadata(repo, version):
35 """
36 reads extension ID and compatibility information from metadata file in the
37 extension's repository
38 """
39 if repo.type == 'android':
40 command = ['hg', '-R', repo.repository, 'id', '-r', version, '-n']
41 result = subprocess.check_output(command)
42 revision = re.sub(r'\D', '', result)
43
44 return {
45 'revision': revision,
46 'minSdkVersion': get_min_sdk_version(repo, version),
47 }
48 elif repo.type == 'safari':
49 metadata = repo.readMetadata(version)
50 return {
51 'certificateID': getSafariCertificateID(repo.keyFile),
52 'version': version,
53 'shortVersion': version,
54 'basename': metadata.get('general', 'basename'),
55 }
56 elif repo.type == 'gecko':
57 metadata = repo.readMetadata(version)
58 result = {
59 'extensionID': metadata.get('general', 'id'),
60 'version': version,
61 'compat': []
62 }
63 for key, value in KNOWN_APPS.iteritems():
64 if metadata.has_option('compat', key):
65 minVersion, maxVersion = metadata.get('compat', key).split('/')
66 result['compat'].append({'id': value, 'minVersion': minVersion, 'maxVers ion': maxVersion})
67 return result
68 else:
69 raise Exception('unknown repository type %r' % repo.type)
29 70
30 def writeUpdateManifest(links): 71 def writeUpdateManifest(links):
Felix Dahlke 2014/07/22 08:11:11 This hasn't been changed, just moved. Since I kep
Wladimir Palant 2014/07/22 11:24:26 Quite a few more actually: elemhidehelper, abpcust
Felix Dahlke 2014/07/22 12:01:11 It doesn't look to me like we're generating update
Wladimir Palant 2014/07/22 18:41:22 We do, see https://adblockplus.org/update.rdf. Ext
31 """ 72 """
32 writes an update manifest for all extensions and Android apps 73 writes an update manifest for all extensions and Android apps
33 """ 74 """
34 75
35 extensions = {'gecko': [], 'android': [], 'safari': []} 76 extensions = {'gecko': [], 'android': [], 'safari': []}
36 for repo in Configuration.getRepositoryConfigurations(): 77 for repo in Configuration.getRepositoryConfigurations():
37 if repo.type not in extensions or not links.has_section(repo.repositoryName) : 78 if repo.type not in extensions or not links.has_section(repo.repositoryName) :
38 continue 79 continue
39 data = readMetadata(repo, links.get(repo.repositoryName, 'version')) 80 data = readMetadata(repo, links.get(repo.repositoryName, 'version'))
40 data['updateURL'] = links.get(repo.repositoryName, 'downloadURL') 81 data['updateURL'] = links.get(repo.repositoryName, 'downloadURL')
41 if data['updateURL'].startswith(repo.downloadsURL): 82 if data['updateURL'].startswith(repo.downloadsURL):
42 data['updateURL'] += "?update" 83 data['updateURL'] += "?update"
43 extensions[repo.type].append(data) 84 extensions[repo.type].append(data)
44 85
45 if len(extensions['android']) > 1: 86 if len(extensions['android']) > 1:
46 print >>sys.stderr, 'Warning: more than one Android app defined, update mani fest only works for one' 87 print >>sys.stderr, 'Warning: more than one Android app defined, update mani fest only works for one'
47 88
48 for repoType in extensions.iterkeys(): 89 for repoType in extensions.iterkeys():
49 manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoT ype) 90 manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoT ype)
50 template = get_template(get_config().get('extensions', '%sUpdateManifest' % repoType)) 91 template = get_template(get_config().get('extensions', '%sUpdateManifest' % repoType))
51 print extensions[repoType]
Wladimir Palant 2014/07/22 11:24:26 Debug code?
Felix Dahlke 2014/07/22 12:01:11 Ouch, done.
52 template.stream({'extensions': extensions[repoType]}).dump(manifestPath) 92 template.stream({'extensions': extensions[repoType]}).dump(manifestPath)
53 93
54 def updateUpdateManifests(): 94 def updateUpdateManifests():
55 """ 95 """
56 updates all update manifests with the current versions 96 updates all update manifests with the current versions
57 """ 97 """
58 98
59 parser = SafeConfigParser() 99 parser = SafeConfigParser()
60 getDownloadLinks(parser) 100 getDownloadLinks(parser)
61 writeUpdateManifest(parser) 101 writeUpdateManifest(parser)
62 102
63 if __name__ == "__main__": 103 if __name__ == "__main__":
64 updateUpdateManifests() 104 updateUpdateManifests()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld