Mercurial > hg
annotate contrib/packaging/hgpackaging/wix.py @ 43522:ce96be208ea4
packaging: stop installing i18n files
The WiX installer has been shipping the content of the i18n/
directory since it was introduced in 2010 in 1e022c88a0a5.
And the installer was subsequently refactored to only ship
the .po files and hggettext.
The .po files and the hggettext script are only used at build
time to produce .mo files, which Mercurial does use at run-time.
It doesn't make sense to install these files on Windows. So
this commit stops doing that.
This change further converges the file layout of the Inno and
WiX installers.
Differential Revision: https://phab.mercurial-scm.org/D7165
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 23 Oct 2019 12:15:42 -0700 |
parents | 2372284d9457 |
children | 94eac340d212 |
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 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
10 import os |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
11 import pathlib |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
12 import re |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
13 import subprocess |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
14 import tempfile |
42048
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
15 import typing |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
16 import xml.dom.minidom |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
17 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
18 from .downloads import download_entry |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
19 from .py2exe import build_py2exe |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
20 from .util import ( |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
21 extract_zip_to_directory, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
22 sign_with_signtool, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
23 ) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
24 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
25 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
26 SUPPORT_WXS = [ |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
27 ('contrib.wxs', r'contrib'), |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
28 ('dist.wxs', r'dist'), |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
29 ('doc.wxs', r'doc'), |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
30 ('help.wxs', r'mercurial\help'), |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
31 ('locale.wxs', r'mercurial\locale'), |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
32 ('templates.wxs', r'mercurial\templates'), |
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 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
35 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
36 EXTRA_PACKAGES = { |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
37 'distutils', |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
38 'pygments', |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
39 } |
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 def find_version(source_dir: pathlib.Path): |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
43 version_py = source_dir / 'mercurial' / '__version__.py' |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
44 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
45 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
|
46 source = fh.read().strip() |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
47 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
48 m = re.search('version = b"(.*)"', source) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
49 return m.group(1) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
50 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
51 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
52 def normalize_version(version): |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
53 """Normalize Mercurial version string so WiX accepts it. |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
54 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
55 Version strings have to be numeric X.Y.Z. |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
56 """ |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
57 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
58 if '+' in version: |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
59 version, extra = version.split('+', 1) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
60 else: |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
61 extra = None |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
62 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
63 # 4.9rc0 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
64 if version[:-1].endswith('rc'): |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
65 version = version[:-3] |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
66 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
67 versions = [int(v) for v in version.split('.')] |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
68 while len(versions) < 3: |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
69 versions.append(0) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
70 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
71 major, minor, build = versions[:3] |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
72 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
73 if extra: |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
74 # <commit count>-<hash>+<date> |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
75 build = int(extra.split('-')[0]) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
76 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
77 return '.'.join('%d' % x for x in (major, minor, build)) |
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 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
80 def ensure_vc90_merge_modules(build_dir): |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
81 x86 = ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
82 download_entry( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
83 'vc9-crt-x86-msm', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
84 build_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
85 local_name='microsoft.vcxx.crt.x86_msm.msm', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
86 )[0], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
87 download_entry( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
88 'vc9-crt-x86-msm-policy', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
89 build_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
90 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
|
91 )[0], |
41952
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 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
94 x64 = ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
95 download_entry( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
96 'vc9-crt-x64-msm', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
97 build_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
98 local_name='microsoft.vcxx.crt.x64_msm.msm', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
99 )[0], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
100 download_entry( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
101 'vc9-crt-x64-msm-policy', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
102 build_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
103 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
|
104 )[0], |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
105 ) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
106 return { |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
107 'x86': x86, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
108 'x64': x64, |
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 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
112 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
|
113 args = [ |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
114 str(wix / 'candle.exe'), |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
115 '-nologo', |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
116 str(wxs), |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
117 '-dSourceDir=%s' % source_dir, |
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 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
120 if defines: |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
121 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
|
122 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
123 subprocess.run(args, cwd=str(cwd), check=True) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
124 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
125 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
126 def make_post_build_signing_fn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
127 name, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
128 subject_name=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
129 cert_path=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
130 cert_password=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
131 timestamp_url=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
132 ): |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
133 """Create a callable that will use signtool to sign hg.exe.""" |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
134 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
135 def post_build_sign(source_dir, build_dir, dist_dir, version): |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
136 description = '%s %s' % (name, version) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
137 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
138 sign_with_signtool( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
139 dist_dir / 'hg.exe', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
140 description, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
141 subject_name=subject_name, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
142 cert_path=cert_path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
143 cert_password=cert_password, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
144 timestamp_url=timestamp_url, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
145 ) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
146 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
147 return post_build_sign |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
148 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
149 |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
150 LIBRARIES_XML = ''' |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
151 <?xml version="1.0" encoding="utf-8"?> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
152 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
153 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
154 <?include {wix_dir}/guids.wxi ?> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
155 <?include {wix_dir}/defines.wxi ?> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
156 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
157 <Fragment> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
158 <DirectoryRef Id="INSTALLDIR" FileSource="$(var.SourceDir)"> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
159 <Directory Id="libdir" Name="lib" FileSource="$(var.SourceDir)/lib"> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
160 <Component Id="libOutput" Guid="$(var.lib.guid)" Win64='$(var.IsX64)'> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
161 </Component> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
162 </Directory> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
163 </DirectoryRef> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
164 </Fragment> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
165 </Wix> |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
166 '''.lstrip() |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
167 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
168 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
169 def make_libraries_xml(wix_dir: pathlib.Path, dist_dir: pathlib.Path): |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
170 """Make XML data for library components WXS.""" |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
171 # We can't use ElementTree because it doesn't handle the |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
172 # <?include ?> directives. |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
173 doc = xml.dom.minidom.parseString( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
174 LIBRARIES_XML.format(wix_dir=str(wix_dir)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
175 ) |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
176 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
177 component = doc.getElementsByTagName('Component')[0] |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
178 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
179 f = doc.createElement('File') |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
180 f.setAttribute('Name', 'library.zip') |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
181 f.setAttribute('KeyPath', 'yes') |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
182 component.appendChild(f) |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
183 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
184 lib_dir = dist_dir / 'lib' |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
185 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
186 for p in sorted(lib_dir.iterdir()): |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
187 if not p.name.endswith(('.dll', '.pyd')): |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
188 continue |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
189 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
190 f = doc.createElement('File') |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
191 f.setAttribute('Name', p.name) |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
192 component.appendChild(f) |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
193 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
194 return doc.toprettyxml() |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
195 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
196 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
197 def build_installer( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
198 source_dir: pathlib.Path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
199 python_exe: pathlib.Path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
200 msi_name='mercurial', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
201 version=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
202 post_build_fn=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
203 extra_packages_script=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
204 extra_wxs: typing.Optional[typing.Dict[str, str]] = None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
205 extra_features: typing.Optional[typing.List[str]] = None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
206 ): |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
207 """Build a WiX MSI installer. |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
208 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
209 ``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
|
210 ``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
|
211 ``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
|
212 ``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
|
213 ``mercurial/__version__.py`` will be consulted. |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
214 ``post_build_fn`` is a callable that will be called after building |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
215 Mercurial but before invoking WiX. It can be used to e.g. facilitate |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
216 signing. It is passed the paths to the Mercurial source, build, and |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
217 dist directories and the resolved Mercurial version. |
42047
715d3220ac4f
wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents:
41957
diff
changeset
|
218 ``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
|
219 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
|
220 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
|
221 should be included in the exe. |
42048
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
222 ``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
|
223 ``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
|
224 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
|
225 """ |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
226 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
|
227 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
228 hg_build_dir = source_dir / 'build' |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
229 dist_dir = source_dir / 'dist' |
41956
39f65c506899
wix: introduce variable to hold path to wix packaging directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41952
diff
changeset
|
230 wix_dir = source_dir / 'contrib' / 'packaging' / 'wix' |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
231 |
41956
39f65c506899
wix: introduce variable to hold path to wix packaging directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41952
diff
changeset
|
232 requirements_txt = wix_dir / 'requirements.txt' |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
233 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
234 build_py2exe( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
235 source_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
236 hg_build_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
237 python_exe, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
238 'wix', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
239 requirements_txt, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
240 extra_packages=EXTRA_PACKAGES, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
241 extra_packages_script=extra_packages_script, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
242 ) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
243 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
244 version = version or normalize_version(find_version(source_dir)) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
245 print('using version string: %s' % version) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
246 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
247 if post_build_fn: |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
248 post_build_fn(source_dir, hg_build_dir, dist_dir, version) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
249 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
250 build_dir = hg_build_dir / ('wix-%s' % arch) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
251 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
252 build_dir.mkdir(exist_ok=True) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
253 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
254 wix_pkg, wix_entry = download_entry('wix', hg_build_dir) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
255 wix_path = hg_build_dir / ('wix-%s' % wix_entry['version']) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
256 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
257 if not wix_path.exists(): |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
258 extract_zip_to_directory(wix_pkg, wix_path) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
259 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
260 ensure_vc90_merge_modules(hg_build_dir) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
261 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
262 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
|
263 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
264 defines = {'Platform': arch} |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
265 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
266 for wxs, rel_path in SUPPORT_WXS: |
41956
39f65c506899
wix: introduce variable to hold path to wix packaging directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41952
diff
changeset
|
267 wxs = wix_dir / wxs |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
268 wxs_source_dir = source_dir / rel_path |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
269 run_candle(wix_path, build_dir, wxs, wxs_source_dir, defines=defines) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
270 |
42048
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
271 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
|
272 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
|
273 |
41957
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
274 # candle.exe doesn't like when we have an open handle on the file. |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
275 # So use TemporaryDirectory() instead of NamedTemporaryFile(). |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
276 with tempfile.TemporaryDirectory() as td: |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
277 td = pathlib.Path(td) |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
278 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
279 tf = td / 'library.wxs' |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
280 with tf.open('w') as fh: |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
281 fh.write(make_libraries_xml(wix_dir, dist_dir)) |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
282 |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
283 run_candle(wix_path, build_dir, tf, dist_dir, defines=defines) |
131d0b7c3940
wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41956
diff
changeset
|
284 |
41956
39f65c506899
wix: introduce variable to hold path to wix packaging directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41952
diff
changeset
|
285 source = wix_dir / 'mercurial.wxs' |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
286 defines['Version'] = version |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
287 defines['Comments'] = 'Installs Mercurial version %s' % version |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
288 defines['VCRedistSrcDir'] = str(hg_build_dir) |
42049
1711f5813a63
wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents:
42048
diff
changeset
|
289 if extra_features: |
1711f5813a63
wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents:
42048
diff
changeset
|
290 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
|
291 defines['MercurialExtraFeatures'] = ';'.join(extra_features) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
292 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
293 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
|
294 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
295 msi_path = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
296 source_dir / 'dist' / ('%s-%s-%s.msi' % (msi_name, version, arch)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
297 ) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
298 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
299 args = [ |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
300 str(wix_path / 'light.exe'), |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
301 '-nologo', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
302 '-ext', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
303 'WixUIExtension', |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
304 '-sw1076', |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
305 '-spdb', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
306 '-o', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
307 str(msi_path), |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
308 ] |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
309 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
310 for source, rel_path in SUPPORT_WXS: |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
311 assert source.endswith('.wxs') |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
312 args.append(str(build_dir / ('%s.wixobj' % source[:-4]))) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
313 |
42048
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
314 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
|
315 assert source.endswith('.wxs') |
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
316 source = os.path.basename(source) |
978b03d5f66e
wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents:
42047
diff
changeset
|
317 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
|
318 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
319 args.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
320 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
321 str(build_dir / 'library.wixobj'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
322 str(build_dir / 'mercurial.wixobj'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
323 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
324 ) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
325 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
326 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
|
327 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
328 print('%s created' % msi_path) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
329 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
330 return { |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
331 'msi_path': msi_path, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
332 } |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
333 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
334 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
335 def build_signed_installer( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
336 source_dir: pathlib.Path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
337 python_exe: pathlib.Path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
338 name: str, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
339 version=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
340 subject_name=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
341 cert_path=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
342 cert_password=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
343 timestamp_url=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
344 extra_packages_script=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
345 extra_wxs=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
346 extra_features=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
347 ): |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
348 """Build an installer with signed executables.""" |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
349 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
350 post_build_fn = make_post_build_signing_fn( |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
351 name, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
352 subject_name=subject_name, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
353 cert_path=cert_path, |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
354 cert_password=cert_password, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
355 timestamp_url=timestamp_url, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
356 ) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
357 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
358 info = build_installer( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
359 source_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
360 python_exe=python_exe, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
361 msi_name=name.lower(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
362 version=version, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
363 post_build_fn=post_build_fn, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
364 extra_packages_script=extra_packages_script, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
365 extra_wxs=extra_wxs, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
366 extra_features=extra_features, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
367 ) |
41952
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
368 |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
369 description = '%s %s' % (name, version) |
b83de9150c1c
packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41924
diff
changeset
|
370 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
371 sign_with_signtool( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
372 info['msi_path'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
373 description, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
374 subject_name=subject_name, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
375 cert_path=cert_path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
376 cert_password=cert_password, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
377 timestamp_url=timestamp_url, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42049
diff
changeset
|
378 ) |