##// END OF EJS Templates
packaging: remove hg.exe.local file...
Gregory Szorc -
r43917:24633444 default
parent child Browse files
Show More
@@ -1,159 +1,158 b''
1 1 # inno.py - Inno Setup functionality.
2 2 #
3 3 # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 # no-check-code because Python 3 native.
9 9
10 10 import os
11 11 import pathlib
12 12 import shutil
13 13 import subprocess
14 14
15 15 import jinja2
16 16
17 17 from .py2exe import (
18 18 build_py2exe,
19 19 stage_install,
20 20 )
21 21 from .util import find_vc_runtime_files
22 22
23 23 EXTRA_PACKAGES = {
24 24 'dulwich',
25 25 'keyring',
26 26 'pygments',
27 27 'win32ctypes',
28 28 }
29 29
30 30 PACKAGE_FILES_METADATA = {
31 31 'ReadMe.html': 'Flags: isreadme',
32 'hg.exe': "AfterInstall: Touch('{app}\\hg.exe.local')",
33 32 }
34 33
35 34
36 35 def build(
37 36 source_dir: pathlib.Path,
38 37 build_dir: pathlib.Path,
39 38 python_exe: pathlib.Path,
40 39 iscc_exe: pathlib.Path,
41 40 version=None,
42 41 ):
43 42 """Build the Inno installer.
44 43
45 44 Build files will be placed in ``build_dir``.
46 45
47 46 py2exe's setup.py doesn't use setuptools. It doesn't have modern logic
48 47 for finding the Python 2.7 toolchain. So, we require the environment
49 48 to already be configured with an active toolchain.
50 49 """
51 50 if not iscc_exe.exists():
52 51 raise Exception('%s does not exist' % iscc_exe)
53 52
54 53 vc_x64 = r'\x64' in os.environ.get('LIB', '')
55 54 arch = 'x64' if vc_x64 else 'x86'
56 55 inno_source_dir = source_dir / 'contrib' / 'packaging' / 'inno'
57 56 inno_build_dir = build_dir / ('inno-%s' % arch)
58 57 staging_dir = inno_build_dir / 'stage'
59 58
60 59 requirements_txt = (
61 60 source_dir / 'contrib' / 'packaging' / 'inno' / 'requirements.txt'
62 61 )
63 62
64 63 inno_build_dir.mkdir(parents=True, exist_ok=True)
65 64
66 65 build_py2exe(
67 66 source_dir,
68 67 build_dir,
69 68 python_exe,
70 69 'inno',
71 70 requirements_txt,
72 71 extra_packages=EXTRA_PACKAGES,
73 72 )
74 73
75 74 # Purge the staging directory for every build so packaging is
76 75 # pristine.
77 76 if staging_dir.exists():
78 77 print('purging %s' % staging_dir)
79 78 shutil.rmtree(staging_dir)
80 79
81 80 # Now assemble all the packaged files into the staging directory.
82 81 stage_install(source_dir, staging_dir)
83 82
84 83 # hg.exe depends on VC9 runtime DLLs. Copy those into place.
85 84 for f in find_vc_runtime_files(vc_x64):
86 85 if f.name.endswith('.manifest'):
87 86 basename = 'Microsoft.VC90.CRT.manifest'
88 87 else:
89 88 basename = f.name
90 89
91 90 dest_path = staging_dir / basename
92 91
93 92 print('copying %s to %s' % (f, dest_path))
94 93 shutil.copyfile(f, dest_path)
95 94
96 95 # The final package layout is simply a mirror of the staging directory.
97 96 package_files = []
98 97 for root, dirs, files in os.walk(staging_dir):
99 98 dirs.sort()
100 99
101 100 root = pathlib.Path(root)
102 101
103 102 for f in sorted(files):
104 103 full = root / f
105 104 rel = full.relative_to(staging_dir)
106 105 if str(rel.parent) == '.':
107 106 dest_dir = '{app}'
108 107 else:
109 108 dest_dir = '{app}\\%s' % rel.parent
110 109
111 110 package_files.append(
112 111 {
113 112 'source': rel,
114 113 'dest_dir': dest_dir,
115 114 'metadata': PACKAGE_FILES_METADATA.get(str(rel), None),
116 115 }
117 116 )
118 117
119 118 print('creating installer')
120 119
121 120 # Install Inno files by rendering a template.
122 121 jinja_env = jinja2.Environment(
123 122 loader=jinja2.FileSystemLoader(str(inno_source_dir)),
124 123 # Need to change these to prevent conflict with Inno Setup.
125 124 comment_start_string='{##',
126 125 comment_end_string='##}',
127 126 )
128 127
129 128 try:
130 129 template = jinja_env.get_template('mercurial.iss')
131 130 except jinja2.TemplateSyntaxError as e:
132 131 raise Exception(
133 132 'template syntax error at %s:%d: %s'
134 133 % (e.name, e.lineno, e.message,)
135 134 )
136 135
137 136 content = template.render(package_files=package_files)
138 137
139 138 with (inno_build_dir / 'mercurial.iss').open('w', encoding='utf-8') as fh:
140 139 fh.write(content)
141 140
142 141 # Copy additional files used by Inno.
143 142 for p in ('mercurial.ico', 'postinstall.txt'):
144 143 shutil.copyfile(
145 144 source_dir / 'contrib' / 'win32' / p, inno_build_dir / p
146 145 )
147 146
148 147 args = [str(iscc_exe)]
149 148
150 149 if vc_x64:
151 150 args.append('/dARCH=x64')
152 151
153 152 if version:
154 153 args.append('/dVERSION=%s' % version)
155 154
156 155 args.append('/Odist')
157 156 args.append(str(inno_build_dir / 'mercurial.iss'))
158 157
159 158 subprocess.run(args, cwd=str(source_dir), check=True)
@@ -1,99 +1,98 b''
1 1 ; Script generated by the Inno Setup Script Wizard.
2 2 ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
3 3
4 4 #ifndef VERSION
5 5 #define FileHandle
6 6 #define FileLine
7 7 #define VERSION = "unknown"
8 8 #if FileHandle = FileOpen(SourcePath + "\..\..\mercurial\__version__.py")
9 9 #expr FileLine = FileRead(FileHandle)
10 10 #expr FileLine = FileRead(FileHandle)
11 11 #define VERSION = Copy(FileLine, Pos('"', FileLine)+1, Len(FileLine)-Pos('"', FileLine)-1)
12 12 #endif
13 13 #if FileHandle
14 14 #expr FileClose(FileHandle)
15 15 #endif
16 16 #pragma message "Detected Version: " + VERSION
17 17 #endif
18 18
19 19 #ifndef ARCH
20 20 #define ARCH = "x86"
21 21 #endif
22 22
23 23 [Setup]
24 24 AppCopyright=Copyright 2005-2019 Matt Mackall and others
25 25 AppName=Mercurial
26 26 AppVersion={#VERSION}
27 27 #if ARCH == "x64"
28 28 AppVerName=Mercurial {#VERSION} (64-bit)
29 29 OutputBaseFilename=Mercurial-{#VERSION}-x64
30 30 ArchitecturesAllowed=x64
31 31 ArchitecturesInstallIn64BitMode=x64
32 32 #else
33 33 AppVerName=Mercurial {#VERSION}
34 34 OutputBaseFilename=Mercurial-{#VERSION}
35 35 #endif
36 36 InfoAfterFile=../postinstall.txt
37 37 LicenseFile=Copying.txt
38 38 ShowLanguageDialog=yes
39 39 AppPublisher=Matt Mackall and others
40 40 AppPublisherURL=https://mercurial-scm.org/
41 41 AppSupportURL=https://mercurial-scm.org/
42 42 AppUpdatesURL=https://mercurial-scm.org/
43 43 {{ 'AppID={{4B95A5F1-EF59-4B08-BED8-C891C46121B3}' }}
44 44 AppContact=mercurial@mercurial-scm.org
45 45 DefaultDirName={pf}\Mercurial
46 46 SourceDir=stage
47 47 VersionInfoDescription=Mercurial distributed SCM (version {#VERSION})
48 48 VersionInfoCopyright=Copyright 2005-2019 Matt Mackall and others
49 49 VersionInfoCompany=Matt Mackall and others
50 50 InternalCompressLevel=max
51 51 SolidCompression=true
52 52 SetupIconFile=../mercurial.ico
53 53 AllowNoIcons=true
54 54 DefaultGroupName=Mercurial
55 55 PrivilegesRequired=none
56 56 ChangesEnvironment=true
57 57
58 58 [Files]
59 59 {% for entry in package_files -%}
60 60 Source: {{ entry.source }}; DestDir: {{ entry.dest_dir }}
61 61 {%- if entry.metadata %}; {{ entry.metadata }}{% endif %}
62 62 {% endfor %}
63 63
64 64 [INI]
65 65 Filename: {app}\Mercurial.url; Section: InternetShortcut; Key: URL; String: https://mercurial-scm.org/
66 66 Filename: {app}\default.d\editor.rc; Section: ui; Key: editor; String: notepad
67 67
68 68 [UninstallDelete]
69 69 Type: files; Name: {app}\Mercurial.url
70 70 Type: filesandordirs; Name: {app}\default.d
71 Type: files; Name: "{app}\hg.exe.local"
72 71
73 72 [Icons]
74 73 Name: {group}\Uninstall Mercurial; Filename: {uninstallexe}
75 74 Name: {group}\Mercurial Command Reference; Filename: {app}\Docs\hg.1.html
76 75 Name: {group}\Mercurial Configuration Files; Filename: {app}\Docs\hgrc.5.html
77 76 Name: {group}\Mercurial Ignore Files; Filename: {app}\Docs\hgignore.5.html
78 77 Name: {group}\Mercurial Web Site; Filename: {app}\Mercurial.url
79 78
80 79 [Tasks]
81 80 Name: modifypath; Description: Add the installation path to the search path; Flags: unchecked
82 81
83 82 [Code]
84 83 procedure Touch(fn: String);
85 84 begin
86 85 SaveStringToFile(ExpandConstant(fn), '', False);
87 86 end;
88 87
89 88 const
90 89 ModPathName = 'modifypath';
91 90 ModPathType = 'user';
92 91
93 92 function ModPathDir(): TArrayOfString;
94 93 begin
95 94 setArrayLength(Result, 1)
96 95 Result[0] := ExpandConstant('{app}');
97 96 end;
98 97
99 98 {% include 'modpath.iss' %}
General Comments 0
You need to be logged in to leave comments. Login now