 Issue 29366797:
  Issue 4697 - Add support for WebExtension-based Firefox development builds  (Closed) 
  Base URL: https://hg.adblockplus.org/sitescripts
    
  
    Issue 29366797:
  Issue 4697 - Add support for WebExtension-based Firefox development builds  (Closed) 
  Base URL: https://hg.adblockplus.org/sitescripts| Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 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 Loading... | |
| 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 # As far as WebExtensions are concerned, Gecko currently means only | |
| 175 # Firefox | |
| 176 self.compat.append({ | |
| 177 'id': packager.KNOWN_APPS['firefox'], | |
| 178 'minVersion': metadata.get('compat', 'gecko') | |
| 179 }) | |
| 180 | |
| 173 def readAndroidMetadata(self): | 181 def readAndroidMetadata(self): | 
| 174 """ | 182 """ | 
| 175 Read Android-specific metadata from AndroidManifest.xml file. | 183 Read Android-specific metadata from AndroidManifest.xml file. | 
| 176 """ | 184 """ | 
| 177 manifestFile = open(os.path.join(self.tempdir, 'AndroidManifest.xml'), ' r') | 185 manifestFile = open(os.path.join(self.tempdir, 'AndroidManifest.xml'), ' r') | 
| 178 manifest = parseXml(manifestFile) | 186 manifest = parseXml(manifestFile) | 
| 179 manifestFile.close() | 187 manifestFile.close() | 
| 180 | 188 | 
| 181 root = manifest.documentElement | 189 root = manifest.documentElement | 
| 182 self.version = root.attributes['android:versionName'].value | 190 self.version = root.attributes['android:versionName'].value | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 | 229 | 
| 222 self.certificateID = packager.get_developer_identifier(certs) | 230 self.certificateID = packager.get_developer_identifier(certs) | 
| 223 self.version = packager.getBuildVersion(self.tempdir, metadata, False, | 231 self.version = packager.getBuildVersion(self.tempdir, metadata, False, | 
| 224 self.buildNum) | 232 self.buildNum) | 
| 225 self.shortVersion = metadata.get('general', 'version') | 233 self.shortVersion = metadata.get('general', 'version') | 
| 226 self.basename = metadata.get('general', 'basename') | 234 self.basename = metadata.get('general', 'basename') | 
| 227 self.updatedFromGallery = False | 235 self.updatedFromGallery = False | 
| 228 | 236 | 
| 229 def writeUpdateManifest(self): | 237 def writeUpdateManifest(self): | 
| 230 """ | 238 """ | 
| 231 Writes update.rdf file for the current build | 239 Writes update manifest for the current build | 
| 232 """ | 240 """ | 
| 233 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) | 241 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) | 
| 234 if self.config.type == 'safari': | 242 if self.config.type == 'safari': | 
| 235 manifestPath = os.path.join(baseDir, 'updates.plist') | 243 manifestPath = os.path.join(baseDir, 'updates.plist') | 
| 236 templateName = 'safariUpdateManifest' | 244 templateName = 'safariUpdateManifest' | 
| 237 elif self.config.type == 'android': | 245 elif self.config.type == 'android': | 
| 238 manifestPath = os.path.join(baseDir, 'updates.xml') | 246 manifestPath = os.path.join(baseDir, 'updates.xml') | 
| 239 templateName = 'androidUpdateManifest' | 247 templateName = 'androidUpdateManifest' | 
| 248 elif self.config.type == 'gecko-webext': | |
| 249 manifestPath = os.path.join(baseDir, 'update.rdf') | |
| 250 templateName = 'geckoUpdateManifest' | |
| 
Wladimir Palant
2016/12/05 08:42:03
Note: the builds currently won't use that update m
 | |
| 240 else: | 251 else: | 
| 241 return | 252 return | 
| 242 | 253 | 
| 243 if not os.path.exists(baseDir): | 254 if not os.path.exists(baseDir): | 
| 244 os.makedirs(baseDir) | 255 os.makedirs(baseDir) | 
| 245 | 256 | 
| 246 # ABP for Android used to have its own update manifest format. We need t o | 257 # 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 | 258 # 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. | 259 # as a significant amount of users is on an old version. | 
| 249 if self.config.type == 'android': | 260 if self.config.type == 'android': | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 os.remove(self.path) | 329 os.remove(self.path) | 
| 319 raise | 330 raise | 
| 320 else: | 331 else: | 
| 321 env = os.environ | 332 env = os.environ | 
| 322 spiderMonkeyBinary = self.config.spiderMonkeyBinary | 333 spiderMonkeyBinary = self.config.spiderMonkeyBinary | 
| 323 if spiderMonkeyBinary: | 334 if spiderMonkeyBinary: | 
| 324 env = dict(env, SPIDERMONKEY_BINARY=spiderMonkeyBinary) | 335 env = dict(env, SPIDERMONKEY_BINARY=spiderMonkeyBinary) | 
| 325 | 336 | 
| 326 command = [os.path.join(self.tempdir, 'build.py'), | 337 command = [os.path.join(self.tempdir, 'build.py'), | 
| 327 '-t', self.config.type, 'build', '-b', self.buildNum] | 338 '-t', self.config.type, 'build', '-b', self.buildNum] | 
| 328 if self.config.type != 'gecko': | 339 if self.config.type not in {'gecko', 'gecko-webext'}: | 
| 329 command.extend(['-k', self.config.keyFile]) | 340 command.extend(['-k', self.config.keyFile]) | 
| 330 command.append(self.path) | 341 command.append(self.path) | 
| 331 subprocess.check_call(command, env=env) | 342 subprocess.check_call(command, env=env) | 
| 332 | 343 | 
| 333 if not os.path.exists(self.path): | 344 if not os.path.exists(self.path): | 
| 334 raise Exception("Build failed, output file hasn't been created") | 345 raise Exception("Build failed, output file hasn't been created") | 
| 335 | 346 | 
| 336 linkPath = os.path.join(baseDir, '00latest%s' % self.config.packageSuffi x) | 347 linkPath = os.path.join(baseDir, '00latest%s' % self.config.packageSuffi x) | 
| 337 if hasattr(os, 'symlink'): | 348 if hasattr(os, 'symlink'): | 
| 338 if os.path.exists(linkPath): | 349 if os.path.exists(linkPath): | 
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 521 self.copyRepository() | 532 self.copyRepository() | 
| 522 self.buildNum = self.getCurrentBuild() | 533 self.buildNum = self.getCurrentBuild() | 
| 523 | 534 | 
| 524 # get meta data from the repository | 535 # get meta data from the repository | 
| 525 if self.config.type == 'android': | 536 if self.config.type == 'android': | 
| 526 self.readAndroidMetadata() | 537 self.readAndroidMetadata() | 
| 527 elif self.config.type == 'chrome': | 538 elif self.config.type == 'chrome': | 
| 528 self.readChromeMetadata() | 539 self.readChromeMetadata() | 
| 529 elif self.config.type == 'safari': | 540 elif self.config.type == 'safari': | 
| 530 self.readSafariMetadata() | 541 self.readSafariMetadata() | 
| 542 elif self.config.type in {'gecko', 'gecko-webext'}: | |
| 543 self.readGeckoMetadata() | |
| 531 else: | 544 else: | 
| 532 self.readGeckoMetadata() | 545 raise Exception('Unknown build type {}' % self.config.type) | 
| 533 | 546 | 
| 534 # create development build | 547 # create development build | 
| 535 self.build() | 548 self.build() | 
| 536 | 549 | 
| 537 # write out changelog | 550 # write out changelog | 
| 538 self.writeChangelog(self.getChanges()) | 551 self.writeChangelog(self.getChanges()) | 
| 539 | 552 | 
| 540 # write update manifest | 553 # write update manifest | 
| 541 if self.config.type != 'gecko': | 554 if self.config.type != 'gecko': | 
| 542 self.writeUpdateManifest() | 555 self.writeUpdateManifest() | 
| 543 | 556 | 
| 544 # retire old builds | 557 # retire old builds | 
| 545 versions = self.retireBuilds() | 558 versions = self.retireBuilds() | 
| 546 | 559 | 
| 547 if self.config.type == 'ie': | 560 if self.config.type == 'ie': | 
| 548 self.writeIEUpdateManifest(versions) | 561 self.writeIEUpdateManifest(versions) | 
| 549 | 562 | 
| 550 # update index page | 563 # update index page | 
| 551 self.updateIndex(versions) | 564 self.updateIndex(versions) | 
| 552 | 565 | 
| 553 # update nightlies config | 566 # update nightlies config | 
| 554 self.config.latestRevision = self.revision | 567 self.config.latestRevision = self.revision | 
| 555 | 568 | 
| 556 if self.config.type == 'gecko' and self.config.galleryID and get_con fig().has_option('extensions', 'amo_key'): | 569 if (self.config.type in {'gecko', 'gecko-webext'} and | 
| 570 self.config.galleryID and | |
| 571 get_config().has_option('extensions', 'amo_key')): | |
| 
Wladimir Palant
2016/12/05 08:42:03
Overindenting seems to be the most readable approa
 | |
| 557 self.uploadToMozillaAddons() | 572 self.uploadToMozillaAddons() | 
| 558 elif self.config.type == 'chrome' and self.config.clientID and self. config.clientSecret and self.config.refreshToken: | 573 elif self.config.type == 'chrome' and self.config.clientID and self. config.clientSecret and self.config.refreshToken: | 
| 559 self.uploadToChromeWebStore() | 574 self.uploadToChromeWebStore() | 
| 560 finally: | 575 finally: | 
| 561 # clean up | 576 # clean up | 
| 562 if self.tempdir: | 577 if self.tempdir: | 
| 563 shutil.rmtree(self.tempdir, ignore_errors=True) | 578 shutil.rmtree(self.tempdir, ignore_errors=True) | 
| 564 | 579 | 
| 565 | 580 | 
| 566 def main(): | 581 def main(): | 
| (...skipping 17 matching lines...) Expand all Loading... | |
| 584 except Exception as ex: | 599 except Exception as ex: | 
| 585 logging.error('The build for %s failed:', repo) | 600 logging.error('The build for %s failed:', repo) | 
| 586 logging.exception(ex) | 601 logging.exception(ex) | 
| 587 | 602 | 
| 588 file = open(nightlyConfigFile, 'wb') | 603 file = open(nightlyConfigFile, 'wb') | 
| 589 nightlyConfig.write(file) | 604 nightlyConfig.write(file) | 
| 590 | 605 | 
| 591 | 606 | 
| 592 if __name__ == '__main__': | 607 if __name__ == '__main__': | 
| 593 main() | 608 main() | 
| OLD | NEW |