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

Side by Side Diff: packagerEdge.py

Issue 29947559: Issue 7114 - Remove az and untranslated resources from Windows packages (Closed)
Patch Set: Different approach Created Nov. 20, 2018, 9:29 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
« no previous file with comments | « no previous file | tests/expecteddata/AppxManifest_edge_development_build.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 tree = ElementTree.parse(manifest_path) 94 tree = ElementTree.parse(manifest_path)
95 root = tree.getroot() 95 root = tree.getroot()
96 96
97 for xpath, text, attributes in overrides: 97 for xpath, text, attributes in overrides:
98 element = root.find(xpath, namespaces) 98 element = root.find(xpath, namespaces)
99 if text: 99 if text:
100 element.text = text 100 element.text = text
101 for attr, value in attributes: 101 for attr, value in attributes:
102 element.set(attr, value) 102 element.set(attr, value)
103 103
104 # Windows rejects to install the package if it contains localized
105 # resources for 'az', or if the manifest lists resources for 'uz'
106 # but the relevant strings aren't translated.
107 resources_dir = os.path.join(os.path.dirname(manifest_path), 'Resources')
108 resources_element = root.find('_d:Resources', namespaces)
109 for element in resources_element.findall('_d:Resource', namespaces):
110 language = element.get('Language')
111 if language:
112 folder = os.path.join(resources_dir, language)
113 if language == 'az':
114 shutil.rmtree(folder, ignore_errors=True)
115 if not os.path.exists(folder):
116 resources_element.remove(element)
117
104 tree.write(manifest_path, encoding='utf-8', xml_declaration=True) 118 tree.write(manifest_path, encoding='utf-8', xml_declaration=True)
105 119
106 120
107 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API. 121 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API.
108 buildNum=None, releaseBuild=False, keyFile=None, 122 buildNum=None, releaseBuild=False, keyFile=None,
109 devenv=False): 123 devenv=False):
110 124
111 metadata = packager.readMetadata(baseDir, type) 125 metadata = packager.readMetadata(baseDir, type)
112 version = packager.getBuildVersion(baseDir, metadata, releaseBuild, 126 version = packager.getBuildVersion(baseDir, metadata, releaseBuild,
113 buildNum) 127 buildNum)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 cmd = ['npm', 'run', '--silent', 'package-edge'] 219 cmd = ['npm', 'run', '--silent', 'package-edge']
206 220
207 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__)) 221 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__))
208 222
209 package = os.path.join(manifold_folder, 'package', 223 package = os.path.join(manifold_folder, 'package',
210 'edgeExtension.appx') 224 'edgeExtension.appx')
211 225
212 shutil.copyfile(package, outfile) 226 shutil.copyfile(package, outfile)
213 finally: 227 finally:
214 shutil.rmtree(tmp_dir, ignore_errors=True) 228 shutil.rmtree(tmp_dir, ignore_errors=True)
OLDNEW
« no previous file with comments | « no previous file | tests/expecteddata/AppxManifest_edge_development_build.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld