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: Created Nov. 20, 2018, 1:50 a.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 | no next file » | 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 import errno
9 from StringIO import StringIO 10 from StringIO import StringIO
10 from glob import glob 11 from glob import glob
11 import subprocess 12 import subprocess
12 import tempfile 13 import tempfile
13 from xml.etree import ElementTree 14 from xml.etree import ElementTree
14 from zipfile import ZipFile 15 from zipfile import ZipFile
15 16
16 import packager 17 import packager
17 import packagerChrome 18 import packagerChrome
18 19
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 tree = ElementTree.parse(manifest_path) 95 tree = ElementTree.parse(manifest_path)
95 root = tree.getroot() 96 root = tree.getroot()
96 97
97 for xpath, text, attributes in overrides: 98 for xpath, text, attributes in overrides:
98 element = root.find(xpath, namespaces) 99 element = root.find(xpath, namespaces)
99 if text: 100 if text:
100 element.text = text 101 element.text = text
101 for attr, value in attributes: 102 for attr, value in attributes:
102 element.set(attr, value) 103 element.set(attr, value)
103 104
105 # Windows rejects to install packages that contain localized resources
106 # for either 'az' or 'uz'. Both languages have dialects using different
107 # scripts. Using the script-sepcific language code instead seems to work.
108 resources_dir = os.path.join(os.path.dirname(manifest_path), 'Resources')
109 for element in root.findall('_d:Resources/_d:Resource', namespaces):
110 old_code = element.get('Language')
111 new_code = {'az': 'az-latn',
112 'uz': 'uz-cyrl'}.get(old_code)
113 if new_code:
114 element.set('Language', new_code)
115 try:
116 os.rename(os.path.join(resources_dir, old_code),
117 os.path.join(resources_dir, new_code))
118 except OSError as e:
119 if e.errno != errno.ENOENT:
120 raise
121
104 tree.write(manifest_path, encoding='utf-8', xml_declaration=True) 122 tree.write(manifest_path, encoding='utf-8', xml_declaration=True)
105 123
106 124
107 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API. 125 def createBuild(baseDir, type='edge', outFile=None, # noqa: preserve API.
108 buildNum=None, releaseBuild=False, keyFile=None, 126 buildNum=None, releaseBuild=False, keyFile=None,
109 devenv=False): 127 devenv=False):
110 128
111 metadata = packager.readMetadata(baseDir, type) 129 metadata = packager.readMetadata(baseDir, type)
112 version = packager.getBuildVersion(baseDir, metadata, releaseBuild, 130 version = packager.getBuildVersion(baseDir, metadata, releaseBuild,
113 buildNum) 131 buildNum)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 cmd = ['npm', 'run', '--silent', 'package-edge'] 223 cmd = ['npm', 'run', '--silent', 'package-edge']
206 224
207 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__)) 225 subprocess.check_call(cmd, env=cmd_env, cwd=os.path.dirname(__file__))
208 226
209 package = os.path.join(manifold_folder, 'package', 227 package = os.path.join(manifold_folder, 'package',
210 'edgeExtension.appx') 228 'edgeExtension.appx')
211 229
212 shutil.copyfile(package, outfile) 230 shutil.copyfile(package, outfile)
213 finally: 231 finally:
214 shutil.rmtree(tmp_dir, ignore_errors=True) 232 shutil.rmtree(tmp_dir, ignore_errors=True)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld