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

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

Issue 6282067956465664: Issue 399 - Added support for Safari to updateDownloadLinks (Closed)
Patch Set: Addressed comments Created April 30, 2014, 12:21 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
« no previous file with comments | « .sitescripts.example ('k') | sitescripts/extensions/bin/updateDownloadLinks.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-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, codecs, subprocess, ConfigParser, traceback, json, hash lib
29 import tempfile, re, 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 34 from sitescripts.extensions.utils import compareVersions, Configuration, getSafa riCertificateID
35 35
36 MAX_BUILDS = 50 36 MAX_BUILDS = 50
37 37
38 38
39 class NightlyBuild(object): 39 class NightlyBuild(object):
40 """ 40 """
41 Performs the build process for an extension, 41 Performs the build process for an extension,
42 generating changelogs and documentation. 42 generating changelogs and documentation.
43 """ 43 """
44 44
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 self.version = packager.getBuildVersion(self.tempdir, metadata, False, self. revision) 169 self.version = packager.getBuildVersion(self.tempdir, metadata, False, self. revision)
170 self.basename = metadata.get("general", "basename") 170 self.basename = metadata.get("general", "basename")
171 if self.config.experimental: 171 if self.config.experimental:
172 self.basename += '-experimental' 172 self.basename += '-experimental'
173 173
174 self.compat = [] 174 self.compat = []
175 if metadata.has_section('compat') and metadata.has_option('compat', 'chrome' ): 175 if metadata.has_section('compat') and metadata.has_option('compat', 'chrome' ):
176 self.compat.append({'id': 'chrome', 'minVersion': metadata.get('compat', ' chrome')}) 176 self.compat.append({'id': 'chrome', 'minVersion': metadata.get('compat', ' chrome')})
177 177
178 def readSafariMetadata(self): 178 def readSafariMetadata(self):
179 # get the certificate ID from the developer certificate's common name
180 import M2Crypto
181 bio = M2Crypto.BIO.openfile(self.config.keyFile)
182 try:
183 while not hasattr(self, 'certificateID'):
184 try:
185 cert = M2Crypto.X509.load_cert_bio(bio)
186 except M2Crypto.X509.X509Error:
187 raise Exception('No safari developer certificate found in chain')
188
189 subject = cert.get_subject()
190 for entry in subject.get_entries_by_nid(subject.nid['CN']):
191 m = re.match(r'Safari Developer: \((.*?)\)', entry.get_data().as_text( ))
192 if m:
193 self.certificateID = m.group(1)
194 break
195 finally:
196 bio.close()
197
198 # read metadata file
199 import buildtools.packagerSafari as packager 179 import buildtools.packagerSafari as packager
200 metadata = packager.readMetadata(self.tempdir, self.config.type) 180 metadata = packager.readMetadata(self.tempdir, self.config.type)
181
182 self.certificateID = getSafariCertificateID(self.config.keyFile)
201 self.version = packager.getBuildVersion(self.tempdir, metadata, False, self. revision) 183 self.version = packager.getBuildVersion(self.tempdir, metadata, False, self. revision)
202 self.shortVersion = metadata.get("general", "version") 184 self.shortVersion = metadata.get("general", "version")
203 self.basename = metadata.get("general", "basename") 185 self.basename = metadata.get("general", "basename")
204 186
205 def writeUpdateManifest(self): 187 def writeUpdateManifest(self):
206 """ 188 """
207 Writes update.rdf file for the current build 189 Writes update.rdf file for the current build
208 """ 190 """
209 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) 191 baseDir = os.path.join(self.config.nightliesDirectory, self.basename)
210 if not os.path.exists(baseDir): 192 if not os.path.exists(baseDir):
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 except Exception, ex: 491 except Exception, ex:
510 print >>sys.stderr, "The build for %s failed:" % repo 492 print >>sys.stderr, "The build for %s failed:" % repo
511 traceback.print_exc() 493 traceback.print_exc()
512 494
513 file = open(nightlyConfigFile, 'wb') 495 file = open(nightlyConfigFile, 'wb')
514 nightlyConfig.write(file) 496 nightlyConfig.write(file)
515 497
516 498
517 if __name__ == '__main__': 499 if __name__ == '__main__':
518 main() 500 main()
OLDNEW
« no previous file with comments | « .sitescripts.example ('k') | sitescripts/extensions/bin/updateDownloadLinks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld