1 |
; NSIS script to create an ASCEND binary installer. |
2 |
; by John Pye, 2006. |
3 |
; |
4 |
; Based on example2.nsi from the NSIS distribution. |
5 |
; |
6 |
; This script is based on example1.nsi, but it remembers the directory, |
7 |
; has uninstall support and (optionally) installs start menu shortcuts. |
8 |
; |
9 |
; It will install example2.nsi into a directory that the user selects, |
10 |
|
11 |
;-------------------------------- |
12 |
|
13 |
; The name of the installer |
14 |
Name "ASCEND" |
15 |
|
16 |
!include LogicLib.nsh |
17 |
|
18 |
; The file to write |
19 |
!ifdef OUTFILE |
20 |
OutFile ${OUTFILE}.exe |
21 |
!else |
22 |
OutFile ascend-setup.exe |
23 |
!endif |
24 |
|
25 |
|
26 |
;SetCompressor /FINAL zlib |
27 |
SetCompressor /SOLID lzma |
28 |
|
29 |
; The default installation directory |
30 |
InstallDir $PROGRAMFILES\ASCEND |
31 |
|
32 |
; Registry key to check for directory (so if you install again, it will |
33 |
; overwrite the old one automatically) |
34 |
InstallDirRegKey HKLM "Software\ASCEND" "Install_Dir" |
35 |
|
36 |
;-------------------------------- |
37 |
|
38 |
; Pages |
39 |
|
40 |
Page components |
41 |
Page directory |
42 |
Page instfiles |
43 |
|
44 |
UninstPage uninstConfirm |
45 |
UninstPage instfiles |
46 |
|
47 |
;-------------------------------- |
48 |
|
49 |
Var /GLOBAL PYOK |
50 |
Var /GLOBAL PYPATH |
51 |
Var /GLOBAL GTKOK |
52 |
Var /GLOBAL GTKPATH |
53 |
Var /GLOBAL GLADEOK |
54 |
Var /GLOBAL GLADEPATH |
55 |
Var /GLOBAL PYINSTALLED |
56 |
Var /GLOBAL TCLOK |
57 |
Var /GLOBAL TCLPATH |
58 |
Var /GLOBAL TCLINSTALLED |
59 |
|
60 |
Function .onInit |
61 |
StrCpy $PYINSTALLED "" |
62 |
StrCpy $TCLINSTALLED "" |
63 |
|
64 |
Call DetectPython |
65 |
Pop $PYOK |
66 |
Pop $PYPATH |
67 |
|
68 |
Call DetectGTK |
69 |
Pop $GTKOK |
70 |
Pop $GTKPATH |
71 |
|
72 |
Call DetectGlade |
73 |
Pop $GLADEOK |
74 |
Pop $GLADEPATH |
75 |
|
76 |
Call DetectTcl |
77 |
Pop $TCLOK |
78 |
Pop $TCLPATH |
79 |
|
80 |
FunctionEnd |
81 |
|
82 |
|
83 |
; The stuff to install |
84 |
Section "ASCEND (required)" |
85 |
SectionIn RO |
86 |
|
87 |
DetailPrint "--- COMMON FILES ---" |
88 |
|
89 |
; Set output path to the installation directory. |
90 |
SetOutPath $INSTDIR |
91 |
File "..\ascend.dll" |
92 |
File "..\ascend-config" |
93 |
|
94 |
; Model Library |
95 |
SetOutPath $INSTDIR\models |
96 |
File /r /x .svn "..\models\*.a4*" |
97 |
File /r /x .svn "..\models\*.tcl" |
98 |
File /r /x .svn "..\models\*.dll" ; extension modules |
99 |
File /r /x .svn "..\models\*.py"; python modules |
100 |
|
101 |
SetOutPath $INSTDIR |
102 |
File "Makefile.bt" |
103 |
File "ascend.syn" |
104 |
|
105 |
${If} ${FileExists} "$APPDATA\.ascend.ini" |
106 |
MessageBox MB_OK "The '$APPDATA\.ascend.ini' is NOT being updated. Manually delete this file if ASCEND doesn't behave as expected." |
107 |
${Else} |
108 |
; Set 'librarypath' in .ascend.ini |
109 |
WriteINIstr $APPDATA\.ascend.ini Directories librarypath "$DOCUMENTS\ascdata;$INSTDIR\models" |
110 |
${EndIf} |
111 |
|
112 |
; Write the installation path into the registry |
113 |
WriteRegStr HKLM SOFTWARE\ASCEND "Install_Dir" "$INSTDIR" |
114 |
|
115 |
; Write the uninstall keys for Windows |
116 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "DisplayName" "ASCEND Simulation Environment" |
117 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "UninstallString" '"$INSTDIR\uninstall.exe"' |
118 |
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoModify" 1 |
119 |
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoRepair" 1 |
120 |
WriteUninstaller "uninstall.exe" |
121 |
|
122 |
; Write file locations to the registry for access from ascend-config |
123 |
WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_LIB" "$INSTDIR" |
124 |
WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_BIN" "$INSTDIR" |
125 |
WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_INCLUDE" "$INSTDIR\include" |
126 |
WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_ASCDATA" "$INSTDIR" |
127 |
WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_MODELS" "$INSTDIR\models" |
128 |
|
129 |
; Create 'ascend-config.bat' batch file for launching the python script 'ascend-config'. |
130 |
ClearErrors |
131 |
FileOpen $0 $INSTDIR\ascend-config.bat w |
132 |
IfErrors ascendconfigerror |
133 |
FileWrite $0 "@echo off" |
134 |
FileWriteByte $0 "13" |
135 |
FileWriteByte $0 "10" |
136 |
FileWrite $0 "set PATH=$PYPATH;$GTKPATH" |
137 |
FileWriteByte $0 "13" |
138 |
FileWriteByte $0 "10" |
139 |
FileWrite $0 "cd " |
140 |
FileWrite $0 $INSTDIR |
141 |
FileWriteByte $0 "13" |
142 |
FileWriteByte $0 "10" |
143 |
FileWrite $0 "$PYPATH\python " |
144 |
FileWriteByte $0 "34" |
145 |
FileWrite $0 "$INSTDIR\ascend-config" |
146 |
FileWriteByte $0 "34" |
147 |
FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8" |
148 |
FileWriteByte $0 "13" |
149 |
FileWriteByte $0 "10" |
150 |
|
151 |
FileClose $0 |
152 |
|
153 |
Return |
154 |
ascendconfigerror: |
155 |
MessageBox MB_OK "The 'ascend-config.bat' file was not installed properly; problems writing to that file." |
156 |
|
157 |
SectionEnd |
158 |
|
159 |
;-------------------------------- |
160 |
|
161 |
Section "PyGTK GUI" |
162 |
${If} $PYOK == 'OK' |
163 |
${If} $GTKOK == 'OK' |
164 |
${If} $GLADEOK == 'OK' |
165 |
;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH" |
166 |
|
167 |
DetailPrint "--- PYTHON INTERFACE ---" |
168 |
|
169 |
; Set output path to the installation directory. |
170 |
SetOutPath $INSTDIR |
171 |
|
172 |
; Python interface |
173 |
File "_ascpy.dll" |
174 |
File "*.py" |
175 |
SetOutPath $INSTDIR\glade |
176 |
File "glade\*.glade" |
177 |
File "glade\*.png" |
178 |
|
179 |
; Create 'ascend.bat' launcher for PyGTK interface |
180 |
ClearErrors |
181 |
FileOpen $0 $INSTDIR\ascend.bat w |
182 |
IfErrors pydone |
183 |
FileWrite $0 "@echo off" |
184 |
FileWriteByte $0 "13" |
185 |
FileWriteByte $0 "10" |
186 |
FileWrite $0 "set PATH=$PYPATH;$GTKPATH" |
187 |
FileWriteByte $0 "13" |
188 |
FileWriteByte $0 "10" |
189 |
FileWrite $0 "cd " |
190 |
FileWrite $0 $INSTDIR |
191 |
FileWriteByte $0 "13" |
192 |
FileWriteByte $0 "10" |
193 |
FileWrite $0 "$PYPATH\python gtkbrowser.py --pygtk-assets=" |
194 |
FileWriteByte $0 "34" |
195 |
FileWrite $0 "$INSTDIR\glade" |
196 |
FileWriteByte $0 "34" |
197 |
FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8" |
198 |
FileWriteByte $0 "13" |
199 |
FileWriteByte $0 "10" |
200 |
|
201 |
FileClose $0 |
202 |
|
203 |
StrCpy $PYINSTALLED "1" |
204 |
WriteRegDWORD HKLM "SOFTWARE\ASCEND" "Python" 1 |
205 |
${Else} |
206 |
MessageBox MB_OK "PyGTK GUI can not be installed, because Glade was not found on this system. If you do want to use the PyGTK GUI, please check the installation instructions ($GLADEPATH)" |
207 |
${EndIf} |
208 |
${Else} |
209 |
MessageBox MB_OK "PyGTK GUI can not be installed, because GTK+ 2.0 was not found on this system. If you do want to use the PyGTK GUI, please check the installation instructions ($GTKPATH)" |
210 |
${EndIf} |
211 |
${Else} |
212 |
MessageBox MB_OK "PyGTK GUI can not be installed, because Python was not found on this system. If you do want to use the PyGTK GUI, please check the installation instructions ($PYPATH)" |
213 |
${EndIf} |
214 |
Return |
215 |
|
216 |
pydone: |
217 |
MessageBox MB_OK "PyGTK GUI was not installed properly -- problems with creating ascend.bar" |
218 |
SectionEnd |
219 |
|
220 |
;--------------------------------- |
221 |
|
222 |
Section "Tcl/Tk GUI" |
223 |
|
224 |
${If} $TCLOK != 'OK' |
225 |
MessageBox MB_OK "Tck/Tk GUI can not be installed, because ActiveTcl was not found on this system. If do you want to use the Tcl/Tk GUI, please check the installation instructions ($TCLPATH)" |
226 |
${Else} |
227 |
DetailPrint "--- TCL/TK INTERFACE ---" |
228 |
SetOutPath $INSTDIR\tcltk |
229 |
File /r /x .svn "..\tcltk\TK\*" |
230 |
SetOutPath $INSTDIR |
231 |
File "..\tcltk\generic\interface\ascendtcl.dll" |
232 |
File "..\tcltk\generic\interface\ascend4.exe" |
233 |
|
234 |
StrCpy $TCLINSTALLED "!" |
235 |
WriteRegDWORD HKLM "SOFTWARE\ASCEND" "TclTk" 1 |
236 |
|
237 |
${EndIf} |
238 |
|
239 |
SectionEnd |
240 |
|
241 |
;--------------------------------- |
242 |
|
243 |
; Optional section (can be disabled by the user) |
244 |
Section "Start Menu Shortcuts" |
245 |
|
246 |
WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1 |
247 |
|
248 |
CreateDirectory "$SMPROGRAMS\ASCEND" |
249 |
CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 |
250 |
CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0 |
251 |
|
252 |
; Link to PyGTK GUI |
253 |
StrCmp $PYINSTALLED "" smdone smpython |
254 |
smpython: |
255 |
CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$INSTDIR\ascend.bat" "" "$INSTDIR\ascend.bat" 0 |
256 |
smdone: |
257 |
|
258 |
SectionEnd |
259 |
|
260 |
;------------------------------------------------------------------ |
261 |
; UNINSTALLER |
262 |
|
263 |
Section "Uninstall" |
264 |
|
265 |
;--- python components --- |
266 |
|
267 |
ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python" |
268 |
IntCmp $0 0 unnopython unpython |
269 |
|
270 |
unpython: |
271 |
DetailPrint "--- REMOVING PYTHON COMPONENTS ---" |
272 |
Delete $INSTDIR\_ascpy.dll |
273 |
Delete $INSTDIR\ascend.bat |
274 |
Delete $INSTDIR\*.py |
275 |
Delete $INSTDIR\glade\*.glade |
276 |
Delete $INSTDIR\glade\*.png |
277 |
RmDir $INSTDIR\glade |
278 |
|
279 |
unnopython: |
280 |
|
281 |
;--- tcl/tk components --- |
282 |
|
283 |
ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk" |
284 |
${If} $0 != 0 |
285 |
DetailPrint "--- REMOVING TCL/TK COMPONENTS ---" |
286 |
Delete $INSTDIR\ascendtcl.dll |
287 |
RMDir /r $INSTDIR\tcltk |
288 |
${EndIf} |
289 |
|
290 |
;--- start menu --- |
291 |
|
292 |
ReadRegDWORD $1 HKLM "SOFTWARE\ASCEND" "StartMenu" |
293 |
IntCmp $1 0 unnostart unstart |
294 |
unstart: |
295 |
; Remove shortcuts, if any |
296 |
DetailPrint "--- REMOVING START MENU SHORTCUTS ---" |
297 |
RmDir /r "$SMPROGRAMS\ASCEND" |
298 |
|
299 |
unnostart: |
300 |
|
301 |
;--- common components --- |
302 |
|
303 |
DetailPrint "--- REMOVING COMMON COMPONENTS ---" |
304 |
; Remove registry keys |
305 |
|
306 |
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" |
307 |
DeleteRegKey HKLM "SOFTWARE\ASCEND" |
308 |
|
309 |
; Remove files and uninstaller |
310 |
|
311 |
Delete $INSTDIR\ascend.dll |
312 |
Delete $INSTDIR\Makefile.bt |
313 |
Delete $INSTDIR\ascend.syn |
314 |
RMDir /r $INSTDIR\models |
315 |
|
316 |
; Remove directories used |
317 |
RMDir "$INSTDIR" |
318 |
|
319 |
SectionEnd |
320 |
|
321 |
;--------------------------------------------------------------------- |
322 |
; UTILITY ROUTINES |
323 |
|
324 |
Function DetectPython |
325 |
ReadRegStr $R6 HKCU "SOFTWARE\Python\PythonCore\2.4\InstallPath" "" |
326 |
${If} $R6 == '' |
327 |
ReadRegStr $R6 HKLM "SOFTWARE\Python\PythonCore\2.4\InstallPath" "" |
328 |
${If} $R6 == '' |
329 |
Push "No registry key found" |
330 |
Push "NOK" |
331 |
Return |
332 |
${EndIf} |
333 |
${EndIf} |
334 |
|
335 |
${If} ${FileExists} "$R6\python.exe" |
336 |
Push "$R6" |
337 |
Push "OK" |
338 |
${Else} |
339 |
Push "No python.exe found" |
340 |
Push "NOK" |
341 |
${EndIf} |
342 |
FunctionEnd |
343 |
|
344 |
;-------------------------------------------------------------------- |
345 |
; Prefer the current user's installation of GTK, fall back to the local machine |
346 |
|
347 |
Function DetectGTK |
348 |
ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath" |
349 |
${If} $R6 == '' |
350 |
ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath" |
351 |
${If} $R6 == '' |
352 |
Push "No GTK registry key found" |
353 |
Push "NOK" |
354 |
Return |
355 |
${EndIf} |
356 |
${EndIf} |
357 |
|
358 |
${If} ${FileExists} "$R6\libgtk-win32-2.0-0.dll" |
359 |
Push "$R6" |
360 |
Push "OK" |
361 |
${Else} |
362 |
Push "No libgtk-win32-2.0-0.dll found in'$R6'" |
363 |
Push "NOK" |
364 |
${EndIf} |
365 |
FunctionEnd |
366 |
|
367 |
;-------------------------------------------------------------------- |
368 |
; Prefer the current user's installation of GTK, fall back to the local machine |
369 |
|
370 |
Function DetectGlade |
371 |
ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath" |
372 |
${If} $R6 == '' |
373 |
ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath" |
374 |
${If} $R6 == '' |
375 |
Push "No GTK registry key found" |
376 |
Push "NOK" |
377 |
Return |
378 |
${EndIf} |
379 |
${EndIf} |
380 |
|
381 |
${If} ${FileExists} "$R6\libglade-2.0-0.dll" |
382 |
Push "$R6" |
383 |
Push "OK" |
384 |
${Else} |
385 |
Push "No libglade-2.0-0.dll found in'$R6'" |
386 |
Push "NOK" |
387 |
${EndIf} |
388 |
FunctionEnd |
389 |
|
390 |
;-------------------------------------------------------------------- |
391 |
|
392 |
Function DetectTcl |
393 |
ReadRegStr $R6 HKCU "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion" |
394 |
${If} $R6 == '' |
395 |
ReadRegStr $R6 HKLM "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion" |
396 |
${If} $R6 == '' |
397 |
Push "No 'CurrentVersion' registry key" |
398 |
Push "NOK" |
399 |
Return |
400 |
${Else} |
401 |
StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6" |
402 |
ReadRegStr $R8 HKLM $R7 "" |
403 |
${EndIf} |
404 |
${Else} |
405 |
StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6" |
406 |
ReadRegStr $R8 HKCU $R7 "" |
407 |
${EndIf} |
408 |
|
409 |
${If} $R8 == '' |
410 |
Push "No value for $R7" |
411 |
Push "NOK" |
412 |
${Else} |
413 |
Push "$R8\bin" |
414 |
Push "OK" |
415 |
${EndIf} |
416 |
FunctionEnd |