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

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

Issue 6270530592178176: Issue 1144 - Generate IE update manifests (Closed)
Patch Set: Created July 25, 2014, 1:06 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-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 compareVersions, Configuration, getSafa riCertificateID
35 35
36 MAX_BUILDS = 50 36 MAX_BUILDS = 50
37 37
38 38
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 os.makedirs(baseDir) 193 os.makedirs(baseDir)
194 if self.config.type == 'chrome' or self.config.type == 'opera': 194 if self.config.type == 'chrome' or self.config.type == 'opera':
195 manifestPath = os.path.join(baseDir, "updates.xml") 195 manifestPath = os.path.join(baseDir, "updates.xml")
196 templateName = 'chromeUpdateManifest' 196 templateName = 'chromeUpdateManifest'
197 elif self.config.type == 'safari': 197 elif self.config.type == 'safari':
198 manifestPath = os.path.join(baseDir, "updates.plist") 198 manifestPath = os.path.join(baseDir, "updates.plist")
199 templateName = 'safariUpdateManifest' 199 templateName = 'safariUpdateManifest'
200 elif self.config.type == 'android': 200 elif self.config.type == 'android':
201 manifestPath = os.path.join(baseDir, "updates.xml") 201 manifestPath = os.path.join(baseDir, "updates.xml")
202 templateName = 'androidUpdateManifest' 202 templateName = 'androidUpdateManifest'
203 elif self.config.type == 'ie':
204 manifestPath = os.path.join(baseDir, "update.json")
205 templateName = 'ieUpdateManifest'
Wladimir Palant 2014/07/29 11:25:18 libabpUpdateManifest please, this format isn't spe
Felix Dahlke 2014/07/29 11:37:17 As it is, the update manifest is IE specific, we w
203 else: 206 else:
204 manifestPath = os.path.join(baseDir, "update.rdf") 207 manifestPath = os.path.join(baseDir, "update.rdf")
205 templateName = 'geckoUpdateManifest' 208 templateName = 'geckoUpdateManifest'
206 209
207 template = get_template(get_config().get('extensions', templateName)) 210 template = get_template(get_config().get('extensions', templateName))
208 template.stream({'extensions': [self]}).dump(manifestPath) 211 template.stream({'extensions': [self]}).dump(manifestPath)
209 212
210 def writeLibabpUpdateManifest(self, updates):
Wladimir Palant 2014/07/29 11:25:18 Why did you remove this function? Are you going to
Felix Dahlke 2014/07/29 11:37:17 Do we need special logic for Android here? How I s
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): 213 def writeIEUpdateManifest(self, versions):
224 """ 214 """
225 Writes update.json file for the latest IE build 215 Writes update.json file for the latest IE build
226 """ 216 """
227 if len(versions) == 0: 217 if len(versions) == 0:
228 return 218 return
229 219
230 version = versions[0] 220 baseDir = os.path.join(self.config.nightliesDirectory, self.basename)
231 packageName = self.basename + '-' + versions[0] + self.config.packageSuffix 221 if not os.path.exists(baseDir):
232 updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename + '/' + packageName + '?update') 222 os.makedirs(baseDir)
233 self.writeLibabpUpdateManifest({
234 "%s/%s" % (self.basename, "msie64"): {
235 "url": updateURL.replace(".exe", "-x64.msi"),
236 "version": version,
237 },
238 "%s/%s" % (self.basename, "msie32"): {
239 "url": updateURL.replace(".exe", "-x86.msi"),
240 "version": version,
241 },
242 })
243 223
244 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) 224 self.version = versions[0]
Wladimir Palant 2014/07/29 11:25:18 This function shouldn't set any instance variables
Felix Dahlke 2014/07/29 11:37:17 True, it's a hack. How about I move this part to w
Wladimir Palant 2014/07/29 12:03:10 Yes, that would make sense.
225 packageName = self.basename + '-' + self.version + self.config.packageSuffix
226 self.updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename +
227 '/' + packageName + '?update')
228 self.name = self.basename
229 self.writeUpdateManifest()
230
245 for suffix in (self.config.packageSuffix, self.config.packageSuffix.replace( "-x64", "-x86")): 231 for suffix in (self.config.packageSuffix, self.config.packageSuffix.replace( "-x64", "-x86")):
246 linkPath = os.path.join(baseDir, '00latest%s' % suffix) 232 linkPath = os.path.join(baseDir, '00latest%s' % suffix)
247 outputPath = os.path.join(baseDir, self.basename + '-' + versions[0] + suf fix) 233 outputPath = os.path.join(baseDir, self.basename + '-' + self.version + su ffix)
248 if hasattr(os, 'symlink'): 234 if hasattr(os, 'symlink'):
249 if os.path.exists(linkPath): 235 if os.path.exists(linkPath):
250 os.remove(linkPath) 236 os.remove(linkPath)
251 os.symlink(os.path.basename(outputPath), linkPath) 237 os.symlink(os.path.basename(outputPath), linkPath)
252 else: 238 else:
253 shutil.copyfile(outputPath, linkPath) 239 shutil.copyfile(outputPath, linkPath)
254 240
255
256 def build(self): 241 def build(self):
257 """ 242 """
258 run the build command in the tempdir 243 run the build command in the tempdir
259 """ 244 """
260 baseDir = os.path.join(self.config.nightliesDirectory, self.basename) 245 baseDir = os.path.join(self.config.nightliesDirectory, self.basename)
261 if not os.path.exists(baseDir): 246 if not os.path.exists(baseDir):
262 os.makedirs(baseDir) 247 os.makedirs(baseDir)
263 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)
264 self.path = os.path.join(baseDir, outputFile) 249 self.path = os.path.join(baseDir, outputFile)
265 self.updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename + '/' + outputFile + '?update') 250 self.updateURL = urlparse.urljoin(self.config.nightliesURL, self.basename + '/' + outputFile + '?update')
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 except Exception, ex: 493 except Exception, ex:
509 print >>sys.stderr, "The build for %s failed:" % repo 494 print >>sys.stderr, "The build for %s failed:" % repo
510 traceback.print_exc() 495 traceback.print_exc()
511 496
512 file = open(nightlyConfigFile, 'wb') 497 file = open(nightlyConfigFile, 'wb')
513 nightlyConfig.write(file) 498 nightlyConfig.write(file)
514 499
515 500
516 if __name__ == '__main__': 501 if __name__ == '__main__':
517 main() 502 main()
OLDNEW
« no previous file with comments | « no previous file | sitescripts/extensions/bin/updateUpdateManifests.py » ('j') | sitescripts/extensions/template/ie-update.json » ('J')

Powered by Google App Engine
This is Rietveld