OLD | NEW |
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This Source Code is subject to the terms of the Mozilla Public License | 3 # This Source Code is subject to the terms of the Mozilla Public License |
4 # version 2.0 (the "License"). You can obtain a copy of the License at | 4 # version 2.0 (the "License"). You can obtain a copy of the License at |
5 # http://mozilla.org/MPL/2.0/. | 5 # http://mozilla.org/MPL/2.0/. |
6 | 6 |
7 """ | 7 """ |
8 | 8 |
9 Nightly builds generation script | 9 Nightly builds generation script |
10 ================================ | 10 ================================ |
11 | 11 |
12 This script generates nightly builds of extensions, together | 12 This script generates nightly builds of extensions, together |
13 with changelogs and documentation. | 13 with changelogs and documentation. |
14 | 14 |
15 """ | 15 """ |
16 | 16 |
17 import sys, os, os.path, subprocess, ConfigParser, traceback, json, hashlib | 17 import sys, os, os.path, subprocess, ConfigParser, traceback, json, hashlib |
18 import tempfile, re, shutil, urlparse, pipes | 18 import tempfile, re, shutil, urlparse, pipes |
19 from datetime import datetime | 19 from datetime import datetime |
20 from xml.dom.minidom import parse as parseXml | 20 from xml.dom.minidom import parse as parseXml |
21 from sitescripts.utils import get_config, setupStderr, get_template | 21 from sitescripts.utils import get_config, setupStderr, get_template |
22 from sitescripts.extensions.utils import compareVersions, Configuration | 22 from sitescripts.extensions.utils import compareVersions, Configuration |
23 import buildtools.packagerGecko as packager | |
24 | 23 |
25 MAX_BUILDS = 50 | 24 MAX_BUILDS = 50 |
26 | 25 |
27 | 26 |
28 class NightlyBuild(object): | 27 class NightlyBuild(object): |
29 """ | 28 """ |
30 Performs the build process for an extension, | 29 Performs the build process for an extension, |
31 generating changelogs and documentation. | 30 generating changelogs and documentation. |
32 """ | 31 """ |
33 | 32 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 os.symlink(changelogPath, linkPath) | 100 os.symlink(changelogPath, linkPath) |
102 else: | 101 else: |
103 shutil.copyfile(changelogPath, linkPath) | 102 shutil.copyfile(changelogPath, linkPath) |
104 | 103 |
105 def readMetadata(self): | 104 def readMetadata(self): |
106 """ | 105 """ |
107 read the metadata file from a cloned repository | 106 read the metadata file from a cloned repository |
108 and parse id, version, basename and the compat section | 107 and parse id, version, basename and the compat section |
109 out of the file | 108 out of the file |
110 """ | 109 """ |
| 110 import buildtools.packagerGecko as packager |
111 metadata = packager.readMetadata(self.tempdir) | 111 metadata = packager.readMetadata(self.tempdir) |
112 self.extensionID = metadata.get("general", "id") | 112 self.extensionID = metadata.get("general", "id") |
113 self.version = '%s.%s' % (metadata.get("general", "version"), self.revision) | 113 self.version = '%s.%s' % (metadata.get("general", "version"), self.revision) |
114 self.basename = metadata.get("general", "basename") | 114 self.basename = metadata.get("general", "basename") |
115 self.compat = [] | 115 self.compat = [] |
116 for key, value in packager.KNOWN_APPS.iteritems(): | 116 for key, value in packager.KNOWN_APPS.iteritems(): |
117 if metadata.has_option('compat', key): | 117 if metadata.has_option('compat', key): |
118 minVersion, maxVersion = metadata.get('compat', key).split('/') | 118 minVersion, maxVersion = metadata.get('compat', key).split('/') |
119 self.compat.append({'id': value, 'minVersion': minVersion, 'maxVersion':
maxVersion}) | 119 self.compat.append({'id': value, 'minVersion': minVersion, 'maxVersion':
maxVersion}) |
120 | 120 |
(...skipping 16 matching lines...) Expand all Loading... |
137 self.basename = os.path.basename(self.config.repository) | 137 self.basename = os.path.basename(self.config.repository) |
138 | 138 |
139 def readChromeMetadata(self): | 139 def readChromeMetadata(self): |
140 """ | 140 """ |
141 Read Chrome-specific metadata from manifest.json file. It will also | 141 Read Chrome-specific metadata from manifest.json file. It will also |
142 calculate extension ID from the private key. | 142 calculate extension ID from the private key. |
143 """ | 143 """ |
144 | 144 |
145 # Calculate extension ID from public key | 145 # Calculate extension ID from public key |
146 # (see http://supercollider.dk/2010/01/calculating-chrome-extension-id-from-
your-private-key-233) | 146 # (see http://supercollider.dk/2010/01/calculating-chrome-extension-id-from-
your-private-key-233) |
147 sys.path.append(self.tempdir) | 147 import buildtools.packagerChrome as packager |
148 build = __import__('build') | 148 publicKey = packager.getPublicKey(self.config.keyFile) |
149 publicKey = build.getPublicKey(self.config.keyFile) | |
150 hash = hashlib.sha256() | 149 hash = hashlib.sha256() |
151 hash.update(publicKey) | 150 hash.update(publicKey) |
152 self.extensionID = hash.hexdigest()[0:32] | 151 self.extensionID = hash.hexdigest()[0:32] |
153 self.extensionID = ''.join(map(lambda c: chr(97 + int(c, 16)), self.extensio
nID)) | 152 self.extensionID = ''.join(map(lambda c: chr(97 + int(c, 16)), self.extensio
nID)) |
154 | 153 |
155 # Now read manifest.json | 154 # Now read manifest.json |
156 manifestFile = open(os.path.join(self.tempdir, 'manifest.json'), 'rb') | 155 manifestFile = open(os.path.join(self.tempdir, 'manifest.json'), 'rb') |
157 manifest = json.load(manifestFile) | 156 manifest = json.load(manifestFile) |
158 manifestFile.close() | 157 manifestFile.close() |
159 | 158 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 buildCommand += map(pipes.quote, ['/home/android/bin/makedebugbuild.py', '
--revision', self.revision, '--version', self.version, '--stdout']) | 209 buildCommand += map(pipes.quote, ['/home/android/bin/makedebugbuild.py', '
--revision', self.revision, '--version', self.version, '--stdout']) |
211 process = subprocess.Popen(buildCommand, stdout=apkFile, stderr=None) | 210 process = subprocess.Popen(buildCommand, stdout=apkFile, stderr=None) |
212 status = process.wait() | 211 status = process.wait() |
213 apkFile.close() | 212 apkFile.close() |
214 if status: | 213 if status: |
215 # clear broken output if any | 214 # clear broken output if any |
216 # exception will be raised later | 215 # exception will be raised later |
217 if os.path.exists(outputPath): | 216 if os.path.exists(outputPath): |
218 os.remove(outputPath) | 217 os.remove(outputPath) |
219 elif self.config.type == 'chrome': | 218 elif self.config.type == 'chrome': |
220 buildCommand = ['python', os.path.join(self.tempdir, 'build.py'), '-k', se
lf.config.keyFile, '-b', self.revision, outputPath] | 219 import buildtools.packagerChrome as packager |
221 if self.config.experimental: | 220 packager.createBuild(self.tempdir, outFile=outputPath, buildNum=self.revis
ion, keyFile=self.config.keyFile, experimentalAPI=self.config.experimental) |
222 buildCommand[-1:0] = ['--experimental'] | |
223 subprocess.Popen(buildCommand, stdout=subprocess.PIPE).communicate() | |
224 else: | 221 else: |
| 222 import buildtools.packagerGecko as packager |
225 packager.createBuild(self.tempdir, outFile=outputPath, buildNum=self.revis
ion, keyFile=self.config.keyFile) | 223 packager.createBuild(self.tempdir, outFile=outputPath, buildNum=self.revis
ion, keyFile=self.config.keyFile) |
226 | 224 |
227 if not os.path.exists(outputPath): | 225 if not os.path.exists(outputPath): |
228 raise Exception("Build failed, output file hasn't been created") | 226 raise Exception("Build failed, output file hasn't been created") |
229 | 227 |
230 linkPath = os.path.join(baseDir, '00latest%s' % self.config.packageSuffix) | 228 linkPath = os.path.join(baseDir, '00latest%s' % self.config.packageSuffix) |
231 if hasattr(os, 'symlink'): | 229 if hasattr(os, 'symlink'): |
232 if os.path.exists(linkPath): | 230 if os.path.exists(linkPath): |
233 os.remove(linkPath) | 231 os.remove(linkPath) |
234 os.symlink(outputPath, linkPath) | 232 os.symlink(outputPath, linkPath) |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 except Exception, ex: | 367 except Exception, ex: |
370 print >>sys.stderr, "The build for %s failed:" % repo | 368 print >>sys.stderr, "The build for %s failed:" % repo |
371 traceback.print_exc() | 369 traceback.print_exc() |
372 | 370 |
373 file = open(nightlyConfigFile, 'wb') | 371 file = open(nightlyConfigFile, 'wb') |
374 nightlyConfig.write(file) | 372 nightlyConfig.write(file) |
375 | 373 |
376 | 374 |
377 if __name__ == '__main__': | 375 if __name__ == '__main__': |
378 main() | 376 main() |
OLD | NEW |