Show More
@@ -12,6 +12,7 b' import pathlib' | |||||
12 | import re |
|
12 | import re | |
13 | import subprocess |
|
13 | import subprocess | |
14 | import tempfile |
|
14 | import tempfile | |
|
15 | import typing | |||
15 | import xml.dom.minidom |
|
16 | import xml.dom.minidom | |
16 |
|
17 | |||
17 | from .downloads import ( |
|
18 | from .downloads import ( | |
@@ -178,7 +179,8 b' def make_libraries_xml(wix_dir: pathlib.' | |||||
178 |
|
179 | |||
179 | def build_installer(source_dir: pathlib.Path, python_exe: pathlib.Path, |
|
180 | def build_installer(source_dir: pathlib.Path, python_exe: pathlib.Path, | |
180 | msi_name='mercurial', version=None, post_build_fn=None, |
|
181 | msi_name='mercurial', version=None, post_build_fn=None, | |
181 |
extra_packages_script=None |
|
182 | extra_packages_script: typing.Optional[str]=None, | |
|
183 | extra_wxs:typing.Optional[typing.Dict[str,str]]=None): | |||
182 | """Build a WiX MSI installer. |
|
184 | """Build a WiX MSI installer. | |
183 |
|
185 | |||
184 | ``source_dir`` is the path to the Mercurial source tree to use. |
|
186 | ``source_dir`` is the path to the Mercurial source tree to use. | |
@@ -194,6 +196,7 b' def build_installer(source_dir: pathlib.' | |||||
194 | into the py2exe binary. It should stage packages into the virtualenv and |
|
196 | into the py2exe binary. It should stage packages into the virtualenv and | |
195 | print a null byte followed by a newline-separated list of packages that |
|
197 | print a null byte followed by a newline-separated list of packages that | |
196 | should be included in the exe. |
|
198 | should be included in the exe. | |
|
199 | ``extra_wxs`` is a dict of {wxs_name: working_dir_for_wxs_build}. | |||
197 | """ |
|
200 | """ | |
198 | arch = 'x64' if r'\x64' in os.environ.get('LIB', '') else 'x86' |
|
201 | arch = 'x64' if r'\x64' in os.environ.get('LIB', '') else 'x86' | |
199 |
|
202 | |||
@@ -235,6 +238,9 b' def build_installer(source_dir: pathlib.' | |||||
235 | wxs_source_dir = source_dir / rel_path |
|
238 | wxs_source_dir = source_dir / rel_path | |
236 | run_candle(wix_path, build_dir, wxs, wxs_source_dir, defines=defines) |
|
239 | run_candle(wix_path, build_dir, wxs, wxs_source_dir, defines=defines) | |
237 |
|
240 | |||
|
241 | for source, rel_path in sorted((extra_wxs or {}).items()): | |||
|
242 | run_candle(wix_path, build_dir, source, rel_path, defines=defines) | |||
|
243 | ||||
238 | # candle.exe doesn't like when we have an open handle on the file. |
|
244 | # candle.exe doesn't like when we have an open handle on the file. | |
239 | # So use TemporaryDirectory() instead of NamedTemporaryFile(). |
|
245 | # So use TemporaryDirectory() instead of NamedTemporaryFile(). | |
240 | with tempfile.TemporaryDirectory() as td: |
|
246 | with tempfile.TemporaryDirectory() as td: | |
@@ -269,6 +275,11 b' def build_installer(source_dir: pathlib.' | |||||
269 | assert source.endswith('.wxs') |
|
275 | assert source.endswith('.wxs') | |
270 | args.append(str(build_dir / ('%s.wixobj' % source[:-4]))) |
|
276 | args.append(str(build_dir / ('%s.wixobj' % source[:-4]))) | |
271 |
|
277 | |||
|
278 | for source, rel_path in sorted((extra_wxs or {}).items()): | |||
|
279 | assert source.endswith('.wxs') | |||
|
280 | source = os.path.basename(source) | |||
|
281 | args.append(str(build_dir / ('%s.wixobj' % source[:-4]))) | |||
|
282 | ||||
272 | args.extend([ |
|
283 | args.extend([ | |
273 | str(build_dir / 'library.wixobj'), |
|
284 | str(build_dir / 'library.wixobj'), | |
274 | str(build_dir / 'mercurial.wixobj'), |
|
285 | str(build_dir / 'mercurial.wixobj'), | |
@@ -286,7 +297,8 b' def build_installer(source_dir: pathlib.' | |||||
286 | def build_signed_installer(source_dir: pathlib.Path, python_exe: pathlib.Path, |
|
297 | def build_signed_installer(source_dir: pathlib.Path, python_exe: pathlib.Path, | |
287 | name: str, version=None, subject_name=None, |
|
298 | name: str, version=None, subject_name=None, | |
288 | cert_path=None, cert_password=None, |
|
299 | cert_path=None, cert_password=None, | |
289 |
timestamp_url=None, extra_packages_script=None |
|
300 | timestamp_url=None, extra_packages_script=None, | |
|
301 | extra_wxs=None): | |||
290 | """Build an installer with signed executables.""" |
|
302 | """Build an installer with signed executables.""" | |
291 |
|
303 | |||
292 | post_build_fn = make_post_build_signing_fn( |
|
304 | post_build_fn = make_post_build_signing_fn( | |
@@ -299,7 +311,8 b' def build_signed_installer(source_dir: p' | |||||
299 | info = build_installer(source_dir, python_exe=python_exe, |
|
311 | info = build_installer(source_dir, python_exe=python_exe, | |
300 | msi_name=name.lower(), version=version, |
|
312 | msi_name=name.lower(), version=version, | |
301 | post_build_fn=post_build_fn, |
|
313 | post_build_fn=post_build_fn, | |
302 |
extra_packages_script=extra_packages_script |
|
314 | extra_packages_script=extra_packages_script, | |
|
315 | extra_wxs=extra_wxs) | |||
303 |
|
316 | |||
304 | description = '%s %s' % (name, version) |
|
317 | description = '%s %s' % (name, version) | |
305 |
|
318 |
@@ -37,6 +37,8 b" if __name__ == '__main__':" | |||||
37 | parser.add_argument('--extra-packages-script', |
|
37 | parser.add_argument('--extra-packages-script', | |
38 | help=('Script to execute to include extra packages in ' |
|
38 | help=('Script to execute to include extra packages in ' | |
39 | 'py2exe binary.')) |
|
39 | 'py2exe binary.')) | |
|
40 | parser.add_argument('--extra-wxs', | |||
|
41 | help='CSV of path_to_wxs_file=working_dir_for_wxs_file') | |||
40 |
|
42 | |||
41 | args = parser.parse_args() |
|
43 | args = parser.parse_args() | |
42 |
|
44 | |||
@@ -59,6 +61,9 b" if __name__ == '__main__':" | |||||
59 |
|
61 | |||
60 | if args.extra_packages_script: |
|
62 | if args.extra_packages_script: | |
61 | kwargs['extra_packages_script'] = args.extra_packages_script |
|
63 | kwargs['extra_packages_script'] = args.extra_packages_script | |
|
64 | if args.extra_wxs: | |||
|
65 | kwargs['extra_wxs'] = dict( | |||
|
66 | thing.split("=") for thing in args.extra_wxs.split(',')) | |||
62 |
|
67 | |||
63 | if args.sign_sn or args.sign_cert: |
|
68 | if args.sign_sn or args.sign_cert: | |
64 | fn = build_signed_installer |
|
69 | fn = build_signed_installer |
General Comments 0
You need to be logged in to leave comments.
Login now