| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 | 19 |
| 20 Nightly builds generation script | 20 Nightly builds generation script |
| 21 ================================ | 21 ================================ |
| 22 | 22 |
| 23 This script generates nightly builds of extensions, together | 23 This script generates nightly builds of extensions, together |
| 24 with changelogs and documentation. | 24 with changelogs and documentation. |
| 25 | 25 |
| 26 """ | 26 """ |
| 27 | 27 |
| 28 import sys, os, os.path, codecs, subprocess, ConfigParser, traceback, json, hash lib | 28 import sys, os, os.path, subprocess, ConfigParser, traceback, json, hashlib |
| 29 import tempfile, shutil, urlparse, pipes, time, urllib2, struct | 29 import tempfile, shutil, urlparse, pipes, time, urllib2, struct |
| 30 from datetime import datetime | 30 from datetime import datetime |
| 31 from urllib import urlencode | 31 from urllib import urlencode |
| 32 from xml.dom.minidom import parse as parseXml | 32 from xml.dom.minidom import parse as parseXml |
| 33 from sitescripts.utils import get_config, setupStderr, get_template | 33 from sitescripts.utils import get_config, setupStderr, get_template |
| 34 from sitescripts.extensions.utils import compareVersions, Configuration, getSafa riCertificateID | 34 from sitescripts.extensions.utils import ( |
| 35 compareVersions, Configuration, getSafariCertificateID, writeIEUpdateManifest) | |
| 35 | 36 |
| 36 MAX_BUILDS = 50 | 37 MAX_BUILDS = 50 |
| 37 | 38 |
| 38 | 39 |
| 39 class NightlyBuild(object): | 40 class NightlyBuild(object): |
| 40 """ | 41 """ |
| 41 Performs the build process for an extension, | 42 Performs the build process for an extension, |
| 42 generating changelogs and documentation. | 43 generating changelogs and documentation. |
| 43 """ | 44 """ |
| 44 | 45 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 elif self.config.type == 'android': | 201 elif self.config.type == 'android': |
| 201 manifestPath = os.path.join(baseDir, "updates.xml") | 202 manifestPath = os.path.join(baseDir, "updates.xml") |
| 202 templateName = 'androidUpdateManifest' | 203 templateName = 'androidUpdateManifest' |
| 203 else: | 204 else: |
| 204 manifestPath = os.path.join(baseDir, "update.rdf") | 205 manifestPath = os.path.join(baseDir, "update.rdf") |
| 205 templateName = 'geckoUpdateManifest' | 206 templateName = 'geckoUpdateManifest' |
| 206 | 207 |
| 207 template = get_template(get_config().get('extensions', templateName)) | 208 template = get_template(get_config().get('extensions', templateName)) |
| 208 template.stream({'extensions': [self]}).dump(manifestPath) | 209 template.stream({'extensions': [self]}).dump(manifestPath) |
| 209 | 210 |
| 210 def writeLibabpUpdateManifest(self, updates): | |
| 211 """ | |
| 212 Writes update.json file for libadblockplus | |
| 213 """ | |
| 214 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) | |
| 215 if not os.path.exists(baseDir): | |
| 216 os.makedirs(baseDir) | |
| 217 manifestPath = os.path.join(baseDir, "update.json") | |
| 218 | |
| 219 handle = codecs.open(manifestPath, "wb", encoding="UTF-8") | |
| 220 json.dump(updates, handle, ensure_ascii=False, indent=2, separators=(",", ": ")) | |
| 221 handle.close() | |
| 222 | |
| 223 def writeIEUpdateManifest(self, versions): | 211 def writeIEUpdateManifest(self, versions): |
| 224 """ | 212 """ |
| 225 Writes update.json file for the latest IE build | 213 Writes update.json file for the latest IE build |
| 226 """ | 214 """ |
| 227 if len(versions) == 0: | 215 if len(versions) == 0: |
| 228 return | 216 return |
| 229 | 217 |
| 230 version = versions[0] | 218 version = versions[0] |
| 231 packageName = self.basename + '-' + versions[0] + self.config.packageSuffix | 219 packageName = self.basename + '-' + version + self.config.packageSuffix |
| 232 updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename + '/' + packageName + '?update') | 220 updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename + '/' + packageName + '?update') |
| 233 self.writeLibabpUpdateManifest({ | 221 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) |
| 234 "%s/%s" % (self.basename, "msie64"): { | 222 manifestPath = os.path.join(baseDir, 'update.json') |
| 235 "url": updateURL.replace(".exe", "-x64.msi"), | 223 writeIEUpdateManifest(manifestPath, [{ |
|
Felix Dahlke
2014/07/29 15:10:27
Not brilliant that this function has the same name
Wladimir Palant
2014/07/30 14:02:23
Don't import the function globally but only in thi
Felix Dahlke
2014/07/30 14:22:36
Yeah, I like that. Done.
| |
| 236 "version": version, | 224 'basename': self.basename, |
| 237 }, | 225 'version': version, |
| 238 "%s/%s" % (self.basename, "msie32"): { | 226 'updateURL': updateURL |
| 239 "url": updateURL.replace(".exe", "-x86.msi"), | 227 }]) |
| 240 "version": version, | |
| 241 }, | |
| 242 }) | |
| 243 | 228 |
| 244 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) | |
| 245 for suffix in (self.config.packageSuffix, self.config.packageSuffix.replace( "-x64", "-x86")): | 229 for suffix in (self.config.packageSuffix, self.config.packageSuffix.replace( "-x64", "-x86")): |
| 246 linkPath = os.path.join(baseDir, '00latest%s' % suffix) | 230 linkPath = os.path.join(baseDir, '00latest%s' % suffix) |
| 247 outputPath = os.path.join(baseDir, self.basename + '-' + versions[0] + suf fix) | 231 outputPath = os.path.join(baseDir, self.basename + '-' + version + suffix) |
| 248 if hasattr(os, 'symlink'): | 232 if hasattr(os, 'symlink'): |
| 249 if os.path.exists(linkPath): | 233 if os.path.exists(linkPath): |
| 250 os.remove(linkPath) | 234 os.remove(linkPath) |
| 251 os.symlink(os.path.basename(outputPath), linkPath) | 235 os.symlink(os.path.basename(outputPath), linkPath) |
| 252 else: | 236 else: |
| 253 shutil.copyfile(outputPath, linkPath) | 237 shutil.copyfile(outputPath, linkPath) |
| 254 | 238 |
| 255 | |
| 256 def build(self): | 239 def build(self): |
| 257 """ | 240 """ |
| 258 run the build command in the tempdir | 241 run the build command in the tempdir |
| 259 """ | 242 """ |
| 260 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) | 243 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) |
| 261 if not os.path.exists(baseDir): | 244 if not os.path.exists(baseDir): |
| 262 os.makedirs(baseDir) | 245 os.makedirs(baseDir) |
| 263 outputFile = "%s-%s%s" % (self.basename, self.version, self.config.packageSu ffix) | 246 outputFile = "%s-%s%s" % (self.basename, self.version, self.config.packageSu ffix) |
| 264 self.path = os.path.join(baseDir, outputFile) | 247 self.path = os.path.join(baseDir, outputFile) |
| 265 self.updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename + '/' + outputFile + '?update') | 248 self.updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename + '/' + outputFile + '?update') |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 except Exception, ex: | 491 except Exception, ex: |
| 509 print >>sys.stderr, "The build for %s failed:" % repo | 492 print >>sys.stderr, "The build for %s failed:" % repo |
| 510 traceback.print_exc() | 493 traceback.print_exc() |
| 511 | 494 |
| 512 file = open(nightlyConfigFile, 'wb') | 495 file = open(nightlyConfigFile, 'wb') |
| 513 nightlyConfig.write(file) | 496 nightlyConfig.write(file) |
| 514 | 497 |
| 515 | 498 |
| 516 if __name__ == '__main__': | 499 if __name__ == '__main__': |
| 517 main() | 500 main() |
| OLD | NEW |