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

Side by Side Diff: 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
Patch Set: Changed update manifest format Created Dec. 5, 2016, 9:47 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.example ('k') | sitescripts/extensions/template/update.rdf » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 self.extensionID = metadata.get('general', 'id') 163 self.extensionID = metadata.get('general', 'id')
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'):
174 self.compat.append({
175 'id': 'gecko',
176 'minVersion': metadata.get('compat', 'gecko')
177 })
178
173 def readAndroidMetadata(self): 179 def readAndroidMetadata(self):
174 """ 180 """
175 Read Android-specific metadata from AndroidManifest.xml file. 181 Read Android-specific metadata from AndroidManifest.xml file.
176 """ 182 """
177 manifestFile = open(os.path.join(self.tempdir, 'AndroidManifest.xml'), ' r') 183 manifestFile = open(os.path.join(self.tempdir, 'AndroidManifest.xml'), ' r')
178 manifest = parseXml(manifestFile) 184 manifest = parseXml(manifestFile)
179 manifestFile.close() 185 manifestFile.close()
180 186
181 root = manifest.documentElement 187 root = manifest.documentElement
182 self.version = root.attributes['android:versionName'].value 188 self.version = root.attributes['android:versionName'].value
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 227
222 self.certificateID = packager.get_developer_identifier(certs) 228 self.certificateID = packager.get_developer_identifier(certs)
223 self.version = packager.getBuildVersion(self.tempdir, metadata, False, 229 self.version = packager.getBuildVersion(self.tempdir, metadata, False,
224 self.buildNum) 230 self.buildNum)
225 self.shortVersion = metadata.get('general', 'version') 231 self.shortVersion = metadata.get('general', 'version')
226 self.basename = metadata.get('general', 'basename') 232 self.basename = metadata.get('general', 'basename')
227 self.updatedFromGallery = False 233 self.updatedFromGallery = False
228 234
229 def writeUpdateManifest(self): 235 def writeUpdateManifest(self):
230 """ 236 """
231 Writes update.rdf file for the current build 237 Writes update manifest for the current build
232 """ 238 """
233 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) 239 baseDir = os.path.join(self.config.nightliesDirectory, self.basename)
234 if self.config.type == 'safari': 240 if self.config.type == 'safari':
235 manifestPath = os.path.join(baseDir, 'updates.plist') 241 manifestPath = os.path.join(baseDir, 'updates.plist')
236 templateName = 'safariUpdateManifest' 242 templateName = 'safariUpdateManifest'
243 autoescape = True
237 elif self.config.type == 'android': 244 elif self.config.type == 'android':
238 manifestPath = os.path.join(baseDir, 'updates.xml') 245 manifestPath = os.path.join(baseDir, 'updates.xml')
239 templateName = 'androidUpdateManifest' 246 templateName = 'androidUpdateManifest'
247 autoescape = True
248 elif self.config.type == 'gecko-webext':
249 manifestPath = os.path.join(baseDir, 'updates.json')
250 templateName = 'geckoUpdateManifest'
251 autoescape = False
240 else: 252 else:
241 return 253 return
242 254
243 if not os.path.exists(baseDir): 255 if not os.path.exists(baseDir):
244 os.makedirs(baseDir) 256 os.makedirs(baseDir)
245 257
246 # 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
247 # 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
248 # as a significant amount of users is on an old version. 260 # as a significant amount of users is on an old version.
249 if self.config.type == 'android': 261 if self.config.type == 'android':
250 newManifestPath = os.path.join(baseDir, 'update.json') 262 newManifestPath = os.path.join(baseDir, 'update.json')
251 writeAndroidUpdateManifest(newManifestPath, [{ 263 writeAndroidUpdateManifest(newManifestPath, [{
252 'basename': self.basename, 264 'basename': self.basename,
253 'version': self.version, 265 'version': self.version,
254 'updateURL': self.updateURL 266 'updateURL': self.updateURL
255 }]) 267 }])
256 268
257 template = get_template(get_config().get('extensions', templateName)) 269 template = get_template(get_config().get('extensions', templateName),
270 autoescape=autoescape)
258 template.stream({'extensions': [self]}).dump(manifestPath) 271 template.stream({'extensions': [self]}).dump(manifestPath)
259 272
260 def writeIEUpdateManifest(self, versions): 273 def writeIEUpdateManifest(self, versions):
261 """ 274 """
262 Writes update.json file for the latest IE build 275 Writes update.json file for the latest IE build
263 """ 276 """
264 if len(versions) == 0: 277 if len(versions) == 0:
265 return 278 return
266 279
267 version = versions[0] 280 version = versions[0]
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 os.remove(self.path) 331 os.remove(self.path)
319 raise 332 raise
320 else: 333 else:
321 env = os.environ 334 env = os.environ
322 spiderMonkeyBinary = self.config.spiderMonkeyBinary 335 spiderMonkeyBinary = self.config.spiderMonkeyBinary
323 if spiderMonkeyBinary: 336 if spiderMonkeyBinary:
324 env = dict(env, SPIDERMONKEY_BINARY=spiderMonkeyBinary) 337 env = dict(env, SPIDERMONKEY_BINARY=spiderMonkeyBinary)
325 338
326 command = [os.path.join(self.tempdir, 'build.py'), 339 command = [os.path.join(self.tempdir, 'build.py'),
327 '-t', self.config.type, 'build', '-b', self.buildNum] 340 '-t', self.config.type, 'build', '-b', self.buildNum]
328 if self.config.type != 'gecko': 341 if self.config.type not in {'gecko', 'gecko-webext'}:
329 command.extend(['-k', self.config.keyFile]) 342 command.extend(['-k', self.config.keyFile])
330 command.append(self.path) 343 command.append(self.path)
331 subprocess.check_call(command, env=env) 344 subprocess.check_call(command, env=env)
332 345
333 if not os.path.exists(self.path): 346 if not os.path.exists(self.path):
334 raise Exception("Build failed, output file hasn't been created") 347 raise Exception("Build failed, output file hasn't been created")
335 348
336 linkPath = os.path.join(baseDir, '00latest%s' % self.config.packageSuffi x) 349 linkPath = os.path.join(baseDir, '00latest%s' % self.config.packageSuffi x)
337 if hasattr(os, 'symlink'): 350 if hasattr(os, 'symlink'):
338 if os.path.exists(linkPath): 351 if os.path.exists(linkPath):
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 self.copyRepository() 534 self.copyRepository()
522 self.buildNum = self.getCurrentBuild() 535 self.buildNum = self.getCurrentBuild()
523 536
524 # get meta data from the repository 537 # get meta data from the repository
525 if self.config.type == 'android': 538 if self.config.type == 'android':
526 self.readAndroidMetadata() 539 self.readAndroidMetadata()
527 elif self.config.type == 'chrome': 540 elif self.config.type == 'chrome':
528 self.readChromeMetadata() 541 self.readChromeMetadata()
529 elif self.config.type == 'safari': 542 elif self.config.type == 'safari':
530 self.readSafariMetadata() 543 self.readSafariMetadata()
544 elif self.config.type in {'gecko', 'gecko-webext'}:
545 self.readGeckoMetadata()
531 else: 546 else:
532 self.readGeckoMetadata() 547 raise Exception('Unknown build type {}' % self.config.type)
533 548
534 # create development build 549 # create development build
535 self.build() 550 self.build()
536 551
537 # write out changelog 552 # write out changelog
538 self.writeChangelog(self.getChanges()) 553 self.writeChangelog(self.getChanges())
539 554
540 # write update manifest 555 # write update manifest
541 if self.config.type != 'gecko': 556 if self.config.type != 'gecko':
542 self.writeUpdateManifest() 557 self.writeUpdateManifest()
543 558
544 # retire old builds 559 # retire old builds
545 versions = self.retireBuilds() 560 versions = self.retireBuilds()
546 561
547 if self.config.type == 'ie': 562 if self.config.type == 'ie':
548 self.writeIEUpdateManifest(versions) 563 self.writeIEUpdateManifest(versions)
549 564
550 # update index page 565 # update index page
551 self.updateIndex(versions) 566 self.updateIndex(versions)
552 567
553 # update nightlies config 568 # update nightlies config
554 self.config.latestRevision = self.revision 569 self.config.latestRevision = self.revision
555 570
556 if self.config.type == 'gecko' and self.config.galleryID and get_con fig().has_option('extensions', 'amo_key'): 571 if (self.config.type in {'gecko', 'gecko-webext'} and
572 self.config.galleryID and
573 get_config().has_option('extensions', 'amo_key')):
557 self.uploadToMozillaAddons() 574 self.uploadToMozillaAddons()
558 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:
559 self.uploadToChromeWebStore() 576 self.uploadToChromeWebStore()
560 finally: 577 finally:
561 # clean up 578 # clean up
562 if self.tempdir: 579 if self.tempdir:
563 shutil.rmtree(self.tempdir, ignore_errors=True) 580 shutil.rmtree(self.tempdir, ignore_errors=True)
564 581
565 582
566 def main(): 583 def main():
(...skipping 17 matching lines...) Expand all
584 except Exception as ex: 601 except Exception as ex:
585 logging.error('The build for %s failed:', repo) 602 logging.error('The build for %s failed:', repo)
586 logging.exception(ex) 603 logging.exception(ex)
587 604
588 file = open(nightlyConfigFile, 'wb') 605 file = open(nightlyConfigFile, 'wb')
589 nightlyConfig.write(file) 606 nightlyConfig.write(file)
590 607
591 608
592 if __name__ == '__main__': 609 if __name__ == '__main__':
593 main() 610 main()
OLDNEW
« no previous file with comments | « .sitescripts.example ('k') | sitescripts/extensions/template/update.rdf » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld