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

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

Issue 29366797: Issue 4697 - Add support for WebExtension-based Firefox development builds (Closed) Base URL: https://hg.adblockplus.org/sitescripts
Left Patch Set: Created Dec. 5, 2016, 8:38 a.m.
Right Patch Set: Updated tests and update manifest generation Created Dec. 5, 2016, 11:21 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.example ('k') | sitescripts/extensions/bin/updateUpdateManifests.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 # 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-2016 Eyeo GmbH 2 # Copyright (C) 2006-2016 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 self.version = packager.getBuildVersion(self.tempdir, metadata, False, 164 self.version = packager.getBuildVersion(self.tempdir, metadata, False,
165 self.buildNum) 165 self.buildNum)
166 self.basename = metadata.get('general', 'basename') 166 self.basename = metadata.get('general', 'basename')
167 self.compat = [] 167 self.compat = []
168 for key, value in packager.KNOWN_APPS.iteritems(): 168 for key, value in packager.KNOWN_APPS.iteritems():
169 if metadata.has_option('compat', key): 169 if metadata.has_option('compat', key):
170 minVersion, maxVersion = metadata.get('compat', key).split('/') 170 minVersion, maxVersion = metadata.get('compat', key).split('/')
171 self.compat.append({'id': value, 'minVersion': minVersion, 'maxV ersion': maxVersion}) 171 self.compat.append({'id': value, 'minVersion': minVersion, 'maxV ersion': maxVersion})
172 172
173 if metadata.has_option('compat', 'gecko'): 173 if metadata.has_option('compat', 'gecko'):
174 # As far as WebExtensions are concerned, Gecko currently means only
175 # Firefox
176 self.compat.append({ 174 self.compat.append({
177 'id': packager.KNOWN_APPS['firefox'], 175 'id': 'gecko',
178 'minVersion': metadata.get('compat', 'gecko') 176 'minVersion': metadata.get('compat', 'gecko')
179 }) 177 })
180 178
181 def readAndroidMetadata(self): 179 def readAndroidMetadata(self):
182 """ 180 """
183 Read Android-specific metadata from AndroidManifest.xml file. 181 Read Android-specific metadata from AndroidManifest.xml file.
184 """ 182 """
185 manifestFile = open(os.path.join(self.tempdir, 'AndroidManifest.xml'), ' r') 183 manifestFile = open(os.path.join(self.tempdir, 'AndroidManifest.xml'), ' r')
186 manifest = parseXml(manifestFile) 184 manifest = parseXml(manifestFile)
187 manifestFile.close() 185 manifestFile.close()
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 self.updatedFromGallery = False 233 self.updatedFromGallery = False
236 234
237 def writeUpdateManifest(self): 235 def writeUpdateManifest(self):
238 """ 236 """
239 Writes update manifest for the current build 237 Writes update manifest for the current build
240 """ 238 """
241 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) 239 baseDir = os.path.join(self.config.nightliesDirectory, self.basename)
242 if self.config.type == 'safari': 240 if self.config.type == 'safari':
243 manifestPath = os.path.join(baseDir, 'updates.plist') 241 manifestPath = os.path.join(baseDir, 'updates.plist')
244 templateName = 'safariUpdateManifest' 242 templateName = 'safariUpdateManifest'
243 autoescape = True
245 elif self.config.type == 'android': 244 elif self.config.type == 'android':
246 manifestPath = os.path.join(baseDir, 'updates.xml') 245 manifestPath = os.path.join(baseDir, 'updates.xml')
247 templateName = 'androidUpdateManifest' 246 templateName = 'androidUpdateManifest'
247 autoescape = True
248 elif self.config.type == 'gecko-webext': 248 elif self.config.type == 'gecko-webext':
249 manifestPath = os.path.join(baseDir, 'update.rdf') 249 manifestPath = os.path.join(baseDir, 'updates.json')
250 templateName = 'geckoUpdateManifest' 250 templateName = 'geckoUpdateManifest'
Wladimir Palant 2016/12/05 08:42:03 Note: the builds currently won't use that update m
251 autoescape = False
251 else: 252 else:
252 return 253 return
253 254
254 if not os.path.exists(baseDir): 255 if not os.path.exists(baseDir):
255 os.makedirs(baseDir) 256 os.makedirs(baseDir)
256 257
257 # ABP for Android used to have its own update manifest format. We need t o 258 # ABP for Android used to have its own update manifest format. We need t o
258 # generate both that and the new one in the libadblockplus format as lon g 259 # generate both that and the new one in the libadblockplus format as lon g
259 # as a significant amount of users is on an old version. 260 # as a significant amount of users is on an old version.
260 if self.config.type == 'android': 261 if self.config.type == 'android':
261 newManifestPath = os.path.join(baseDir, 'update.json') 262 newManifestPath = os.path.join(baseDir, 'update.json')
262 writeAndroidUpdateManifest(newManifestPath, [{ 263 writeAndroidUpdateManifest(newManifestPath, [{
263 'basename': self.basename, 264 'basename': self.basename,
264 'version': self.version, 265 'version': self.version,
265 'updateURL': self.updateURL 266 'updateURL': self.updateURL
266 }]) 267 }])
267 268
268 template = get_template(get_config().get('extensions', templateName)) 269 template = get_template(get_config().get('extensions', templateName),
270 autoescape=autoescape)
269 template.stream({'extensions': [self]}).dump(manifestPath) 271 template.stream({'extensions': [self]}).dump(manifestPath)
270 272
271 def writeIEUpdateManifest(self, versions): 273 def writeIEUpdateManifest(self, versions):
272 """ 274 """
273 Writes update.json file for the latest IE build 275 Writes update.json file for the latest IE build
274 """ 276 """
275 if len(versions) == 0: 277 if len(versions) == 0:
276 return 278 return
277 279
278 version = versions[0] 280 version = versions[0]
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 self.writeIEUpdateManifest(versions) 563 self.writeIEUpdateManifest(versions)
562 564
563 # update index page 565 # update index page
564 self.updateIndex(versions) 566 self.updateIndex(versions)
565 567
566 # update nightlies config 568 # update nightlies config
567 self.config.latestRevision = self.revision 569 self.config.latestRevision = self.revision
568 570
569 if (self.config.type in {'gecko', 'gecko-webext'} and 571 if (self.config.type in {'gecko', 'gecko-webext'} and
570 self.config.galleryID and 572 self.config.galleryID and
571 get_config().has_option('extensions', 'amo_key')): 573 get_config().has_option('extensions', 'amo_key')):
Wladimir Palant 2016/12/05 08:42:03 Overindenting seems to be the most readable approa
572 self.uploadToMozillaAddons() 574 self.uploadToMozillaAddons()
573 elif self.config.type == 'chrome' and self.config.clientID and self. config.clientSecret and self.config.refreshToken: 575 elif self.config.type == 'chrome' and self.config.clientID and self. config.clientSecret and self.config.refreshToken:
574 self.uploadToChromeWebStore() 576 self.uploadToChromeWebStore()
575 finally: 577 finally:
576 # clean up 578 # clean up
577 if self.tempdir: 579 if self.tempdir:
578 shutil.rmtree(self.tempdir, ignore_errors=True) 580 shutil.rmtree(self.tempdir, ignore_errors=True)
579 581
580 582
581 def main(): 583 def main():
(...skipping 17 matching lines...) Expand all
599 except Exception as ex: 601 except Exception as ex:
600 logging.error('The build for %s failed:', repo) 602 logging.error('The build for %s failed:', repo)
601 logging.exception(ex) 603 logging.exception(ex)
602 604
603 file = open(nightlyConfigFile, 'wb') 605 file = open(nightlyConfigFile, 'wb')
604 nightlyConfig.write(file) 606 nightlyConfig.write(file)
605 607
606 608
607 if __name__ == '__main__': 609 if __name__ == '__main__':
608 main() 610 main()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld