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

Delta Between Two Patch Sets: packagerEdge.py

Issue 29931564: Issue 7080 - Don't tranlsate product name in builds for Microsoft Edge (Closed)
Left Patch Set: Created Oct. 30, 2018, 11:28 p.m.
Right Patch Set: Rebased Created Oct. 31, 2018, 6:31 p.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
« no previous file with change/comment | « package.json ('k') | tests/expecteddata/AppxManifest_edge_development_build.xml » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 os 5 import os
6 import shutil 6 import shutil
7 import json 7 import json
8 import re 8 import re
9 from StringIO import StringIO 9 from StringIO import StringIO
10 from glob import glob 10 from glob import glob
(...skipping 22 matching lines...) Expand all
33 fp, events=['start-ns'])]) 33 fp, events=['start-ns'])])
34 for prefix, uri in ns.items(): 34 for prefix, uri in ns.items():
35 ElementTree.register_namespace(prefix, uri) 35 ElementTree.register_namespace(prefix, uri)
36 36
37 # Make the default namespace available in an xpath expression 37 # Make the default namespace available in an xpath expression
38 ns['_d'] = ns[''] 38 ns['_d'] = ns['']
39 39
40 return ns 40 return ns
41 41
42 42
43 def get_appx_version(metadata, build_num):
44 """Get the version number for usage in AppxManifest.xml.
45
46 As required by the Windows Store, the returned version string has four
47 components, where the 3rd component is replaced with the build number
48 if available, and the 4th component is always zero (e.g. 1.2.1000.0).
49 """
50 components = metadata.get('general', 'version').split('.')[:3]
51 components.extend(['0'] * (4 - len(components)))
52 if build_num:
53 components[2] = build_num
54 return '.'.join(components)
55
56
43 def update_appx_manifest(manifest_path, base_dir, files, metadata, 57 def update_appx_manifest(manifest_path, base_dir, files, metadata,
44 release_build): 58 release_build, build_num):
45 namespaces = register_xml_namespaces(manifest_path) 59 namespaces = register_xml_namespaces(manifest_path)
46 60
47 v_min, v_max = metadata.get('compat', 'windows').split('/') 61 v_min, v_max = metadata.get('compat', 'windows').split('/')
48 62
49 filenames = [] 63 filenames = []
50 64
51 for name, path in metadata.items('appx_assets'): 65 for name, path in metadata.items('appx_assets'):
52 path = os.path.join(base_dir, path) 66 path = os.path.join(base_dir, path)
53 icon_path = '{}/{}'.format(ASSETS_DIR, name) 67 icon_path = '{}/{}'.format(ASSETS_DIR, name)
54 68
55 files.read(path, icon_path) 69 files.read(path, icon_path)
56 filenames.append(icon_path) 70 filenames.append(icon_path)
57 71
58 assets = packagerChrome.makeIcons(files, filenames) 72 assets = packagerChrome.makeIcons(files, filenames)
59 73
60 author = metadata.get('general', 'author') 74 author = metadata.get('general', 'author')
61 75
62 overrides = [ 76 overrides = [
63 ('_d:Identity', None, [ 77 ('_d:Identity', None, [
64 ('Name', packager.get_app_id(release_build, metadata)), 78 ('Name', packager.get_app_id(release_build, metadata)),
65 ('Publisher', metadata.get('general', 'publisher_id')), 79 ('Publisher', metadata.get('general', 'publisher_id')),
80 ('Version', get_appx_version(metadata, build_num)),
66 ]), 81 ]),
67 ('_d:Properties/_d:PublisherDisplayName', author, []), 82 ('_d:Properties/_d:PublisherDisplayName', author, []),
68 ('_d:Properties/_d:Logo', assets[50], []), 83 ('_d:Properties/_d:Logo', assets[50], []),
69 ('_d:Dependencies/_d:TargetDeviceFamily', None, [ 84 ('_d:Dependencies/_d:TargetDeviceFamily', None, [
70 ('MaxVersionTested', v_max), 85 ('MaxVersionTested', v_max),
71 ('MinVersion', v_min), 86 ('MinVersion', v_min),
72 ]), 87 ]),
73 ('_d:Applications/_d:Application/uap:VisualElements', None, [ 88 ('_d:Applications/_d:Application/uap:VisualElements', None, [
74 ('Square150x150Logo', assets[150]), 89 ('Square150x150Logo', assets[150]),
75 ('Square44x44Logo', assets[44]), 90 ('Square44x44Logo', assets[44]),
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 cmd = ['npm', 'run', '--silent', 'build-edge'] 183 cmd = ['npm', 'run', '--silent', 'build-edge']
169 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__)) 184 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__))
170 185
171 manifold_folder = glob(os.path.join(ext_dir, '*', 'edgeextension'))[0] 186 manifold_folder = glob(os.path.join(ext_dir, '*', 'edgeextension'))[0]
172 manifest_folder = os.path.join(manifold_folder, 'manifest') 187 manifest_folder = os.path.join(manifold_folder, 'manifest')
173 asset_folder = os.path.join(manifest_folder, ASSETS_DIR) 188 asset_folder = os.path.join(manifest_folder, ASSETS_DIR)
174 189
175 # update incomplete appxmanifest 190 # update incomplete appxmanifest
176 intermediate_manifest = os.path.join(manifest_folder, MANIFEST) 191 intermediate_manifest = os.path.join(manifest_folder, MANIFEST)
177 update_appx_manifest(intermediate_manifest, baseDir, files, metadata, 192 update_appx_manifest(intermediate_manifest, baseDir, files, metadata,
178 releaseBuild) 193 releaseBuild, buildNum)
179 194
180 # cleanup placeholders, copy actual images 195 # cleanup placeholders, copy actual images
181 shutil.rmtree(asset_folder) 196 shutil.rmtree(asset_folder)
182 os.mkdir(asset_folder) 197 os.mkdir(asset_folder)
183 if metadata.has_section('appx_assets'): 198 if metadata.has_section('appx_assets'):
184 for name, path in metadata.items('appx_assets'): 199 for name, path in metadata.items('appx_assets'):
185 path = os.path.join(baseDir, path) 200 path = os.path.join(baseDir, path)
186 target = os.path.join(asset_folder, name) 201 target = os.path.join(asset_folder, name)
187 shutil.copyfile(path, target) 202 shutil.copyfile(path, target)
188 203
189 # package app with manifoldjs 204 # package app with manifoldjs
190 cmd = ['npm', 'run', '--silent', 'package-edge'] 205 cmd = ['npm', 'run', '--silent', 'package-edge']
191 206
192 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__)) 207 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__))
193 208
194 package = os.path.join(manifold_folder, 'package', 209 package = os.path.join(manifold_folder, 'package',
195 'edgeExtension.appx') 210 'edgeExtension.appx')
196 211
197 shutil.copyfile(package, outfile) 212 shutil.copyfile(package, outfile)
198 finally: 213 finally:
199 shutil.rmtree(tmp_dir, ignore_errors=True) 214 shutil.rmtree(tmp_dir, ignore_errors=True)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld