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

Side by Side Diff: packagerEdge.py

Issue 29931555: Issue 5668 - Reintroduce buildnumber shifting for edge (Closed)
Patch Set: Created Oct. 30, 2018, 4:55 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 from StringIO import StringIO 7 from StringIO import StringIO
8 import subprocess 8 import subprocess
9 import tempfile 9 import tempfile
10 from xml.etree import ElementTree 10 from xml.etree import ElementTree
(...skipping 19 matching lines...) Expand all
30 fp, events=['start-ns'])]) 30 fp, events=['start-ns'])])
31 for prefix, uri in ns.items(): 31 for prefix, uri in ns.items():
32 ElementTree.register_namespace(prefix, uri) 32 ElementTree.register_namespace(prefix, uri)
33 33
34 # Make the default namespace available in an xpath expression 34 # Make the default namespace available in an xpath expression
35 ns['_d'] = ns[''] 35 ns['_d'] = ns['']
36 36
37 return ns 37 return ns
38 38
39 39
40 def get_appx_version(metadata, build_num):
41 """Get the version number for usage in AppxManifest.xml.
42
43 As required by the Windows Store, the returned version string has four
44 components, where the 3rd component is replaced with the build number
45 if available, and the 4th component is always zero (e.g. 1.2.1000.0).
46 """
47 components = metadata.get('general', 'version').split('.')[:3]
48 components.extend(['0'] * (4 - len(components)))
49 if build_num:
50 components[2] = build_num
51 return '.'.join(components)
52
53
40 def update_appx_manifest(manifest_path, base_dir, files, metadata, 54 def update_appx_manifest(manifest_path, base_dir, files, metadata,
41 release_build): 55 release_build, build_num):
42 namespaces = register_xml_namespaces(manifest_path) 56 namespaces = register_xml_namespaces(manifest_path)
43 57
44 v_min, v_max = metadata.get('compat', 'windows').split('/') 58 v_min, v_max = metadata.get('compat', 'windows').split('/')
45 59
46 filenames = [] 60 filenames = []
47 61
48 for name, path in metadata.items('appx_assets'): 62 for name, path in metadata.items('appx_assets'):
49 path = os.path.join(base_dir, path) 63 path = os.path.join(base_dir, path)
50 icon_path = '{}/{}'.format(ASSETS_DIR, name) 64 icon_path = '{}/{}'.format(ASSETS_DIR, name)
51 65
52 files.read(path, icon_path) 66 files.read(path, icon_path)
53 filenames.append(icon_path) 67 filenames.append(icon_path)
54 68
55 assets = packagerChrome.makeIcons(files, filenames) 69 assets = packagerChrome.makeIcons(files, filenames)
56 70
57 author = metadata.get('general', 'author') 71 author = metadata.get('general', 'author')
58 72
59 overrides = [ 73 overrides = [
60 ('_d:Identity', None, [ 74 ('_d:Identity', None, [
61 ('Name', packager.get_app_id(release_build, metadata)), 75 ('Name', packager.get_app_id(release_build, metadata)),
62 ('Publisher', metadata.get('general', 'publisher_id')), 76 ('Publisher', metadata.get('general', 'publisher_id')),
77 ('Version', get_appx_version(metadata, build_num)),
63 ]), 78 ]),
64 ('_d:Properties/_d:PublisherDisplayName', author, []), 79 ('_d:Properties/_d:PublisherDisplayName', author, []),
65 ('_d:Properties/_d:Logo', assets[50], []), 80 ('_d:Properties/_d:Logo', assets[50], []),
66 ('_d:Dependencies/_d:TargetDeviceFamily', None, [ 81 ('_d:Dependencies/_d:TargetDeviceFamily', None, [
67 ('MaxVersionTested', v_max), 82 ('MaxVersionTested', v_max),
68 ('MinVersion', v_min), 83 ('MinVersion', v_min),
69 ]), 84 ]),
70 ('_d:Applications/_d:Application/uap:VisualElements', None, [ 85 ('_d:Applications/_d:Application/uap:VisualElements', None, [
71 ('Square150x150Logo', assets[150]), 86 ('Square150x150Logo', assets[150]),
72 ('Square44x44Logo', assets[44]), 87 ('Square44x44Logo', assets[44]),
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 manifest_folder = os.path.join(manifold_folder, 'manifest') 178 manifest_folder = os.path.join(manifold_folder, 'manifest')
164 asset_folder = os.path.join(manifest_folder, ASSETS_DIR) 179 asset_folder = os.path.join(manifest_folder, ASSETS_DIR)
165 180
166 # prepare the extension with manifoldjs 181 # prepare the extension with manifoldjs
167 cmd = ['npm', 'run', '--silent', 'build-edge'] 182 cmd = ['npm', 'run', '--silent', 'build-edge']
168 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__)) 183 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__))
169 184
170 # update incomplete appxmanifest 185 # update incomplete appxmanifest
171 intermediate_manifest = os.path.join(manifest_folder, MANIFEST) 186 intermediate_manifest = os.path.join(manifest_folder, MANIFEST)
172 update_appx_manifest(intermediate_manifest, baseDir, files, metadata, 187 update_appx_manifest(intermediate_manifest, baseDir, files, metadata,
173 releaseBuild) 188 releaseBuild, buildNum)
174 189
175 # cleanup placeholders, copy actual images 190 # cleanup placeholders, copy actual images
176 shutil.rmtree(asset_folder) 191 shutil.rmtree(asset_folder)
177 os.mkdir(asset_folder) 192 os.mkdir(asset_folder)
178 if metadata.has_section('appx_assets'): 193 if metadata.has_section('appx_assets'):
179 for name, path in metadata.items('appx_assets'): 194 for name, path in metadata.items('appx_assets'):
180 path = os.path.join(baseDir, path) 195 path = os.path.join(baseDir, path)
181 target = os.path.join(asset_folder, name) 196 target = os.path.join(asset_folder, name)
182 shutil.copyfile(path, target) 197 shutil.copyfile(path, target)
183 198
184 # package app with manifoldjs 199 # package app with manifoldjs
185 cmd = ['npm', 'run', '--silent', 'package-edge'] 200 cmd = ['npm', 'run', '--silent', 'package-edge']
186 201
187 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__)) 202 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__))
188 203
189 package = os.path.join(manifold_folder, 'package', 204 package = os.path.join(manifold_folder, 'package',
190 'edgeExtension.appx') 205 'edgeExtension.appx')
191 206
192 shutil.copyfile(package, outfile) 207 shutil.copyfile(package, outfile)
193 finally: 208 finally:
194 shutil.rmtree(tmp_dir, ignore_errors=True) 209 shutil.rmtree(tmp_dir, ignore_errors=True)
OLDNEW

Powered by Google App Engine
This is Rietveld