| 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 errno | 5 import errno |
| 6 import glob | 6 import glob |
| 7 import io | 7 import io |
| 8 import json | 8 import json |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 # ... = icon-16.png icon-32.png icon-48.png | 98 # ... = icon-16.png icon-32.png icon-48.png |
| 99 icon = makeIcons(files, icons) | 99 icon = makeIcons(files, icons) |
| 100 popup = None | 100 popup = None |
| 101 | 101 |
| 102 templateData[opt] = {'icon': icon, 'popup': popup} | 102 templateData[opt] = {'icon': icon, 'popup': popup} |
| 103 | 103 |
| 104 if metadata.has_option('general', 'icons'): | 104 if metadata.has_option('general', 'icons'): |
| 105 templateData['icons'] = makeIcons(files, | 105 templateData['icons'] = makeIcons(files, |
| 106 metadata.get('general', 'icons').split
()) | 106 metadata.get('general', 'icons').split
()) |
| 107 | 107 |
| 108 if metadata.has_option('general', 'permissions'): | |
| 109 templateData['permissions'] = metadata.get('general', 'permissions').spl
it() | |
| 110 | |
| 111 if metadata.has_option('general', 'optionalPermissions'): | |
| 112 templateData['optionalPermissions'] = metadata.get( | |
| 113 'general', 'optionalPermissions').split() | |
| 114 | |
| 115 if metadata.has_option('general', 'backgroundScripts'): | 108 if metadata.has_option('general', 'backgroundScripts'): |
| 116 templateData['backgroundScripts'] = metadata.get( | 109 templateData['backgroundScripts'] = metadata.get( |
| 117 'general', 'backgroundScripts').split() | 110 'general', 'backgroundScripts').split() |
| 118 if params['devenv']: | 111 if params['devenv']: |
| 119 templateData['backgroundScripts'].append('devenvPoller__.js') | 112 templateData['backgroundScripts'].append('devenvPoller__.js') |
| 120 | 113 |
| 121 if metadata.has_option('general', 'webAccessible') and metadata.get('general
', 'webAccessible') != '': | |
| 122 templateData['webAccessible'] = metadata.get('general', | |
| 123 'webAccessible').split() | |
| 124 | |
| 125 if metadata.has_section('contentScripts'): | 114 if metadata.has_section('contentScripts'): |
| 126 contentScripts = [] | 115 contentScripts = [] |
| 127 for run_at, scripts in metadata.items('contentScripts'): | 116 for run_at, scripts in metadata.items('contentScripts'): |
| 128 if scripts == '': | 117 if scripts == '': |
| 129 continue | 118 continue |
| 130 contentScripts.append({ | 119 contentScripts.append({ |
| 131 'matches': ['http://*/*', 'https://*/*'], | 120 'matches': ['http://*/*', 'https://*/*'], |
| 132 'js': scripts.split(), | 121 'js': scripts.split(), |
| 133 'run_at': run_at, | 122 'run_at': run_at, |
| 134 'all_frames': True, | 123 'all_frames': True, |
| 135 'match_about_blank': True, | 124 'match_about_blank': True, |
| 136 }) | 125 }) |
| 137 templateData['contentScripts'] = contentScripts | 126 templateData['contentScripts'] = contentScripts |
| 138 if params['type'] == 'gecko': | 127 if params['type'] == 'gecko': |
| 139 templateData['app_id'] = get_app_id(params['releaseBuild'], metadata) | 128 templateData['app_id'] = get_app_id(params['releaseBuild'], metadata) |
| 140 | 129 |
| 141 manifest = template.render(templateData) | 130 manifest = template.render(templateData) |
| 142 | 131 |
| 143 # Normalize JSON structure | 132 # Normalize JSON structure |
| 144 licenseComment = re.compile(r'/\*.*?\*/', re.S) | 133 licenseComment = re.compile(r'/\*.*?\*/', re.S) |
| 145 data = json.loads(re.sub(licenseComment, '', manifest, 1)) | 134 data = json.loads(re.sub(licenseComment, '', manifest, 1)) |
| 146 if '_dummy' in data: | 135 if '_dummy' in data: |
| 147 del data['_dummy'] | 136 del data['_dummy'] |
| 148 manifest = json.dumps(data, sort_keys=True, indent=2) | 137 manifest = json.dumps(metadata.section_as_dict('manifest', data), |
| 138 sort_keys=True, indent=2) |
| 149 | 139 |
| 150 return manifest.encode('utf-8') | 140 return manifest.encode('utf-8') |
| 151 | 141 |
| 152 | 142 |
| 153 def toJson(data): | 143 def toJson(data): |
| 154 return json.dumps( | 144 return json.dumps( |
| 155 data, ensure_ascii=False, sort_keys=True, | 145 data, ensure_ascii=False, sort_keys=True, |
| 156 indent=2, separators=(',', ': ') | 146 indent=2, separators=(',', ': ') |
| 157 ).encode('utf-8') + '\n' | 147 ).encode('utf-8') + '\n' |
| 158 | 148 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 if devenv: | 386 if devenv: |
| 397 add_devenv_requirements(files, metadata, params) | 387 add_devenv_requirements(files, metadata, params) |
| 398 | 388 |
| 399 zipdata = files.zipToString() | 389 zipdata = files.zipToString() |
| 400 signature = None | 390 signature = None |
| 401 pubkey = None | 391 pubkey = None |
| 402 if keyFile != None: | 392 if keyFile != None: |
| 403 signature = signBinary(zipdata, keyFile) | 393 signature = signBinary(zipdata, keyFile) |
| 404 pubkey = getPublicKey(keyFile) | 394 pubkey = getPublicKey(keyFile) |
| 405 writePackage(outFile, pubkey, signature, zipdata) | 395 writePackage(outFile, pubkey, signature, zipdata) |
| OLD | NEW |