Mercurial > hg
annotate contrib/packaging/hgpackaging/wix.py @ 45847:d68618954ade
errors: use InputError for some errors on `hg clone`
Differential Revision: https://phab.mercurial-scm.org/D9329
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 12 Nov 2020 15:28:06 -0800 |
parents | d270b9b797a7 |
children | 89a2afe31e82 |
rev | line source |
---|---|
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
1 # wix.py - WiX installer functionality |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
2 # |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
3 # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
4 # |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
7 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
8 # no-check-code because Python 3 native. |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
9 |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
10 import collections |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
11 import os |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
12 import pathlib |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
13 import re |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
14 import shutil |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
15 import subprocess |
42048
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
16 import typing |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
17 import uuid |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
18 import xml.dom.minidom |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
19 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
20 from .downloads import download_entry |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
21 from .py2exe import ( |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
22 build_py2exe, |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
23 stage_install, |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
24 ) |
44767
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
25 from .pyoxidizer import run_pyoxidizer |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
26 from .util import ( |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
27 extract_zip_to_directory, |
44220
a70108a3d7cc
packaging: move the version normalization function to the util module
Matt Harbison <matt_harbison@yahoo.com>
parents:
44173
diff
changeset
|
28 normalize_windows_version, |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
29 process_install_rules, |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
30 sign_with_signtool, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
31 ) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
32 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
33 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
34 EXTRA_PACKAGES = { |
44223
481caa4a2244
packaging: bundle dulwich, keyring, and pywin32-ctypes with WiX too
Matt Harbison <matt_harbison@yahoo.com>
parents:
44220
diff
changeset
|
35 'dulwich', |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
36 'distutils', |
44223
481caa4a2244
packaging: bundle dulwich, keyring, and pywin32-ctypes with WiX too
Matt Harbison <matt_harbison@yahoo.com>
parents:
44220
diff
changeset
|
37 'keyring', |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
38 'pygments', |
44223
481caa4a2244
packaging: bundle dulwich, keyring, and pywin32-ctypes with WiX too
Matt Harbison <matt_harbison@yahoo.com>
parents:
44220
diff
changeset
|
39 'win32ctypes', |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
40 } |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
41 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
42 |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
43 EXTRA_INSTALL_RULES = [ |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
44 ('contrib/packaging/wix/COPYING.rtf', 'COPYING.rtf'), |
44153
e4344e463c0c
packaging: rename hgrc.d to defaultrc for Windows config files next to the exe
Matt Harbison <matt_harbison@yahoo.com>
parents:
43623
diff
changeset
|
45 ('contrib/win32/mercurial.ini', 'defaultrc/mercurial.rc'), |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
46 ] |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
47 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
48 STAGING_REMOVE_FILES = [ |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
49 # We use the RTF variant. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
50 'copying.txt', |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
51 ] |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
52 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
53 SHORTCUTS = { |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
54 # hg.1.html' |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
55 'hg.file.5d3e441c_28d9_5542_afd0_cdd4234f12d5': { |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
56 'Name': 'Mercurial Command Reference', |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
57 }, |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
58 # hgignore.5.html |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
59 'hg.file.5757d8e0_f207_5e10_a2ec_3ba0a062f431': { |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
60 'Name': 'Mercurial Ignore Files', |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
61 }, |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
62 # hgrc.5.html |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
63 'hg.file.92e605fd_1d1a_5dc6_9fc0_5d2998eb8f5e': { |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
64 'Name': 'Mercurial Configuration Files', |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
65 }, |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
66 } |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
67 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
68 |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
69 def find_version(source_dir: pathlib.Path): |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
70 version_py = source_dir / 'mercurial' / '__version__.py' |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
71 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
72 with version_py.open('r', encoding='utf-8') as fh: |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
73 source = fh.read().strip() |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
74 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
75 m = re.search('version = b"(.*)"', source) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
76 return m.group(1) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
77 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
78 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
79 def ensure_vc90_merge_modules(build_dir): |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
80 x86 = ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
81 download_entry( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
82 'vc9-crt-x86-msm', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
83 build_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
84 local_name='microsoft.vcxx.crt.x86_msm.msm', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
85 )[0], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
86 download_entry( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
87 'vc9-crt-x86-msm-policy', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
88 build_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
89 local_name='policy.x.xx.microsoft.vcxx.crt.x86_msm.msm', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
90 )[0], |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
91 ) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
92 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
93 x64 = ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
94 download_entry( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
95 'vc9-crt-x64-msm', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
96 build_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
97 local_name='microsoft.vcxx.crt.x64_msm.msm', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
98 )[0], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
99 download_entry( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
100 'vc9-crt-x64-msm-policy', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
101 build_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
102 local_name='policy.x.xx.microsoft.vcxx.crt.x64_msm.msm', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
103 )[0], |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
104 ) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
105 return { |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
106 'x86': x86, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
107 'x64': x64, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
108 } |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
109 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
110 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
111 def run_candle(wix, cwd, wxs, source_dir, defines=None): |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
112 args = [ |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
113 str(wix / 'candle.exe'), |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
114 '-nologo', |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
115 str(wxs), |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
116 '-dSourceDir=%s' % source_dir, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
117 ] |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
118 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
119 if defines: |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
120 args.extend('-d%s=%s' % define for define in sorted(defines.items())) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
121 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
122 subprocess.run(args, cwd=str(cwd), check=True) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
123 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
124 |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
125 def make_files_xml(staging_dir: pathlib.Path, is_x64) -> str: |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
126 """Create XML string listing every file to be installed.""" |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
127 |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
128 # We derive GUIDs from a deterministic file path identifier. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
129 # We shoehorn the name into something that looks like a URL because |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
130 # the UUID namespaces are supposed to work that way (even though |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
131 # the input data probably is never validated). |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
132 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
133 doc = xml.dom.minidom.parseString( |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
134 '<?xml version="1.0" encoding="utf-8"?>' |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
135 '<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">' |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
136 '</Wix>' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
137 ) |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
138 |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
139 # Assemble the install layout by directory. This makes it easier to |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
140 # emit XML, since each directory has separate entities. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
141 manifest = collections.defaultdict(dict) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
142 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
143 for root, dirs, files in os.walk(staging_dir): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
144 dirs.sort() |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
145 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
146 root = pathlib.Path(root) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
147 rel_dir = root.relative_to(staging_dir) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
148 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
149 for i in range(len(rel_dir.parts)): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
150 parent = '/'.join(rel_dir.parts[0 : i + 1]) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
151 manifest.setdefault(parent, {}) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
152 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
153 for f in sorted(files): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
154 full = root / f |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
155 manifest[str(rel_dir).replace('\\', '/')][full.name] = full |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
156 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
157 component_groups = collections.defaultdict(list) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
158 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
159 # Now emit a <Fragment> for each directory. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
160 # Each directory is composed of a <DirectoryRef> pointing to its parent |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
161 # and defines child <Directory>'s and a <Component> with all the files. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
162 for dir_name, entries in sorted(manifest.items()): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
163 # The directory id is derived from the path. But the root directory |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
164 # is special. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
165 if dir_name == '.': |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
166 parent_directory_id = 'INSTALLDIR' |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
167 else: |
45644
439ce34d81e6
packaging: normalize - to _ in WiX Id values
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44769
diff
changeset
|
168 parent_directory_id = 'hg.dir.%s' % dir_name.replace( |
439ce34d81e6
packaging: normalize - to _ in WiX Id values
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44769
diff
changeset
|
169 '/', '.' |
439ce34d81e6
packaging: normalize - to _ in WiX Id values
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44769
diff
changeset
|
170 ).replace('-', '_') |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
171 |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
172 fragment = doc.createElement('Fragment') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
173 directory_ref = doc.createElement('DirectoryRef') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
174 directory_ref.setAttribute('Id', parent_directory_id) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
175 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
176 # Add <Directory> entries for immediate children directories. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
177 for possible_child in sorted(manifest.keys()): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
178 if ( |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
179 dir_name == '.' |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
180 and '/' not in possible_child |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
181 and possible_child != '.' |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
182 ): |
45644
439ce34d81e6
packaging: normalize - to _ in WiX Id values
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44769
diff
changeset
|
183 child_directory_id = ('hg.dir.%s' % possible_child).replace( |
439ce34d81e6
packaging: normalize - to _ in WiX Id values
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44769
diff
changeset
|
184 '-', '_' |
439ce34d81e6
packaging: normalize - to _ in WiX Id values
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44769
diff
changeset
|
185 ) |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
186 name = possible_child |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
187 else: |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
188 if not possible_child.startswith('%s/' % dir_name): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
189 continue |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
190 name = possible_child[len(dir_name) + 1 :] |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
191 if '/' in name: |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
192 continue |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
193 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
194 child_directory_id = 'hg.dir.%s' % possible_child.replace( |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
195 '/', '.' |
45644
439ce34d81e6
packaging: normalize - to _ in WiX Id values
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44769
diff
changeset
|
196 ).replace('-', '_') |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
197 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
198 directory = doc.createElement('Directory') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
199 directory.setAttribute('Id', child_directory_id) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
200 directory.setAttribute('Name', name) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
201 directory_ref.appendChild(directory) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
202 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
203 # Add <Component>s for files in this directory. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
204 for rel, source_path in sorted(entries.items()): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
205 if dir_name == '.': |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
206 full_rel = rel |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
207 else: |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
208 full_rel = '%s/%s' % (dir_name, rel) |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
209 |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
210 component_unique_id = ( |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
211 'https://www.mercurial-scm.org/wix-installer/0/component/%s' |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
212 % full_rel |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
213 ) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
214 component_guid = uuid.uuid5(uuid.NAMESPACE_URL, component_unique_id) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
215 component_id = 'hg.component.%s' % str(component_guid).replace( |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
216 '-', '_' |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
217 ) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
218 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
219 component = doc.createElement('Component') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
220 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
221 component.setAttribute('Id', component_id) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
222 component.setAttribute('Guid', str(component_guid).upper()) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
223 component.setAttribute('Win64', 'yes' if is_x64 else 'no') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
224 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
225 # Assign this component to a top-level group. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
226 if dir_name == '.': |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
227 component_groups['ROOT'].append(component_id) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
228 elif '/' in dir_name: |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
229 component_groups[dir_name[0 : dir_name.index('/')]].append( |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
230 component_id |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
231 ) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
232 else: |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
233 component_groups[dir_name].append(component_id) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
234 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
235 unique_id = ( |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
236 'https://www.mercurial-scm.org/wix-installer/0/%s' % full_rel |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
237 ) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
238 file_guid = uuid.uuid5(uuid.NAMESPACE_URL, unique_id) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
239 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
240 # IDs have length limits. So use GUID to derive them. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
241 file_guid_normalized = str(file_guid).replace('-', '_') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
242 file_id = 'hg.file.%s' % file_guid_normalized |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
243 |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
244 file_element = doc.createElement('File') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
245 file_element.setAttribute('Id', file_id) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
246 file_element.setAttribute('Source', str(source_path)) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
247 file_element.setAttribute('KeyPath', 'yes') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
248 file_element.setAttribute('ReadOnly', 'yes') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
249 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
250 component.appendChild(file_element) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
251 directory_ref.appendChild(component) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
252 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
253 fragment.appendChild(directory_ref) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
254 doc.documentElement.appendChild(fragment) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
255 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
256 for group, component_ids in sorted(component_groups.items()): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
257 fragment = doc.createElement('Fragment') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
258 component_group = doc.createElement('ComponentGroup') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
259 component_group.setAttribute('Id', 'hg.group.%s' % group) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
260 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
261 for component_id in component_ids: |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
262 component_ref = doc.createElement('ComponentRef') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
263 component_ref.setAttribute('Id', component_id) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
264 component_group.appendChild(component_ref) |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
265 |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
266 fragment.appendChild(component_group) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
267 doc.documentElement.appendChild(fragment) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
268 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
269 # Add <Shortcut> to files that have it defined. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
270 for file_id, metadata in sorted(SHORTCUTS.items()): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
271 els = doc.getElementsByTagName('File') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
272 els = [el for el in els if el.getAttribute('Id') == file_id] |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
273 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
274 if not els: |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
275 raise Exception('could not find File[Id=%s]' % file_id) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
276 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
277 for el in els: |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
278 shortcut = doc.createElement('Shortcut') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
279 shortcut.setAttribute('Id', 'hg.shortcut.%s' % file_id) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
280 shortcut.setAttribute('Directory', 'ProgramMenuDir') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
281 shortcut.setAttribute('Icon', 'hgIcon.ico') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
282 shortcut.setAttribute('IconIndex', '0') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
283 shortcut.setAttribute('Advertise', 'yes') |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
284 for k, v in sorted(metadata.items()): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
285 shortcut.setAttribute(k, v) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
286 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
287 el.appendChild(shortcut) |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
288 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
289 return doc.toprettyxml() |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
290 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
291 |
44767
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
292 def build_installer_py2exe( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
293 source_dir: pathlib.Path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
294 python_exe: pathlib.Path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
295 msi_name='mercurial', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
296 version=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
297 extra_packages_script=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
298 extra_wxs: typing.Optional[typing.Dict[str, str]] = None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
299 extra_features: typing.Optional[typing.List[str]] = None, |
44765
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
300 signing_info: typing.Optional[typing.Dict[str, str]] = None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
301 ): |
44767
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
302 """Build a WiX MSI installer using py2exe. |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
303 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
304 ``source_dir`` is the path to the Mercurial source tree to use. |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
305 ``arch`` is the target architecture. either ``x86`` or ``x64``. |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
306 ``python_exe`` is the path to the Python executable to use/bundle. |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
307 ``version`` is the Mercurial version string. If not defined, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
308 ``mercurial/__version__.py`` will be consulted. |
42047
715d3220ac4f
wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents:
41957
diff
changeset
|
309 ``extra_packages_script`` is a command to be run to inject extra packages |
715d3220ac4f
wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents:
41957
diff
changeset
|
310 into the py2exe binary. It should stage packages into the virtualenv and |
715d3220ac4f
wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents:
41957
diff
changeset
|
311 print a null byte followed by a newline-separated list of packages that |
715d3220ac4f
wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents:
41957
diff
changeset
|
312 should be included in the exe. |
42048
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
313 ``extra_wxs`` is a dict of {wxs_name: working_dir_for_wxs_build}. |
42049
1711f5813a63
wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents:
42048
diff
changeset
|
314 ``extra_features`` is a list of additional named Features to include in |
1711f5813a63
wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents:
42048
diff
changeset
|
315 the build. These must match Feature names in one of the wxs scripts. |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
316 """ |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
317 arch = 'x64' if r'\x64' in os.environ.get('LIB', '') else 'x86' |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
318 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
319 hg_build_dir = source_dir / 'build' |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
320 |
44242
847e582f3cc9
packaging: make the path to Win32 requirements absolute when building WiX
Matt Harbison <matt_harbison@yahoo.com>
parents:
44224
diff
changeset
|
321 requirements_txt = ( |
45752
d270b9b797a7
contrib: split Windows requirements into multiple files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45644
diff
changeset
|
322 source_dir / 'contrib' / 'packaging' / 'requirements-windows-py2.txt' |
44242
847e582f3cc9
packaging: make the path to Win32 requirements absolute when building WiX
Matt Harbison <matt_harbison@yahoo.com>
parents:
44224
diff
changeset
|
323 ) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
324 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
325 build_py2exe( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
326 source_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
327 hg_build_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
328 python_exe, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
329 'wix', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
330 requirements_txt, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
331 extra_packages=EXTRA_PACKAGES, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
332 extra_packages_script=extra_packages_script, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
333 ) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
334 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
335 build_dir = hg_build_dir / ('wix-%s' % arch) |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
336 staging_dir = build_dir / 'stage' |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
337 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
338 build_dir.mkdir(exist_ok=True) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
339 |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
340 # Purge the staging directory for every build so packaging is pristine. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
341 if staging_dir.exists(): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
342 print('purging %s' % staging_dir) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
343 shutil.rmtree(staging_dir) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
344 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
345 stage_install(source_dir, staging_dir, lower_case=True) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
346 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
347 # We also install some extra files. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
348 process_install_rules(EXTRA_INSTALL_RULES, source_dir, staging_dir) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
349 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
350 # And remove some files we don't want. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
351 for f in STAGING_REMOVE_FILES: |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
352 p = staging_dir / f |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
353 if p.exists(): |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
354 print('removing %s' % p) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
355 p.unlink() |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
356 |
44764
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
357 return run_wix_packaging( |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
358 source_dir, |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
359 build_dir, |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
360 staging_dir, |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
361 arch, |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
362 version=version, |
44767
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
363 python2=True, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
364 msi_name=msi_name, |
44769
9ade217b550d
packaging: add -python2 to Windows installer filenames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44767
diff
changeset
|
365 suffix="-python2", |
44767
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
366 extra_wxs=extra_wxs, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
367 extra_features=extra_features, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
368 signing_info=signing_info, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
369 ) |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
370 |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
371 |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
372 def build_installer_pyoxidizer( |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
373 source_dir: pathlib.Path, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
374 target_triple: str, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
375 msi_name='mercurial', |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
376 version=None, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
377 extra_wxs: typing.Optional[typing.Dict[str, str]] = None, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
378 extra_features: typing.Optional[typing.List[str]] = None, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
379 signing_info: typing.Optional[typing.Dict[str, str]] = None, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
380 ): |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
381 """Build a WiX MSI installer using PyOxidizer.""" |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
382 hg_build_dir = source_dir / "build" |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
383 build_dir = hg_build_dir / ("wix-%s" % target_triple) |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
384 staging_dir = build_dir / "stage" |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
385 |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
386 arch = "x64" if "x86_64" in target_triple else "x86" |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
387 |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
388 build_dir.mkdir(parents=True, exist_ok=True) |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
389 run_pyoxidizer(source_dir, build_dir, staging_dir, target_triple) |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
390 |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
391 # We also install some extra files. |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
392 process_install_rules(EXTRA_INSTALL_RULES, source_dir, staging_dir) |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
393 |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
394 # And remove some files we don't want. |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
395 for f in STAGING_REMOVE_FILES: |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
396 p = staging_dir / f |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
397 if p.exists(): |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
398 print('removing %s' % p) |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
399 p.unlink() |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
400 |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
401 return run_wix_packaging( |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
402 source_dir, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
403 build_dir, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
404 staging_dir, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
405 arch, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
406 version, |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
407 python2=False, |
44764
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
408 msi_name=msi_name, |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
409 extra_wxs=extra_wxs, |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
410 extra_features=extra_features, |
44765
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
411 signing_info=signing_info, |
44764
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
412 ) |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
413 |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
414 |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
415 def run_wix_packaging( |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
416 source_dir: pathlib.Path, |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
417 build_dir: pathlib.Path, |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
418 staging_dir: pathlib.Path, |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
419 arch: str, |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
420 version: str, |
44767
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
421 python2: bool, |
44764
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
422 msi_name: typing.Optional[str] = "mercurial", |
44769
9ade217b550d
packaging: add -python2 to Windows installer filenames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44767
diff
changeset
|
423 suffix: str = "", |
44764
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
424 extra_wxs: typing.Optional[typing.Dict[str, str]] = None, |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
425 extra_features: typing.Optional[typing.List[str]] = None, |
44765
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
426 signing_info: typing.Optional[typing.Dict[str, str]] = None, |
44764
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
427 ): |
44765
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
428 """Invokes WiX to package up a built Mercurial. |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
429 |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
430 ``signing_info`` is a dict defining properties to facilitate signing the |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
431 installer. Recognized keys include ``name``, ``subject_name``, |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
432 ``cert_path``, ``cert_password``, and ``timestamp_url``. If populated, |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
433 we will sign both the hg.exe and the .msi using the signing credentials |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
434 specified. |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
435 """ |
44766
a5740490eb5f
packaging: move version derivation to run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44765
diff
changeset
|
436 |
a5740490eb5f
packaging: move version derivation to run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44765
diff
changeset
|
437 orig_version = version or find_version(source_dir) |
a5740490eb5f
packaging: move version derivation to run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44765
diff
changeset
|
438 version = normalize_windows_version(orig_version) |
a5740490eb5f
packaging: move version derivation to run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44765
diff
changeset
|
439 print('using version string: %s' % version) |
a5740490eb5f
packaging: move version derivation to run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44765
diff
changeset
|
440 if version != orig_version: |
a5740490eb5f
packaging: move version derivation to run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44765
diff
changeset
|
441 print('(normalized from: %s)' % orig_version) |
a5740490eb5f
packaging: move version derivation to run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44765
diff
changeset
|
442 |
44765
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
443 if signing_info: |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
444 sign_with_signtool( |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
445 staging_dir / "hg.exe", |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
446 "%s %s" % (signing_info["name"], version), |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
447 subject_name=signing_info["subject_name"], |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
448 cert_path=signing_info["cert_path"], |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
449 cert_password=signing_info["cert_password"], |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
450 timestamp_url=signing_info["timestamp_url"], |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
451 ) |
44764
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
452 |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
453 wix_dir = source_dir / 'contrib' / 'packaging' / 'wix' |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
454 |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
455 wix_pkg, wix_entry = download_entry('wix', build_dir) |
92627c42e7c2
packaging: isolate invocation of WiX to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44242
diff
changeset
|
456 wix_path = build_dir / ('wix-%s' % wix_entry['version']) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
457 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
458 if not wix_path.exists(): |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
459 extract_zip_to_directory(wix_pkg, wix_path) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
460 |
44767
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
461 if python2: |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
462 ensure_vc90_merge_modules(build_dir) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
463 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
464 source_build_rel = pathlib.Path(os.path.relpath(source_dir, build_dir)) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
465 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
466 defines = {'Platform': arch} |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
467 |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
468 # Derive a .wxs file with the staged files. |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
469 manifest_wxs = build_dir / 'stage.wxs' |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
470 with manifest_wxs.open('w', encoding='utf-8') as fh: |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
471 fh.write(make_files_xml(staging_dir, is_x64=arch == 'x64')) |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
472 |
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
473 run_candle(wix_path, build_dir, manifest_wxs, staging_dir, defines=defines) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
474 |
42048
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
475 for source, rel_path in sorted((extra_wxs or {}).items()): |
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
476 run_candle(wix_path, build_dir, source, rel_path, defines=defines) |
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
477 |
41956
39f65c506899
wix: introduce variable to hold path to wix packaging directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41952
diff
changeset
|
478 source = wix_dir / 'mercurial.wxs' |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
479 defines['Version'] = version |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
480 defines['Comments'] = 'Installs Mercurial version %s' % version |
44767
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
481 |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
482 if python2: |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
483 defines["PythonVersion"] = "2" |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
484 defines['VCRedistSrcDir'] = str(build_dir) |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
485 else: |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
486 defines["PythonVersion"] = "3" |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
487 |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
488 if (staging_dir / "lib").exists(): |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
489 defines["MercurialHasLib"] = "1" |
234882d17814
packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44766
diff
changeset
|
490 |
42049
1711f5813a63
wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents:
42048
diff
changeset
|
491 if extra_features: |
1711f5813a63
wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents:
42048
diff
changeset
|
492 assert all(';' not in f for f in extra_features) |
1711f5813a63
wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents:
42048
diff
changeset
|
493 defines['MercurialExtraFeatures'] = ';'.join(extra_features) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
494 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
495 run_candle(wix_path, build_dir, source, source_build_rel, defines=defines) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
496 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
497 msi_path = ( |
44769
9ade217b550d
packaging: add -python2 to Windows installer filenames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44767
diff
changeset
|
498 source_dir |
9ade217b550d
packaging: add -python2 to Windows installer filenames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44767
diff
changeset
|
499 / 'dist' |
9ade217b550d
packaging: add -python2 to Windows installer filenames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44767
diff
changeset
|
500 / ('%s-%s-%s%s.msi' % (msi_name, orig_version, arch, suffix)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
501 ) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
502 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
503 args = [ |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
504 str(wix_path / 'light.exe'), |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
505 '-nologo', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
506 '-ext', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
507 'WixUIExtension', |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
508 '-sw1076', |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
509 '-spdb', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
510 '-o', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
511 str(msi_path), |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
512 ] |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
513 |
42048
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
514 for source, rel_path in sorted((extra_wxs or {}).items()): |
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
515 assert source.endswith('.wxs') |
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
516 source = os.path.basename(source) |
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
517 args.append(str(build_dir / ('%s.wixobj' % source[:-4]))) |
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
518 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
519 args.extend( |
43623
94eac340d212
packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43522
diff
changeset
|
520 [str(build_dir / 'stage.wixobj'), str(build_dir / 'mercurial.wixobj'),] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
521 ) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
522 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
523 subprocess.run(args, cwd=str(source_dir), check=True) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
524 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
525 print('%s created' % msi_path) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
526 |
44765
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
527 if signing_info: |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
528 sign_with_signtool( |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
529 msi_path, |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
530 "%s %s" % (signing_info["name"], version), |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
531 subject_name=signing_info["subject_name"], |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
532 cert_path=signing_info["cert_path"], |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
533 cert_password=signing_info["cert_password"], |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
534 timestamp_url=signing_info["timestamp_url"], |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
535 ) |
a39984091380
packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44764
diff
changeset
|
536 |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
537 return { |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
538 'msi_path': msi_path, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
539 } |