| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 | 2 |
| 3 # This Source Code Form is subject to the terms of the Mozilla Public | 3 # This Source Code Form is subject to the terms of the Mozilla Public |
| 4 # License, v. 2.0. If a copy of the MPL was not distributed with this | 4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 import re | 9 import re |
| 10 import hashlib | 10 import hashlib |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 } | 224 } |
| 225 | 225 |
| 226 def checkScript(name): | 226 def checkScript(name): |
| 227 content = files[name] | 227 content = files[name] |
| 228 for match in re.finditer(r'(?:^|\s)require\(\s*"([\w\-]+)"\s*\)', content): | 228 for match in re.finditer(r'(?:^|\s)require\(\s*"([\w\-]+)"\s*\)', content): |
| 229 templateData['requires'][match.group(1)] = True | 229 templateData['requires'][match.group(1)] = True |
| 230 if name.startswith('chrome/content/'): | 230 if name.startswith('chrome/content/'): |
| 231 templateData['hasChromeRequires'] = True | 231 templateData['hasChromeRequires'] = True |
| 232 if name.startswith('lib/') and re.search(r'\bXMLHttpRequest\b', content): | 232 if name.startswith('lib/') and re.search(r'\bXMLHttpRequest\b', content): |
| 233 templateData['hasXMLHttpRequest'] = True | 233 templateData['hasXMLHttpRequest'] = True |
| 234 if name == 'defaults/prefs.js': | |
| 235 if re.search(r'\.currentVersion"', content): | |
| 236 templateData['hasVersionPref'] = True | |
| 237 if not '/' in name or name.startswith('lib/'): | 234 if not '/' in name or name.startswith('lib/'): |
| 238 if re.search(r'(?:^|\s)onShutdown\.', content): | 235 if re.search(r'(?:^|\s)onShutdown\.', content): |
| 239 templateData['hasShutdownHandlers'] = True | 236 templateData['hasShutdownHandlers'] = True |
| 240 | 237 |
| 241 for name, content in files.iteritems(): | 238 for name, content in files.iteritems(): |
| 242 if name == 'chrome.manifest': | 239 if name == 'chrome.manifest': |
| 243 templateData['hasChrome'] = True | 240 templateData['hasChrome'] = True |
| 241 elif name == 'defaults/prefs.json': | |
| 242 templateData['hasVersionPref'] = re.search(r'"currentVersion":', content) != None | |
|
Wladimir Palant
2015/05/29 18:40:52
It's JSON data now, we can do better:
templateDat
Felix Dahlke
2015/05/29 20:04:10
Seemed a bit over the top to me considering that w
| |
| 244 elif name.endswith('.js'): | 243 elif name.endswith('.js'): |
| 245 checkScript(name) | 244 checkScript(name) |
| 246 elif name.endswith('.xul'): | 245 elif name.endswith('.xul'): |
| 247 match = re.search(r'<(?:window|dialog)\s[^>]*\bwindowtype="([^">]+)"', con tent) | 246 match = re.search(r'<(?:window|dialog)\s[^>]*\bwindowtype="([^">]+)"', con tent) |
| 248 if match: | 247 if match: |
| 249 templateData['chromeWindows'].append(match.group(1)) | 248 templateData['chromeWindows'].append(match.group(1)) |
| 250 | 249 |
| 251 while True: | 250 while True: |
| 252 missing = [] | 251 missing = [] |
| 253 for module in templateData['requires']: | 252 for module in templateData['requires']: |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 if metadata.has_section('preprocess'): | 354 if metadata.has_section('preprocess'): |
| 356 files.preprocess([f for f, _ in metadata.items('preprocess')]) | 355 files.preprocess([f for f, _ in metadata.items('preprocess')]) |
| 357 if keyFile: | 356 if keyFile: |
| 358 signFiles(files, keyFile) | 357 signFiles(files, keyFile) |
| 359 files.zip(outFile, sortKey=lambda x: '!' if x == 'META-INF/zigbert.rsa' else x ) | 358 files.zip(outFile, sortKey=lambda x: '!' if x == 'META-INF/zigbert.rsa' else x ) |
| 360 | 359 |
| 361 def autoInstall(baseDir, type, host, port, multicompartment=False): | 360 def autoInstall(baseDir, type, host, port, multicompartment=False): |
| 362 fileBuffer = StringIO() | 361 fileBuffer = StringIO() |
| 363 createBuild(baseDir, type=type, outFile=fileBuffer, multicompartment=multicomp artment) | 362 createBuild(baseDir, type=type, outFile=fileBuffer, multicompartment=multicomp artment) |
| 364 urllib.urlopen('http://%s:%s/' % (host, port), data=fileBuffer.getvalue()) | 363 urllib.urlopen('http://%s:%s/' % (host, port), data=fileBuffer.getvalue()) |
| OLD | NEW |