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

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

Issue 6270530592178176: Issue 1144 - Generate IE update manifests (Closed)
Patch Set: Import writeIEUpdateManifest as doWrite in the function body Created July 30, 2014, 2:22 p.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/createNightlies.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
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 Generate update manifests 19 Generate update manifests
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 os
25 import re 26 import re
26 import subprocess 27 import subprocess
27 from buildtools.packagerGecko import KNOWN_APPS 28 from buildtools.packagerGecko import KNOWN_APPS
28 from ConfigParser import SafeConfigParser 29 from ConfigParser import SafeConfigParser
29 from sitescripts.utils import get_config, get_template 30 from sitescripts.utils import get_config, get_template
30 from sitescripts.extensions.utils import (Configuration, getDownloadLinks, 31 from sitescripts.extensions.utils import (
31 getSafariCertificateID) 32 Configuration, getDownloadLinks, getSafariCertificateID,
33 writeIEUpdateManifest)
32 from sitescripts.extensions.android import get_min_sdk_version 34 from sitescripts.extensions.android import get_min_sdk_version
33 35
34 def readMetadata(repo, version): 36 def readMetadata(repo, version):
35 """ 37 """
36 reads extension ID and compatibility information from metadata file in the 38 reads extension ID and compatibility information from metadata file in the
37 extension's repository 39 extension's repository
38 """ 40 """
39 if repo.type == 'android': 41 if repo.type == 'android':
40 command = ['hg', '-R', repo.repository, 'id', '-r', version, '-n'] 42 command = ['hg', '-R', repo.repository, 'id', '-r', version, '-n']
41 result = subprocess.check_output(command) 43 result = subprocess.check_output(command)
(...skipping 16 matching lines...) Expand all
58 result = { 60 result = {
59 'extensionID': metadata.get('general', 'id'), 61 'extensionID': metadata.get('general', 'id'),
60 'version': version, 62 'version': version,
61 'compat': [] 63 'compat': []
62 } 64 }
63 for key, value in KNOWN_APPS.iteritems(): 65 for key, value in KNOWN_APPS.iteritems():
64 if metadata.has_option('compat', key): 66 if metadata.has_option('compat', key):
65 minVersion, maxVersion = metadata.get('compat', key).split('/') 67 minVersion, maxVersion = metadata.get('compat', key).split('/')
66 result['compat'].append({'id': value, 'minVersion': minVersion, 'maxVers ion': maxVersion}) 68 result['compat'].append({'id': value, 'minVersion': minVersion, 'maxVers ion': maxVersion})
67 return result 69 return result
70 elif repo.type == 'ie':
71 return {
72 'version': version,
73 'basename': os.path.basename(repo.repository)
74 }
68 else: 75 else:
69 raise Exception('unknown repository type %r' % repo.type) 76 raise Exception('unknown repository type %r' % repo.type)
70 77
71 def writeUpdateManifest(links): 78 def writeUpdateManifest(links):
72 """ 79 """
73 writes an update manifest for all extensions and Android apps 80 writes an update manifest for all extensions and Android apps
74 """ 81 """
75 82
76 extensions = {'gecko': [], 'android': [], 'safari': []} 83 extensions = {'gecko': [], 'android': [], 'safari': [], 'ie': []}
77 for repo in Configuration.getRepositoryConfigurations(): 84 for repo in Configuration.getRepositoryConfigurations():
78 if repo.type not in extensions or not links.has_section(repo.repositoryName) : 85 if repo.type not in extensions or not links.has_section(repo.repositoryName) :
79 continue 86 continue
80 data = readMetadata(repo, links.get(repo.repositoryName, 'version')) 87 data = readMetadata(repo, links.get(repo.repositoryName, 'version'))
81 data['updateURL'] = links.get(repo.repositoryName, 'downloadURL') 88 data['updateURL'] = links.get(repo.repositoryName, 'downloadURL')
82 if data['updateURL'].startswith(repo.downloadsURL): 89 if data['updateURL'].startswith(repo.downloadsURL):
83 data['updateURL'] += "?update" 90 data['updateURL'] += "?update"
84 extensions[repo.type].append(data) 91 extensions[repo.type].append(data)
85 92
86 if len(extensions['android']) > 1: 93 if len(extensions['android']) > 1:
87 print >>sys.stderr, 'Warning: more than one Android app defined, update mani fest only works for one' 94 print >>sys.stderr, 'Warning: more than one Android app defined, update mani fest only works for one'
88 95
89 for repoType in extensions.iterkeys(): 96 for repoType in extensions.iterkeys():
90 manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoT ype) 97 manifestPath = get_config().get('extensions', '%sUpdateManifestPath' % repoT ype)
91 template = get_template(get_config().get('extensions', '%sUpdateManifest' % repoType)) 98 if repoType == 'ie':
92 template.stream({'extensions': extensions[repoType]}).dump(manifestPath) 99 writeIEUpdateManifest(manifestPath, extensions[repoType])
100 else:
101 template = get_template(get_config().get('extensions', '%sUpdateManifest' % repoType))
102 template.stream({'extensions': extensions[repoType]}).dump(manifestPath)
93 103
94 def updateUpdateManifests(): 104 def updateUpdateManifests():
95 """ 105 """
96 updates all update manifests with the current versions 106 updates all update manifests with the current versions
97 """ 107 """
98 108
99 parser = SafeConfigParser() 109 parser = SafeConfigParser()
100 getDownloadLinks(parser) 110 getDownloadLinks(parser)
101 writeUpdateManifest(parser) 111 writeUpdateManifest(parser)
102 112
103 if __name__ == "__main__": 113 if __name__ == "__main__":
104 updateUpdateManifests() 114 updateUpdateManifests()
OLDNEW
« no previous file with comments | « sitescripts/extensions/bin/createNightlies.py ('k') | sitescripts/extensions/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld