Show More
@@ -0,0 +1,219 b'' | |||
|
1 | // ---------------------------------------------------------------------------- | |
|
2 | // | |
|
3 | // Inno Setup Ver: 5.4.2 | |
|
4 | // Script Version: 1.4.2 | |
|
5 | // Author: Jared Breland <jbreland@legroom.net> | |
|
6 | // Homepage: http://www.legroom.net/software | |
|
7 | // License: GNU Lesser General Public License (LGPL), version 3 | |
|
8 | // http://www.gnu.org/licenses/lgpl.html | |
|
9 | // | |
|
10 | // Script Function: | |
|
11 | // Allow modification of environmental path directly from Inno Setup installers | |
|
12 | // | |
|
13 | // Instructions: | |
|
14 | // Copy modpath.iss to the same directory as your setup script | |
|
15 | // | |
|
16 | // Add this statement to your [Setup] section | |
|
17 | // ChangesEnvironment=true | |
|
18 | // | |
|
19 | // Add this statement to your [Tasks] section | |
|
20 | // You can change the Description or Flags | |
|
21 | // You can change the Name, but it must match the ModPathName setting below | |
|
22 | // Name: modifypath; Description: &Add application directory to your environmental path; Flags: unchecked | |
|
23 | // | |
|
24 | // Add the following to the end of your [Code] section | |
|
25 | // ModPathName defines the name of the task defined above | |
|
26 | // ModPathType defines whether the 'user' or 'system' path will be modified; | |
|
27 | // this will default to user if anything other than system is set | |
|
28 | // setArrayLength must specify the total number of dirs to be added | |
|
29 | // Result[0] contains first directory, Result[1] contains second, etc. | |
|
30 | // const | |
|
31 | // ModPathName = 'modifypath'; | |
|
32 | // ModPathType = 'user'; | |
|
33 | // | |
|
34 | // function ModPathDir(): TArrayOfString; | |
|
35 | // begin | |
|
36 | // setArrayLength(Result, 1); | |
|
37 | // Result[0] := ExpandConstant('{app}'); | |
|
38 | // end; | |
|
39 | // #include "modpath.iss" | |
|
40 | // ---------------------------------------------------------------------------- | |
|
41 | ||
|
42 | procedure ModPath(); | |
|
43 | var | |
|
44 | oldpath: String; | |
|
45 | newpath: String; | |
|
46 | updatepath: Boolean; | |
|
47 | pathArr: TArrayOfString; | |
|
48 | aExecFile: String; | |
|
49 | aExecArr: TArrayOfString; | |
|
50 | i, d: Integer; | |
|
51 | pathdir: TArrayOfString; | |
|
52 | regroot: Integer; | |
|
53 | regpath: String; | |
|
54 | ||
|
55 | begin | |
|
56 | // Get constants from main script and adjust behavior accordingly | |
|
57 | // ModPathType MUST be 'system' or 'user'; force 'user' if invalid | |
|
58 | if ModPathType = 'system' then begin | |
|
59 | regroot := HKEY_LOCAL_MACHINE; | |
|
60 | regpath := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'; | |
|
61 | end else begin | |
|
62 | regroot := HKEY_CURRENT_USER; | |
|
63 | regpath := 'Environment'; | |
|
64 | end; | |
|
65 | ||
|
66 | // Get array of new directories and act on each individually | |
|
67 | pathdir := ModPathDir(); | |
|
68 | for d := 0 to GetArrayLength(pathdir)-1 do begin | |
|
69 | updatepath := true; | |
|
70 | ||
|
71 | // Modify WinNT path | |
|
72 | if UsingWinNT() = true then begin | |
|
73 | ||
|
74 | // Get current path, split into an array | |
|
75 | RegQueryStringValue(regroot, regpath, 'Path', oldpath); | |
|
76 | oldpath := oldpath + ';'; | |
|
77 | i := 0; | |
|
78 | ||
|
79 | while (Pos(';', oldpath) > 0) do begin | |
|
80 | SetArrayLength(pathArr, i+1); | |
|
81 | pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath)-1); | |
|
82 | oldpath := Copy(oldpath, Pos(';', oldpath)+1, Length(oldpath)); | |
|
83 | i := i + 1; | |
|
84 | ||
|
85 | // Check if current directory matches app dir | |
|
86 | if pathdir[d] = pathArr[i-1] then begin | |
|
87 | // if uninstalling, remove dir from path | |
|
88 | if IsUninstaller() = true then begin | |
|
89 | continue; | |
|
90 | // if installing, flag that dir already exists in path | |
|
91 | end else begin | |
|
92 | updatepath := false; | |
|
93 | end; | |
|
94 | end; | |
|
95 | ||
|
96 | // Add current directory to new path | |
|
97 | if i = 1 then begin | |
|
98 | newpath := pathArr[i-1]; | |
|
99 | end else begin | |
|
100 | newpath := newpath + ';' + pathArr[i-1]; | |
|
101 | end; | |
|
102 | end; | |
|
103 | ||
|
104 | // Append app dir to path if not already included | |
|
105 | if (IsUninstaller() = false) AND (updatepath = true) then | |
|
106 | newpath := newpath + ';' + pathdir[d]; | |
|
107 | ||
|
108 | // Write new path | |
|
109 | RegWriteStringValue(regroot, regpath, 'Path', newpath); | |
|
110 | ||
|
111 | // Modify Win9x path | |
|
112 | end else begin | |
|
113 | ||
|
114 | // Convert to shortened dirname | |
|
115 | pathdir[d] := GetShortName(pathdir[d]); | |
|
116 | ||
|
117 | // If autoexec.bat exists, check if app dir already exists in path | |
|
118 | aExecFile := 'C:\AUTOEXEC.BAT'; | |
|
119 | if FileExists(aExecFile) then begin | |
|
120 | LoadStringsFromFile(aExecFile, aExecArr); | |
|
121 | for i := 0 to GetArrayLength(aExecArr)-1 do begin | |
|
122 | if IsUninstaller() = false then begin | |
|
123 | // If app dir already exists while installing, skip add | |
|
124 | if (Pos(pathdir[d], aExecArr[i]) > 0) then | |
|
125 | updatepath := false; | |
|
126 | break; | |
|
127 | end else begin | |
|
128 | // If app dir exists and = what we originally set, then delete at uninstall | |
|
129 | if aExecArr[i] = 'SET PATH=%PATH%;' + pathdir[d] then | |
|
130 | aExecArr[i] := ''; | |
|
131 | end; | |
|
132 | end; | |
|
133 | end; | |
|
134 | ||
|
135 | // If app dir not found, or autoexec.bat didn't exist, then (create and) append to current path | |
|
136 | if (IsUninstaller() = false) AND (updatepath = true) then begin | |
|
137 | SaveStringToFile(aExecFile, #13#10 + 'SET PATH=%PATH%;' + pathdir[d], True); | |
|
138 | ||
|
139 | // If uninstalling, write the full autoexec out | |
|
140 | end else begin | |
|
141 | SaveStringsToFile(aExecFile, aExecArr, False); | |
|
142 | end; | |
|
143 | end; | |
|
144 | end; | |
|
145 | end; | |
|
146 | ||
|
147 | // Split a string into an array using passed delimeter | |
|
148 | procedure MPExplode(var Dest: TArrayOfString; Text: String; Separator: String); | |
|
149 | var | |
|
150 | i: Integer; | |
|
151 | begin | |
|
152 | i := 0; | |
|
153 | repeat | |
|
154 | SetArrayLength(Dest, i+1); | |
|
155 | if Pos(Separator,Text) > 0 then begin | |
|
156 | Dest[i] := Copy(Text, 1, Pos(Separator, Text)-1); | |
|
157 | Text := Copy(Text, Pos(Separator,Text) + Length(Separator), Length(Text)); | |
|
158 | i := i + 1; | |
|
159 | end else begin | |
|
160 | Dest[i] := Text; | |
|
161 | Text := ''; | |
|
162 | end; | |
|
163 | until Length(Text)=0; | |
|
164 | end; | |
|
165 | ||
|
166 | ||
|
167 | procedure CurStepChanged(CurStep: TSetupStep); | |
|
168 | var | |
|
169 | taskname: String; | |
|
170 | begin | |
|
171 | taskname := ModPathName; | |
|
172 | if CurStep = ssPostInstall then | |
|
173 | if IsTaskSelected(taskname) then | |
|
174 | ModPath(); | |
|
175 | end; | |
|
176 | ||
|
177 | procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); | |
|
178 | var | |
|
179 | aSelectedTasks: TArrayOfString; | |
|
180 | i: Integer; | |
|
181 | taskname: String; | |
|
182 | regpath: String; | |
|
183 | regstring: String; | |
|
184 | appid: String; | |
|
185 | begin | |
|
186 | // only run during actual uninstall | |
|
187 | if CurUninstallStep = usUninstall then begin | |
|
188 | // get list of selected tasks saved in registry at install time | |
|
189 | appid := '{#emit SetupSetting("AppId")}'; | |
|
190 | if appid = '' then appid := '{#emit SetupSetting("AppName")}'; | |
|
191 | regpath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\'+appid+'_is1'); | |
|
192 | RegQueryStringValue(HKLM, regpath, 'Inno Setup: Selected Tasks', regstring); | |
|
193 | if regstring = '' then RegQueryStringValue(HKCU, regpath, 'Inno Setup: Selected Tasks', regstring); | |
|
194 | ||
|
195 | // check each task; if matches modpath taskname, trigger patch removal | |
|
196 | if regstring <> '' then begin | |
|
197 | taskname := ModPathName; | |
|
198 | MPExplode(aSelectedTasks, regstring, ','); | |
|
199 | if GetArrayLength(aSelectedTasks) > 0 then begin | |
|
200 | for i := 0 to GetArrayLength(aSelectedTasks)-1 do begin | |
|
201 | if comparetext(aSelectedTasks[i], taskname) = 0 then | |
|
202 | ModPath(); | |
|
203 | end; | |
|
204 | end; | |
|
205 | end; | |
|
206 | end; | |
|
207 | end; | |
|
208 | ||
|
209 | function NeedRestart(): Boolean; | |
|
210 | var | |
|
211 | taskname: String; | |
|
212 | begin | |
|
213 | taskname := ModPathName; | |
|
214 | if IsTaskSelected(taskname) and not UsingWinNT() then begin | |
|
215 | Result := True; | |
|
216 | end else begin | |
|
217 | Result := False; | |
|
218 | end; | |
|
219 | end; |
@@ -53,6 +53,7 b' SetupIconFile=contrib\\win32\\mercurial.ic' | |||
|
53 | 53 | AllowNoIcons=true |
|
54 | 54 | DefaultGroupName=Mercurial |
|
55 | 55 | PrivilegesRequired=none |
|
56 | ChangesEnvironment=true | |
|
56 | 57 | |
|
57 | 58 | [Files] |
|
58 | 59 | Source: contrib\mercurial.el; DestDir: {app}/Contrib |
@@ -80,7 +81,6 b' Source: dist\\python*.dll; Destdir: {app}' | |||
|
80 | 81 | Source: dist\msvc*.dll; DestDir: {app}; Flags: skipifsourcedoesntexist |
|
81 | 82 | Source: dist\Microsoft.VC*.CRT.manifest; DestDir: {app}; Flags: skipifsourcedoesntexist |
|
82 | 83 | Source: dist\lib\library.zip; DestDir: {app}\lib |
|
83 | Source: dist\add_path.exe; DestDir: {app} | |
|
84 | 84 | Source: doc\*.html; DestDir: {app}\Docs |
|
85 | 85 | Source: doc\style.css; DestDir: {app}\Docs |
|
86 | 86 | Source: mercurial\help\*.txt; DestDir: {app}\help |
@@ -107,14 +107,22 b' Name: {group}\\Mercurial Configuration Fi' | |||
|
107 | 107 | Name: {group}\Mercurial Ignore Files; Filename: {app}\Docs\hgignore.5.html |
|
108 | 108 | Name: {group}\Mercurial Web Site; Filename: {app}\Mercurial.url |
|
109 | 109 | |
|
110 | [Run] | |
|
111 |
|
|
|
112 | ||
|
113 | [UninstallRun] | |
|
114 | Filename: "{app}\add_path.exe"; Parameters: "/del {app}" | |
|
110 | [Tasks] | |
|
111 | Name: modifypath; Description: Add the installation path to the search path; Flags: unchecked | |
|
115 | 112 | |
|
116 | 113 | [Code] |
|
117 | 114 | procedure Touch(fn: String); |
|
118 | 115 | begin |
|
119 | 116 | SaveStringToFile(ExpandConstant(fn), '', False); |
|
120 | 117 | end; |
|
118 | ||
|
119 | const | |
|
120 | ModPathName = 'modifypath'; | |
|
121 | ModPathType = 'user'; | |
|
122 | ||
|
123 | function ModPathDir(): TArrayOfString; | |
|
124 | begin | |
|
125 | setArrayLength(Result, 1) | |
|
126 | Result[0] := ExpandConstant('{app}'); | |
|
127 | end; | |
|
128 | #include "modpath.iss" |
@@ -40,9 +40,6 b' matching the mercurial version you want ' | |||
|
40 | 40 | ISTool - optional |
|
41 | 41 | http://www.istool.org/default.aspx/ |
|
42 | 42 | |
|
43 | add_path (you need only add_path.exe in the zip file) | |
|
44 | http://www.barisione.org/apps.html#add_path | |
|
45 | ||
|
46 | 43 | Docutils |
|
47 | 44 | http://docutils.sourceforge.net/ |
|
48 | 45 | |
@@ -76,7 +73,7 b' Building instructions with MSVC 2008 Exp' | |||
|
76 | 73 | "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_amd64 |
|
77 | 74 | python setup.py py2exe -b 3 |
|
78 | 75 | |
|
79 |
Copy |
|
|
76 | Copy cacert.pem files into the dist directory that just got created. | |
|
80 | 77 | |
|
81 | 78 | If you are using Python 2.6 or later, or if you are using MSVC 2008 to compile |
|
82 | 79 | mercurial, you must include the C runtime libraries in the installer. To do so, |
@@ -99,13 +96,13 b' Before building the installer, you have ' | |||
|
99 | 96 | cd .. |
|
100 | 97 | |
|
101 | 98 | If you use ISTool, you open the |
|
102 | C:\hg\hg-release\contrib\packaging\inno\mercurial.iss | |
|
99 | C:\hg\hg-release\contrib\packaging\inno-installer\mercurial.iss | |
|
103 | 100 | file and type Ctrl-F9 to compile the installer file. |
|
104 | 101 | |
|
105 | 102 | Otherwise you run the Inno Setup compiler. Assuming it's in the path |
|
106 | 103 | you should execute: |
|
107 | 104 | |
|
108 | iscc contrib\packaging\inno\mercurial.iss /dVERSION=foo | |
|
105 | iscc contrib\packaging\inno-installer\mercurial.iss /dVERSION=foo | |
|
109 | 106 | |
|
110 | 107 | Where 'foo' is the version number you would like to see in the |
|
111 | 108 | 'Add/Remove Applications' tool. The installer will be placed into |
@@ -115,7 +112,7 b' installer will retrieve the version info' | |||
|
115 | 112 | |
|
116 | 113 | If you want to build an installer for a 64-bit mercurial, add /dARCH=x64 to |
|
117 | 114 | your command line: |
|
118 | iscc contrib\packaging\inno\mercurial.iss /dARCH=x64 | |
|
115 | iscc contrib\packaging\inno-installer\mercurial.iss /dARCH=x64 | |
|
119 | 116 | |
|
120 | 117 | To automate the steps above you may want to create a batchfile based on the |
|
121 | 118 | following (MinGW build chain): |
@@ -126,6 +123,6 b' following (MinGW build chain):' | |||
|
126 | 123 | cd doc |
|
127 | 124 | mingw32-make html |
|
128 | 125 | cd .. |
|
129 | iscc contrib\packaging\inno\mercurial.iss /dVERSION=snapshot | |
|
126 | iscc contrib\packaging\inno-installer\mercurial.iss /dVERSION=snapshot | |
|
130 | 127 | |
|
131 | 128 | and run it from the root of the hg repository (c:\hg\hg-release). |
General Comments 0
You need to be logged in to leave comments.
Login now