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-2013 Eyeo GmbH | 4 # Copyright (C) 2006-2013 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, subprocess, ConfigParser, traceback, json, hashlib | 28 import sys, os, os.path, codecs, subprocess, ConfigParser, traceback, json, hash
lib |
29 import tempfile, re, shutil, urlparse, pipes | 29 import tempfile, re, shutil, urlparse, pipes |
30 from datetime import datetime | 30 from datetime import datetime |
31 from xml.dom.minidom import parse as parseXml | 31 from xml.dom.minidom import parse as parseXml |
32 from sitescripts.utils import get_config, setupStderr, get_template | 32 from sitescripts.utils import get_config, setupStderr, get_template |
33 from sitescripts.extensions.utils import compareVersions, Configuration | 33 from sitescripts.extensions.utils import compareVersions, Configuration |
34 | 34 |
35 MAX_BUILDS = 50 | 35 MAX_BUILDS = 50 |
36 | 36 |
37 | 37 |
38 class NightlyBuild(object): | 38 class NightlyBuild(object): |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 elif self.config.type == 'android': | 188 elif self.config.type == 'android': |
189 manifestPath = os.path.join(baseDir, "updates.xml") | 189 manifestPath = os.path.join(baseDir, "updates.xml") |
190 templateName = 'androidUpdateManifest' | 190 templateName = 'androidUpdateManifest' |
191 else: | 191 else: |
192 manifestPath = os.path.join(baseDir, "update.rdf") | 192 manifestPath = os.path.join(baseDir, "update.rdf") |
193 templateName = 'geckoUpdateManifest' | 193 templateName = 'geckoUpdateManifest' |
194 | 194 |
195 template = get_template(get_config().get('extensions', templateName)) | 195 template = get_template(get_config().get('extensions', templateName)) |
196 template.stream({'extensions': [self]}).dump(manifestPath) | 196 template.stream({'extensions': [self]}).dump(manifestPath) |
197 | 197 |
| 198 def writeLibabpUpdateManifest(self, updates): |
| 199 """ |
| 200 Writes update.json file for libadblockplus |
| 201 """ |
| 202 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) |
| 203 if not os.path.exists(baseDir): |
| 204 os.makedirs(baseDir) |
| 205 manifestPath = os.path.join(baseDir, "update.json") |
| 206 |
| 207 handle = codecs.open(manifestPath, "wb", encoding="UTF-8") |
| 208 json.dump(updates, handle, ensure_ascii=False, indent=2, separators=(",", ":
")) |
| 209 handle.close() |
| 210 |
| 211 def writeIEUpdateManifest(self, versions): |
| 212 """ |
| 213 Writes update.json file for the latest IE build |
| 214 """ |
| 215 if len(versions) == 0: |
| 216 return |
| 217 |
| 218 version = versions[0] |
| 219 packageName = self.basename + '-' + versions[0] + self.config.packageSuffix |
| 220 updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename + '/' +
packageName + '?update') |
| 221 self.writeLibabpUpdateManifest({ |
| 222 "%s/%s" % (self.basename, "msie64"): { |
| 223 "url": updateURL, |
| 224 "version": version, |
| 225 }, |
| 226 "%s/%s" % (self.basename, "win64"): { |
| 227 "url": updateURL, |
| 228 "version": version, |
| 229 }, |
| 230 "%s/%s" % (self.basename, "msie32"): { |
| 231 "url": updateURL.replace("-x64", "-x86"), |
| 232 "version": version, |
| 233 }, |
| 234 "%s/%s" % (self.basename, "win32"): { |
| 235 "url": updateURL.replace("-x64", "-x86"), |
| 236 "version": version, |
| 237 }, |
| 238 }) |
| 239 |
| 240 |
198 def build(self): | 241 def build(self): |
199 """ | 242 """ |
200 run the build command in the tempdir | 243 run the build command in the tempdir |
201 """ | 244 """ |
202 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) | 245 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) |
203 if not os.path.exists(baseDir): | 246 if not os.path.exists(baseDir): |
204 os.makedirs(baseDir) | 247 os.makedirs(baseDir) |
205 outputFile = "%s-%s%s" % (self.basename, self.version, self.config.packageSu
ffix) | 248 outputFile = "%s-%s%s" % (self.basename, self.version, self.config.packageSu
ffix) |
206 outputPath = os.path.join(baseDir, outputFile) | 249 outputPath = os.path.join(baseDir, outputFile) |
207 self.updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename +
'/' + outputFile + '?update') | 250 self.updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename +
'/' + outputFile + '?update') |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 os.path.join(self.tempdir, 'lib')] | 353 os.path.join(self.tempdir, 'lib')] |
311 subprocess.Popen(command, stdout=subprocess.PIPE).communicate() | 354 subprocess.Popen(command, stdout=subprocess.PIPE).communicate() |
312 finally: | 355 finally: |
313 shutil.rmtree(docsdir, ignore_errors=True) | 356 shutil.rmtree(docsdir, ignore_errors=True) |
314 | 357 |
315 def run(self): | 358 def run(self): |
316 """ | 359 """ |
317 Run the nightly build process for one extension | 360 Run the nightly build process for one extension |
318 """ | 361 """ |
319 try: | 362 try: |
320 if self.config.type == 'kmeleon': | 363 if self.config.type == 'ie': |
321 # We cannot build K-Meleon builds, simply list the builds already in | 364 # We cannot build IE builds, simply list the builds already in |
322 # the directory. Basename has to be deduced from the repository name. | 365 # the directory. Basename has to be deduced from the repository name. |
323 self.basename = os.path.basename(self.config.repository) | 366 self.basename = os.path.basename(self.config.repository) |
324 else: | 367 else: |
325 # copy the repository into a temporary directory | 368 # copy the repository into a temporary directory |
326 self.copyRepository() | 369 self.copyRepository() |
327 | 370 |
328 # get meta data from the repository | 371 # get meta data from the repository |
329 if self.config.type == 'android': | 372 if self.config.type == 'android': |
330 self.readAndroidMetadata() | 373 self.readAndroidMetadata() |
331 elif self.config.type == 'chrome' or self.config.type == 'opera': | 374 elif self.config.type == 'chrome' or self.config.type == 'opera': |
332 self.readChromeMetadata() | 375 self.readChromeMetadata() |
333 else: | 376 else: |
334 self.readMetadata() | 377 self.readMetadata() |
335 | 378 |
336 # create development build | 379 # create development build |
337 self.build() | 380 self.build() |
338 | 381 |
339 # write out changelog | 382 # write out changelog |
340 self.writeChangelog(self.getChanges()) | 383 self.writeChangelog(self.getChanges()) |
341 | 384 |
342 # write update.rdf file | 385 # write update.rdf file |
343 self.writeUpdateManifest() | 386 self.writeUpdateManifest() |
344 | 387 |
345 # update documentation | 388 # update documentation |
346 self.updateDocs() | 389 self.updateDocs() |
347 | 390 |
348 # retire old builds | 391 # retire old builds |
349 versions = self.retireBuilds() | 392 versions = self.retireBuilds() |
350 | 393 |
| 394 if self.config.type == 'ie': |
| 395 self.writeIEUpdateManifest(versions) |
| 396 |
351 # update index page | 397 # update index page |
352 self.updateIndex(versions) | 398 self.updateIndex(versions) |
353 | 399 |
354 # update nightlies config | 400 # update nightlies config |
355 self.config.latestRevision = self.revision | 401 self.config.latestRevision = self.revision |
356 finally: | 402 finally: |
357 # clean up | 403 # clean up |
358 if self.tempdir: | 404 if self.tempdir: |
359 shutil.rmtree(self.tempdir, ignore_errors=True) | 405 shutil.rmtree(self.tempdir, ignore_errors=True) |
360 | 406 |
(...skipping 21 matching lines...) Expand all Loading... |
382 except Exception, ex: | 428 except Exception, ex: |
383 print >>sys.stderr, "The build for %s failed:" % repo | 429 print >>sys.stderr, "The build for %s failed:" % repo |
384 traceback.print_exc() | 430 traceback.print_exc() |
385 | 431 |
386 file = open(nightlyConfigFile, 'wb') | 432 file = open(nightlyConfigFile, 'wb') |
387 nightlyConfig.write(file) | 433 nightlyConfig.write(file) |
388 | 434 |
389 | 435 |
390 if __name__ == '__main__': | 436 if __name__ == '__main__': |
391 main() | 437 main() |
OLD | NEW |