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

Delta Between Two Patch Sets: packagerChrome.py

Issue 29743581: Issue 6552 - Support arbitrary manifest values (Closed) Base URL: https://hg.adblockplus.org/buildtools/file/a3db4a1a49e8
Left Patch Set: Created April 5, 2018, 10:21 a.m.
Right Patch Set: Created April 19, 2018, 11:42 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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
11 import struct 11 import struct
12 import subprocess 12 import subprocess
13 import sys 13 import sys
14 import random 14 import random
15 import posixpath 15 import posixpath
16 import ConfigParser
17 16
18 from packager import (readMetadata, getDefaultFileName, getBuildVersion, 17 from packager import (readMetadata, getDefaultFileName, getBuildVersion,
19 getTemplate, get_extension, Files, get_app_id) 18 getTemplate, get_extension, Files, get_app_id)
20 19
21 defaultLocale = 'en_US' 20 defaultLocale = 'en_US'
22 21
23 22
24 def getIgnoredFiles(params): 23 def getIgnoredFiles(params):
25 return {'store.description'} 24 return {'store.description'}
26 25
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 # ... = icon-16.png icon-32.png icon-48.png 98 # ... = icon-16.png icon-32.png icon-48.png
100 icon = makeIcons(files, icons) 99 icon = makeIcons(files, icons)
101 popup = None 100 popup = None
102 101
103 templateData[opt] = {'icon': icon, 'popup': popup} 102 templateData[opt] = {'icon': icon, 'popup': popup}
104 103
105 if metadata.has_option('general', 'icons'): 104 if metadata.has_option('general', 'icons'):
106 templateData['icons'] = makeIcons(files, 105 templateData['icons'] = makeIcons(files,
107 metadata.get('general', 'icons').split ()) 106 metadata.get('general', 'icons').split ())
108 107
109 if metadata.has_option('general', 'permissions'):
110 templateData['permissions'] = metadata.get('general', 'permissions').spl it()
111
112 if metadata.has_option('general', 'optionalPermissions'):
113 templateData['optionalPermissions'] = metadata.get(
114 'general', 'optionalPermissions').split()
115
116 if metadata.has_option('general', 'backgroundScripts'): 108 if metadata.has_option('general', 'backgroundScripts'):
117 templateData['backgroundScripts'] = metadata.get( 109 templateData['backgroundScripts'] = metadata.get(
118 'general', 'backgroundScripts').split() 110 'general', 'backgroundScripts').split()
119 if params['devenv']: 111 if params['devenv']:
120 templateData['backgroundScripts'].append('devenvPoller__.js') 112 templateData['backgroundScripts'].append('devenvPoller__.js')
121
122 if metadata.has_option('general', 'webAccessible') and metadata.get('general ', 'webAccessible') != '':
123 templateData['webAccessible'] = metadata.get('general',
124 'webAccessible').split()
125
126 for key in ['externallyConnectable_matches', 'externallyConnectable_ids']:
127 try:
128 values = metadata.get('general', key)
129 if values == '':
130 continue
131
132 sub_key = key.split('_', 1)[1]
133 templateData.setdefault('externallyConnectable', {})
134 templateData['externallyConnectable'][sub_key] = values.split()
135 except ConfigParser.NoOptionError:
136 continue
137
138 # We don't need to configure accept_ts_channel_id if nothing can connect
139 if 'externallyConnectable' in templateData.keys():
140 try:
141 key = 'accepts_tls_channel_id'
142 val = metadata.get('general', 'externallyConnectable_' + key)
143 templateData['externallyConnectable'][key] = val == 'true'
144 except ConfigParser.NoOptionError:
145 pass
146 113
147 if metadata.has_section('contentScripts'): 114 if metadata.has_section('contentScripts'):
148 contentScripts = [] 115 contentScripts = []
149 for run_at, scripts in metadata.items('contentScripts'): 116 for run_at, scripts in metadata.items('contentScripts'):
150 if scripts == '': 117 if scripts == '':
151 continue 118 continue
152 contentScripts.append({ 119 contentScripts.append({
153 'matches': ['http://*/*', 'https://*/*'], 120 'matches': ['http://*/*', 'https://*/*'],
154 'js': scripts.split(), 121 'js': scripts.split(),
155 'run_at': run_at, 122 'run_at': run_at,
156 'all_frames': True, 123 'all_frames': True,
157 'match_about_blank': True, 124 'match_about_blank': True,
158 }) 125 })
159 templateData['contentScripts'] = contentScripts 126 templateData['contentScripts'] = contentScripts
160 if params['type'] == 'gecko': 127 if params['type'] == 'gecko':
161 templateData['app_id'] = get_app_id(params['releaseBuild'], metadata) 128 templateData['app_id'] = get_app_id(params['releaseBuild'], metadata)
162 129
163 manifest = template.render(templateData) 130 manifest = template.render(templateData)
164 131
165 # Normalize JSON structure 132 # Normalize JSON structure
166 licenseComment = re.compile(r'/\*.*?\*/', re.S) 133 licenseComment = re.compile(r'/\*.*?\*/', re.S)
167 data = json.loads(re.sub(licenseComment, '', manifest, 1)) 134 data = json.loads(re.sub(licenseComment, '', manifest, 1))
168 if '_dummy' in data: 135 if '_dummy' in data:
169 del data['_dummy'] 136 del data['_dummy']
137
138 metadata.serialize_section_if_present('manifest', data)
170 manifest = json.dumps(data, sort_keys=True, indent=2) 139 manifest = json.dumps(data, sort_keys=True, indent=2)
171 140
172 return manifest.encode('utf-8') 141 return manifest.encode('utf-8')
173 142
174 143
175 def toJson(data): 144 def toJson(data):
176 return json.dumps( 145 return json.dumps(
177 data, ensure_ascii=False, sort_keys=True, 146 data, ensure_ascii=False, sort_keys=True,
178 indent=2, separators=(',', ': ') 147 indent=2, separators=(',', ': ')
179 ).encode('utf-8') + '\n' 148 ).encode('utf-8') + '\n'
(...skipping 10 matching lines...) Expand all
190 # Historically we didn't use relative paths when requiring modules, so in 159 # Historically we didn't use relative paths when requiring modules, so in
191 # order for webpack to know where to find them we need to pass in a list of 160 # order for webpack to know where to find them we need to pass in a list of
192 # resolve paths. Going forward we should always use relative paths, once we 161 # resolve paths. Going forward we should always use relative paths, once we
193 # do that consistently this can be removed. See issues 5760, 5761 and 5762. 162 # do that consistently this can be removed. See issues 5760, 5761 and 5762.
194 resolve_paths = [os.path.join(base_extension_path, dir, 'lib') 163 resolve_paths = [os.path.join(base_extension_path, dir, 'lib')
195 for dir in ['', 'adblockpluscore', 'adblockplusui']] 164 for dir in ['', 'adblockpluscore', 'adblockplusui']]
196 165
197 info_template = getTemplate(info_templates[params['type']]) 166 info_template = getTemplate(info_templates[params['type']])
198 info_module = info_template.render( 167 info_module = info_template.render(
199 basename=params['metadata'].get('general', 'basename'), 168 basename=params['metadata'].get('general', 'basename'),
200 version=params['metadata'].get('general', 'version') 169 version=params['version']
201 ).encode('utf-8') 170 ).encode('utf-8')
202 171
203 configuration = { 172 configuration = {
204 'bundles': [], 173 'bundles': [],
205 'extension_path': base_extension_path, 174 'extension_path': base_extension_path,
206 'info_module': info_module, 175 'info_module': info_module,
207 'resolve_paths': resolve_paths, 176 'resolve_paths': resolve_paths,
208 } 177 }
209 178
210 for item in params['metadata'].items('bundles'): 179 for item in params['metadata'].items('bundles'):
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 if devenv: 387 if devenv:
419 add_devenv_requirements(files, metadata, params) 388 add_devenv_requirements(files, metadata, params)
420 389
421 zipdata = files.zipToString() 390 zipdata = files.zipToString()
422 signature = None 391 signature = None
423 pubkey = None 392 pubkey = None
424 if keyFile != None: 393 if keyFile != None:
425 signature = signBinary(zipdata, keyFile) 394 signature = signBinary(zipdata, keyFile)
426 pubkey = getPublicKey(keyFile) 395 pubkey = getPublicKey(keyFile)
427 writePackage(outFile, pubkey, signature, zipdata) 396 writePackage(outFile, pubkey, signature, zipdata)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld