Show More
@@ -1,48 +1,51 b'' | |||||
1 | #!/usr/bin/env python3 |
|
1 | #!/usr/bin/env python3 | |
2 | # build.py - Inno installer build script. |
|
2 | # build.py - Inno installer build script. | |
3 | # |
|
3 | # | |
4 | # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> |
|
4 | # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> | |
5 | # |
|
5 | # | |
6 | # This software may be used and distributed according to the terms of the |
|
6 | # This software may be used and distributed according to the terms of the | |
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
8 |
|
8 | |||
9 | # This script automates the building of the Inno MSI installer for Mercurial. |
|
9 | # This script automates the building of the Inno MSI installer for Mercurial. | |
10 |
|
10 | |||
11 | # no-check-code because Python 3 native. |
|
11 | # no-check-code because Python 3 native. | |
12 |
|
12 | |||
13 | import argparse |
|
13 | import argparse | |
14 | import os |
|
14 | import os | |
15 | import pathlib |
|
15 | import pathlib | |
16 | import sys |
|
16 | import sys | |
17 |
|
17 | |||
18 |
|
18 | |||
19 | if __name__ == '__main__': |
|
19 | if __name__ == '__main__': | |
20 | parser = argparse.ArgumentParser() |
|
20 | parser = argparse.ArgumentParser() | |
21 |
|
21 | |||
22 | parser.add_argument('--python', |
|
22 | parser.add_argument('--python', | |
23 | required=True, |
|
23 | required=True, | |
24 | help='path to python.exe to use') |
|
24 | help='path to python.exe to use') | |
25 | parser.add_argument('--iscc', |
|
25 | parser.add_argument('--iscc', | |
26 | help='path to iscc.exe to use') |
|
26 | help='path to iscc.exe to use') | |
27 | parser.add_argument('--version', |
|
27 | parser.add_argument('--version', | |
28 | help='Mercurial version string to use ' |
|
28 | help='Mercurial version string to use ' | |
29 | '(detected from __version__.py if not defined') |
|
29 | '(detected from __version__.py if not defined') | |
30 |
|
30 | |||
31 | args = parser.parse_args() |
|
31 | args = parser.parse_args() | |
32 |
|
32 | |||
|
33 | if not os.path.isabs(args.python): | |||
|
34 | raise Exception('--python arg must be an absolute path') | |||
|
35 | ||||
33 | if args.iscc: |
|
36 | if args.iscc: | |
34 | iscc = pathlib.Path(args.iscc) |
|
37 | iscc = pathlib.Path(args.iscc) | |
35 | else: |
|
38 | else: | |
36 | iscc = (pathlib.Path(os.environ['ProgramFiles(x86)']) / 'Inno Setup 5' / |
|
39 | iscc = (pathlib.Path(os.environ['ProgramFiles(x86)']) / 'Inno Setup 5' / | |
37 | 'ISCC.exe') |
|
40 | 'ISCC.exe') | |
38 |
|
41 | |||
39 | here = pathlib.Path(os.path.abspath(os.path.dirname(__file__))) |
|
42 | here = pathlib.Path(os.path.abspath(os.path.dirname(__file__))) | |
40 | source_dir = here.parent.parent.parent |
|
43 | source_dir = here.parent.parent.parent | |
41 | build_dir = source_dir / 'build' |
|
44 | build_dir = source_dir / 'build' | |
42 |
|
45 | |||
43 | sys.path.insert(0, str(source_dir / 'contrib' / 'packaging')) |
|
46 | sys.path.insert(0, str(source_dir / 'contrib' / 'packaging')) | |
44 |
|
47 | |||
45 | from hgpackaging.inno import build |
|
48 | from hgpackaging.inno import build | |
46 |
|
49 | |||
47 | build(source_dir, build_dir, pathlib.Path(args.python), iscc, |
|
50 | build(source_dir, build_dir, pathlib.Path(args.python), iscc, | |
48 | version=args.version) |
|
51 | version=args.version) |
@@ -1,81 +1,84 b'' | |||||
1 | #!/usr/bin/env python3 |
|
1 | #!/usr/bin/env python3 | |
2 | # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> |
|
2 | # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> | |
3 | # |
|
3 | # | |
4 | # This software may be used and distributed according to the terms of the |
|
4 | # This software may be used and distributed according to the terms of the | |
5 | # GNU General Public License version 2 or any later version. |
|
5 | # GNU General Public License version 2 or any later version. | |
6 |
|
6 | |||
7 | # no-check-code because Python 3 native. |
|
7 | # no-check-code because Python 3 native. | |
8 |
|
8 | |||
9 | """Code to build Mercurial WiX installer.""" |
|
9 | """Code to build Mercurial WiX installer.""" | |
10 |
|
10 | |||
11 | import argparse |
|
11 | import argparse | |
12 | import os |
|
12 | import os | |
13 | import pathlib |
|
13 | import pathlib | |
14 | import sys |
|
14 | import sys | |
15 |
|
15 | |||
16 |
|
16 | |||
17 | if __name__ == '__main__': |
|
17 | if __name__ == '__main__': | |
18 | parser = argparse.ArgumentParser() |
|
18 | parser = argparse.ArgumentParser() | |
19 |
|
19 | |||
20 | parser.add_argument('--name', |
|
20 | parser.add_argument('--name', | |
21 | help='Application name', |
|
21 | help='Application name', | |
22 | default='Mercurial') |
|
22 | default='Mercurial') | |
23 | parser.add_argument('--python', |
|
23 | parser.add_argument('--python', | |
24 | help='Path to Python executable to use', |
|
24 | help='Path to Python executable to use', | |
25 | required=True) |
|
25 | required=True) | |
26 | parser.add_argument('--sign-sn', |
|
26 | parser.add_argument('--sign-sn', | |
27 | help='Subject name (or fragment thereof) of certificate ' |
|
27 | help='Subject name (or fragment thereof) of certificate ' | |
28 | 'to use for signing') |
|
28 | 'to use for signing') | |
29 | parser.add_argument('--sign-cert', |
|
29 | parser.add_argument('--sign-cert', | |
30 | help='Path to certificate to use for signing') |
|
30 | help='Path to certificate to use for signing') | |
31 | parser.add_argument('--sign-password', |
|
31 | parser.add_argument('--sign-password', | |
32 | help='Password for signing certificate') |
|
32 | help='Password for signing certificate') | |
33 | parser.add_argument('--sign-timestamp-url', |
|
33 | parser.add_argument('--sign-timestamp-url', | |
34 | help='URL of timestamp server to use for signing') |
|
34 | help='URL of timestamp server to use for signing') | |
35 | parser.add_argument('--version', |
|
35 | parser.add_argument('--version', | |
36 | help='Version string to use') |
|
36 | help='Version string to use') | |
37 | parser.add_argument('--extra-packages-script', |
|
37 | parser.add_argument('--extra-packages-script', | |
38 | help=('Script to execute to include extra packages in ' |
|
38 | help=('Script to execute to include extra packages in ' | |
39 | 'py2exe binary.')) |
|
39 | 'py2exe binary.')) | |
40 | parser.add_argument('--extra-wxs', |
|
40 | parser.add_argument('--extra-wxs', | |
41 | help='CSV of path_to_wxs_file=working_dir_for_wxs_file') |
|
41 | help='CSV of path_to_wxs_file=working_dir_for_wxs_file') | |
42 | parser.add_argument('--extra-features', |
|
42 | parser.add_argument('--extra-features', | |
43 | help=('CSV of extra feature names to include ' |
|
43 | help=('CSV of extra feature names to include ' | |
44 | 'in the installer from the extra wxs files')) |
|
44 | 'in the installer from the extra wxs files')) | |
45 |
|
45 | |||
46 | args = parser.parse_args() |
|
46 | args = parser.parse_args() | |
47 |
|
47 | |||
48 | here = pathlib.Path(os.path.abspath(os.path.dirname(__file__))) |
|
48 | here = pathlib.Path(os.path.abspath(os.path.dirname(__file__))) | |
49 | source_dir = here.parent.parent.parent |
|
49 | source_dir = here.parent.parent.parent | |
50 |
|
50 | |||
51 | sys.path.insert(0, str(source_dir / 'contrib' / 'packaging')) |
|
51 | sys.path.insert(0, str(source_dir / 'contrib' / 'packaging')) | |
52 |
|
52 | |||
53 | from hgpackaging.wix import ( |
|
53 | from hgpackaging.wix import ( | |
54 | build_installer, |
|
54 | build_installer, | |
55 | build_signed_installer, |
|
55 | build_signed_installer, | |
56 | ) |
|
56 | ) | |
57 |
|
57 | |||
58 | fn = build_installer |
|
58 | fn = build_installer | |
59 | kwargs = { |
|
59 | kwargs = { | |
60 | 'source_dir': source_dir, |
|
60 | 'source_dir': source_dir, | |
61 | 'python_exe': pathlib.Path(args.python), |
|
61 | 'python_exe': pathlib.Path(args.python), | |
62 | 'version': args.version, |
|
62 | 'version': args.version, | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
|
65 | if not os.path.isabs(args.python): | |||
|
66 | raise Exception('--python arg must be an absolute path') | |||
|
67 | ||||
65 | if args.extra_packages_script: |
|
68 | if args.extra_packages_script: | |
66 | kwargs['extra_packages_script'] = args.extra_packages_script |
|
69 | kwargs['extra_packages_script'] = args.extra_packages_script | |
67 | if args.extra_wxs: |
|
70 | if args.extra_wxs: | |
68 | kwargs['extra_wxs'] = dict( |
|
71 | kwargs['extra_wxs'] = dict( | |
69 | thing.split("=") for thing in args.extra_wxs.split(',')) |
|
72 | thing.split("=") for thing in args.extra_wxs.split(',')) | |
70 | if args.extra_features: |
|
73 | if args.extra_features: | |
71 | kwargs['extra_features'] = args.extra_features.split(',') |
|
74 | kwargs['extra_features'] = args.extra_features.split(',') | |
72 |
|
75 | |||
73 | if args.sign_sn or args.sign_cert: |
|
76 | if args.sign_sn or args.sign_cert: | |
74 | fn = build_signed_installer |
|
77 | fn = build_signed_installer | |
75 | kwargs['name'] = args.name |
|
78 | kwargs['name'] = args.name | |
76 | kwargs['subject_name'] = args.sign_sn |
|
79 | kwargs['subject_name'] = args.sign_sn | |
77 | kwargs['cert_path'] = args.sign_cert |
|
80 | kwargs['cert_path'] = args.sign_cert | |
78 | kwargs['cert_password'] = args.sign_password |
|
81 | kwargs['cert_password'] = args.sign_password | |
79 | kwargs['timestamp_url'] = args.sign_timestamp_url |
|
82 | kwargs['timestamp_url'] = args.sign_timestamp_url | |
80 |
|
83 | |||
81 | fn(**kwargs) |
|
84 | fn(**kwargs) |
General Comments 0
You need to be logged in to leave comments.
Login now