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

Side by Side Diff: sitescripts/extensions/bin/updateUpdateManifests.py

Issue 6291923287408640: Issue 1093 - Separate update manifest generation (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « sitescripts/extensions/bin/updateDownloadLinks.py ('k') | sitescripts/extensions/utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # coding: utf-8
2
3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2014 Eyeo GmbH
5 #
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
8 # published by the Free Software Foundation.
9 #
10 # Adblock Plus is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
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/>.
17
18 """
19 Generate update manifests
20 =========================
21
22 This script generates update manifests for all extensions and apps
23 """
24
25 import re
26 import subprocess
27 from buildtools.packagerGecko import KNOWN_APPS
28 from ConfigParser import SafeConfigParser
29 from sitescripts.utils import get_config, get_template
30 from sitescripts.extensions.utils import (Configuration, getDownloadLinks,
31 getSafariCertificateID)
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)
70
71 def writeUpdateManifest(links):
72 """
73 writes an update manifest for all extensions and Android apps
74 """
75
76 extensions = {'gecko': [], 'android': [], 'safari': []}
77 for repo in Configuration.getRepositoryConfigurations():
78 if repo.type not in extensions or not links.has_section(repo.repositoryName) :
79 continue
80 data = readMetadata(repo, links.get(repo.repositoryName, 'version'))
81 data['updateURL'] = links.get(repo.repositoryName, 'downloadURL')
82 if data['updateURL'].startswith(repo.downloadsURL):
83 data['updateURL'] += "?update"
84 extensions[repo.type].append(data)
85
86 if len(extensions['android']) > 1:
87 print >>sys.stderr, 'Warning: more than one Android app defined, update mani fest only works for one'
88
89 for repoType in extensions.iterkeys():
90 manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoT ype)
91 template = get_template(get_config().get('extensions', '%sUpdateManifest' % repoType))
92 template.stream({'extensions': extensions[repoType]}).dump(manifestPath)
93
94 def updateUpdateManifests():
95 """
96 updates all update manifests with the current versions
97 """
98
99 parser = SafeConfigParser()
100 getDownloadLinks(parser)
101 writeUpdateManifest(parser)
102
103 if __name__ == "__main__":
104 updateUpdateManifests()
OLDNEW
« no previous file with comments | « sitescripts/extensions/bin/updateDownloadLinks.py ('k') | sitescripts/extensions/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld