| OLD | NEW |
| 1 # This Source Code Form is subject to the terms of the Mozilla Public | 1 # This Source Code Form is subject to the terms of the Mozilla Public |
| 2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 import sys | 6 import sys |
| 7 import re | 7 import re |
| 8 import hashlib | 8 import hashlib |
| 9 import base64 | 9 import base64 |
| 10 import urllib | 10 import urllib |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 result = {} | 48 result = {} |
| 49 chromeDir = getChromeDir(baseDir) | 49 chromeDir = getChromeDir(baseDir) |
| 50 for subdir in ('content', 'skin'): | 50 for subdir in ('content', 'skin'): |
| 51 result[subdir] = os.path.join(chromeDir, subdir) | 51 result[subdir] = os.path.join(chromeDir, subdir) |
| 52 for locale in locales: | 52 for locale in locales: |
| 53 result['locale/%s' % locale] = os.path.join(chromeDir, 'locale', locale) | 53 result['locale/%s' % locale] = os.path.join(chromeDir, 'locale', locale) |
| 54 return result | 54 return result |
| 55 | 55 |
| 56 | 56 |
| 57 def getPackageFiles(params): | 57 def getPackageFiles(params): |
| 58 result = set(('chrome', 'components', 'modules', 'lib', 'resources', 'chrome
.manifest', 'icon.png', 'icon64.png',)) | 58 result = { |
| 59 'chrome', 'components', 'modules', 'lib', 'resources', 'webextension', |
| 60 'chrome.manifest', 'icon.png', 'icon64.png' |
| 61 } |
| 59 | 62 |
| 60 baseDir = params['baseDir'] | 63 baseDir = params['baseDir'] |
| 61 for file in os.listdir(baseDir): | 64 for file in os.listdir(baseDir): |
| 62 if file.endswith('.js') or file.endswith('.xml'): | 65 if file.endswith('.js') or file.endswith('.xml'): |
| 63 result.add(file) | 66 result.add(file) |
| 64 return result | 67 return result |
| 65 | 68 |
| 66 | 69 |
| 67 def getIgnoredFiles(params): | 70 def getIgnoredFiles(params): |
| 68 return {'.incomplete', 'meta.properties'} | 71 return {'.incomplete', 'meta.properties'} |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 237 |
| 235 def addMissingFiles(params, files): | 238 def addMissingFiles(params, files): |
| 236 templateData = { | 239 templateData = { |
| 237 'hasChrome': False, | 240 'hasChrome': False, |
| 238 'hasChromeRequires': False, | 241 'hasChromeRequires': False, |
| 239 'hasShutdownHandlers': False, | 242 'hasShutdownHandlers': False, |
| 240 'chromeWindows': [], | 243 'chromeWindows': [], |
| 241 'requires': set(), | 244 'requires': set(), |
| 242 'jsonRequires': params['jsonRequires'], | 245 'jsonRequires': params['jsonRequires'], |
| 243 'metadata': params['metadata'], | 246 'metadata': params['metadata'], |
| 247 'hasWebExtension': params['hasWebExtension'], |
| 244 'multicompartment': params['multicompartment'], | 248 'multicompartment': params['multicompartment'], |
| 245 'applications': dict((v, k) for k, v in KNOWN_APPS.iteritems()), | 249 'applications': dict((v, k) for k, v in KNOWN_APPS.iteritems()), |
| 246 } | 250 } |
| 247 | 251 |
| 248 def checkScript(name): | 252 def checkScript(name): |
| 249 content = files[name] | 253 content = files[name] |
| 250 for match in re.finditer(r'(?:^|\s)require\(\s*"([\w\-]+)"\s*\)', conten
t): | 254 for match in re.finditer(r'(?:^|\s)require\(\s*"([\w\-]+)"\s*\)', conten
t): |
| 251 templateData['requires'].add(match.group(1)) | 255 templateData['requires'].add(match.group(1)) |
| 252 if name.startswith('chrome/content/'): | 256 if name.startswith('chrome/content/'): |
| 253 templateData['hasChromeRequires'] = True | 257 templateData['hasChromeRequires'] = True |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 contributors = getContributors(metadata) | 303 contributors = getContributors(metadata) |
| 300 | 304 |
| 301 params = { | 305 params = { |
| 302 'baseDir': baseDir, | 306 'baseDir': baseDir, |
| 303 'locales': locales, | 307 'locales': locales, |
| 304 'releaseBuild': releaseBuild, | 308 'releaseBuild': releaseBuild, |
| 305 'version': version.encode('utf-8'), | 309 'version': version.encode('utf-8'), |
| 306 'metadata': metadata, | 310 'metadata': metadata, |
| 307 'contributors': contributors, | 311 'contributors': contributors, |
| 308 'multicompartment': multicompartment, | 312 'multicompartment': multicompartment, |
| 313 'hasWebExtension': os.path.isdir(os.path.join(baseDir, 'webextension')), |
| 309 'jsonRequires': {}, | 314 'jsonRequires': {}, |
| 310 } | 315 } |
| 311 | 316 |
| 312 mapped = metadata.items('mapping') if metadata.has_section('mapping') else [
] | 317 mapped = metadata.items('mapping') if metadata.has_section('mapping') else [
] |
| 313 skip = [opt for opt, _ in mapped] + ['chrome'] | 318 skip = [opt for opt, _ in mapped] + ['chrome'] |
| 314 files = Files(getPackageFiles(params), getIgnoredFiles(params), | 319 files = Files(getPackageFiles(params), getIgnoredFiles(params), |
| 315 process=lambda path, data: processFile(path, data, params)) | 320 process=lambda path, data: processFile(path, data, params)) |
| 316 files['install.rdf'] = createManifest(params) | 321 files['install.rdf'] = createManifest(params) |
| 317 files.readMappedFiles(mapped) | 322 files.readMappedFiles(mapped) |
| 318 files.read(baseDir, skip=skip) | 323 files.read(baseDir, skip=skip) |
| 319 for name, path in getChromeSubdirs(baseDir, params['locales']).iteritems(): | 324 for name, path in getChromeSubdirs(baseDir, params['locales']).iteritems(): |
| 320 if os.path.isdir(path): | 325 if os.path.isdir(path): |
| 321 files.read(path, 'chrome/%s' % name, skip=skip) | 326 files.read(path, 'chrome/%s' % name, skip=skip) |
| 322 importLocales(params, files) | 327 importLocales(params, files) |
| 323 fixupLocales(params, files) | 328 fixupLocales(params, files) |
| 324 processJSONFiles(params, files) | 329 processJSONFiles(params, files) |
| 325 if not 'bootstrap.js' in files: | 330 if not 'bootstrap.js' in files: |
| 326 addMissingFiles(params, files) | 331 addMissingFiles(params, files) |
| 327 if metadata.has_section('preprocess'): | 332 if metadata.has_section('preprocess'): |
| 328 files.preprocess([f for f, _ in metadata.items('preprocess')]) | 333 files.preprocess([f for f, _ in metadata.items('preprocess')]) |
| 329 files.zip(outFile, sortKey=lambda x: '!' if x == 'META-INF/zigbert.rsa' else
x) | 334 files.zip(outFile, sortKey=lambda x: '!' if x == 'META-INF/zigbert.rsa' else
x) |
| 330 | 335 |
| 331 | 336 |
| 332 def autoInstall(baseDir, type, host, port, multicompartment=False): | 337 def autoInstall(baseDir, type, host, port, multicompartment=False): |
| 333 fileBuffer = StringIO() | 338 fileBuffer = StringIO() |
| 334 createBuild(baseDir, type=type, outFile=fileBuffer, multicompartment=multico
mpartment) | 339 createBuild(baseDir, type=type, outFile=fileBuffer, multicompartment=multico
mpartment) |
| 335 urllib.urlopen('http://%s:%s/' % (host, port), data=fileBuffer.getvalue()) | 340 urllib.urlopen('http://%s:%s/' % (host, port), data=fileBuffer.getvalue()) |
| OLD | NEW |