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

Side by Side Diff: sitescripts/extensions/bin/createNightlies.py

Issue 6103027194789888: Integrated ABP for Safari into the nightly builds (Closed)
Patch Set: Created Nov. 12, 2013, 6:43 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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,
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 metadata = packager.readMetadata(self.tempdir, self.config.type) 167 metadata = packager.readMetadata(self.tempdir, self.config.type)
168 self.version = packager.getBuildVersion(self.tempdir, metadata, False, self. revision) 168 self.version = packager.getBuildVersion(self.tempdir, metadata, False, self. revision)
169 self.basename = metadata.get("general", "basename") 169 self.basename = metadata.get("general", "basename")
170 if self.config.experimental: 170 if self.config.experimental:
171 self.basename += '-experimental' 171 self.basename += '-experimental'
172 172
173 self.compat = [] 173 self.compat = []
174 if metadata.has_section('compat') and metadata.has_option('compat', 'chrome' ): 174 if metadata.has_section('compat') and metadata.has_option('compat', 'chrome' ):
175 self.compat.append({'id': 'chrome', 'minVersion': metadata.get('compat', ' chrome')}) 175 self.compat.append({'id': 'chrome', 'minVersion': metadata.get('compat', ' chrome')})
176 176
177 def readSafariMetadata(self):
178 # get the certificate ID from the developer certificate's common name
179 import M2Crypto
180 bio = M2Crypto.BIO.openfile(self.config.keyFile)
181 try:
182 while not hasattr(self, 'certificateID'):
183 try:
184 cert = M2Crypto.X509.load_cert_bio(bio)
185 except M2Crypto.X509.X509Error:
186 raise Exception('No safari developer certificate found in chain')
187
188 subject = cert.get_subject()
189 for entry in subject.get_entries_by_nid(subject.nid['CN']):
190 m = re.match(r'Safari Developer: \((.*?)\)', entry.get_data().as_text( ))
Wladimir Palant 2013/11/13 11:53:24 Wow, this sucks.
Sebastian Noack 2013/11/13 11:55:55 Agreed. Do you have a better idea?
Wladimir Palant 2013/11/13 13:21:13 No, I don't - other than putting "this sucks, blam
191 if m:
192 self.certificateID = m.group(1)
193 break
194 finally:
195 bio.close()
196
197 # read metadata file
198 import buildtools.packagerSafari as packager
199 metadata = packager.readMetadata(self.tempdir, self.config.type)
200 self.version = packager.getBuildVersion(self.tempdir, metadata, False, self. revision)
201 self.shortVersion = metadata.get("general", "version")
202 self.basename = metadata.get("general", "basename")
203
177 def writeUpdateManifest(self): 204 def writeUpdateManifest(self):
178 """ 205 """
179 Writes update.rdf file for the current build 206 Writes update.rdf file for the current build
180 """ 207 """
181 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) 208 baseDir = os.path.join(self.config.nightliesDirectory, self.basename)
182 if not os.path.exists(baseDir): 209 if not os.path.exists(baseDir):
183 os.makedirs(baseDir) 210 os.makedirs(baseDir)
184 if self.config.type == 'chrome' or self.config.type == 'opera': 211 if self.config.type == 'chrome' or self.config.type == 'opera':
185 manifestPath = os.path.join(baseDir, "updates.xml") 212 manifestPath = os.path.join(baseDir, "updates.xml")
186 templateName = 'chromeUpdateManifest' 213 templateName = 'chromeUpdateManifest'
214 elif self.config.type == 'safari':
215 manifestPath = os.path.join(baseDir, "updates.plist")
216 templateName = 'safariUpdateManifest'
187 elif self.config.type == 'android': 217 elif self.config.type == 'android':
188 manifestPath = os.path.join(baseDir, "updates.xml") 218 manifestPath = os.path.join(baseDir, "updates.xml")
189 templateName = 'androidUpdateManifest' 219 templateName = 'androidUpdateManifest'
190 else: 220 else:
191 manifestPath = os.path.join(baseDir, "update.rdf") 221 manifestPath = os.path.join(baseDir, "update.rdf")
192 templateName = 'geckoUpdateManifest' 222 templateName = 'geckoUpdateManifest'
193 223
194 template = get_template(get_config().get('extensions', templateName)) 224 template = get_template(get_config().get('extensions', templateName))
195 template.stream({'extensions': [self]}).dump(manifestPath) 225 template.stream({'extensions': [self]}).dump(manifestPath)
196 226
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 buildCommand += map(pipes.quote, ['/home/android/bin/makedebugbuild.py', '--revision', self.revision, '--version', self.version, '--stdout']) 301 buildCommand += map(pipes.quote, ['/home/android/bin/makedebugbuild.py', '--revision', self.revision, '--version', self.version, '--stdout'])
272 subprocess.check_call(buildCommand, stdout=apkFile, close_fds=True) 302 subprocess.check_call(buildCommand, stdout=apkFile, close_fds=True)
273 except: 303 except:
274 # clear broken output if any 304 # clear broken output if any
275 if os.path.exists(outputPath): 305 if os.path.exists(outputPath):
276 os.remove(outputPath) 306 os.remove(outputPath)
277 raise 307 raise
278 elif self.config.type == 'chrome' or self.config.type == 'opera': 308 elif self.config.type == 'chrome' or self.config.type == 'opera':
279 import buildtools.packagerChrome as packager 309 import buildtools.packagerChrome as packager
280 packager.createBuild(self.tempdir, type=self.config.type, outFile=outputPa th, buildNum=self.revision, keyFile=self.config.keyFile, experimentalAPI=self.co nfig.experimental) 310 packager.createBuild(self.tempdir, type=self.config.type, outFile=outputPa th, buildNum=self.revision, keyFile=self.config.keyFile, experimentalAPI=self.co nfig.experimental)
311 elif self.config.type == 'safari':
312 import buildtools.packagerSafari as packager
313 packager.createBuild(self.tempdir, type=self.config.type, outFile=outputPa th, buildNum=self.revision, keyFile=self.config.keyFile)
281 else: 314 else:
282 import buildtools.packagerGecko as packager 315 import buildtools.packagerGecko as packager
283 packager.createBuild(self.tempdir, outFile=outputPath, buildNum=self.revis ion, keyFile=self.config.keyFile) 316 packager.createBuild(self.tempdir, outFile=outputPath, buildNum=self.revis ion, keyFile=self.config.keyFile)
284 317
285 if not os.path.exists(outputPath): 318 if not os.path.exists(outputPath):
286 raise Exception("Build failed, output file hasn't been created") 319 raise Exception("Build failed, output file hasn't been created")
287 320
288 linkPath = os.path.join(baseDir, '00latest%s' % self.config.packageSuffix) 321 linkPath = os.path.join(baseDir, '00latest%s' % self.config.packageSuffix)
289 if hasattr(os, 'symlink'): 322 if hasattr(os, 'symlink'):
290 if os.path.exists(linkPath): 323 if os.path.exists(linkPath):
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 self.basename = os.path.basename(self.config.repository) 403 self.basename = os.path.basename(self.config.repository)
371 else: 404 else:
372 # copy the repository into a temporary directory 405 # copy the repository into a temporary directory
373 self.copyRepository() 406 self.copyRepository()
374 407
375 # get meta data from the repository 408 # get meta data from the repository
376 if self.config.type == 'android': 409 if self.config.type == 'android':
377 self.readAndroidMetadata() 410 self.readAndroidMetadata()
378 elif self.config.type == 'chrome' or self.config.type == 'opera': 411 elif self.config.type == 'chrome' or self.config.type == 'opera':
379 self.readChromeMetadata() 412 self.readChromeMetadata()
413 elif self.config.type == 'safari':
414 self.readSafariMetadata()
380 else: 415 else:
381 self.readMetadata() 416 self.readMetadata()
382 417
383 # create development build 418 # create development build
384 self.build() 419 self.build()
385 420
386 # write out changelog 421 # write out changelog
387 self.writeChangelog(self.getChanges()) 422 self.writeChangelog(self.getChanges())
388 423
389 # write update.rdf file 424 # write update.rdf file
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 except Exception, ex: 467 except Exception, ex:
433 print >>sys.stderr, "The build for %s failed:" % repo 468 print >>sys.stderr, "The build for %s failed:" % repo
434 traceback.print_exc() 469 traceback.print_exc()
435 470
436 file = open(nightlyConfigFile, 'wb') 471 file = open(nightlyConfigFile, 'wb')
437 nightlyConfig.write(file) 472 nightlyConfig.write(file)
438 473
439 474
440 if __name__ == '__main__': 475 if __name__ == '__main__':
441 main() 476 main()
OLDNEW

Powered by Google App Engine
This is Rietveld