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 |
; Set 'librarypath' in .ascend.ini |
106 |
WriteINIstr $APPDATA\.ascend.ini Directories librarypath "$DOCUMENTS\ascdata;$INSTDIR\models" |
107 |
|
108 |
; Write the installation path into the registry |
109 |
WriteRegStr HKLM SOFTWARE\ASCEND "Install_Dir" "$INSTDIR" |
110 |
|
111 |
; Write the uninstall keys for Windows |
112 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "DisplayName" "ASCEND Simulation Environment" |
113 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "UninstallString" '"$INSTDIR\uninstall.exe"' |
114 |
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoModify" 1 |
115 |
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoRepair" 1 |
116 |
WriteUninstaller "uninstall.exe" |
117 |
|
118 |
; Write file locations to the registry for access from ascend-config |
119 |
WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_LIB" "$INSTDIR" |
120 |
WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_BIN" "$INSTDIR" |
121 |
WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_INCLUDE" "$INSTDIR\include" |
122 |
WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_ASCDATA" "$INSTDIR" |
123 |
WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_MODELS" "$INSTDIR\models" |
124 |
|
125 |
; Create 'ascend-config.bat' batch file for launching the python script 'ascend-config'. |
126 |
ClearErrors |
127 |
FileOpen $0 $INSTDIR\ascend-config.bat w |
128 |
IfErrors ascendconfigerror |
129 |
FileWrite $0 "@echo off" |
130 |
FileWriteByte $0 "13" |
131 |
FileWriteByte $0 "10" |
132 |
FileWrite $0 "set PATH=$PYPATH;$GTKPATH" |
133 |
FileWriteByte $0 "13" |
134 |
FileWriteByte $0 "10" |
135 |
FileWrite $0 "cd " |
136 |
FileWrite $0 $INSTDIR |
137 |
FileWriteByte $0 "13" |
138 |
FileWriteByte $0 "10" |
139 |
FileWrite $0 "$PYPATH\python " |
140 |
FileWriteByte $0 "34" |
141 |
FileWrite $0 "$INSTDIR\ascend-config" |
142 |
FileWriteByte $0 "34" |
143 |
FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8" |
144 |
FileWriteByte $0 "13" |
145 |
FileWriteByte $0 "10" |
146 |
|
147 |
FileClose $0 |
148 |
|
149 |
Return |
150 |
ascendconfigerror: |
151 |
MessageBox MB_OK "The 'ascend-config.bat' file was not installed properly; problems writing to that file." |
152 |
|
153 |
SectionEnd |
154 |
|
155 |
;-------------------------------- |
156 |
|
157 |
Section "PyGTK GUI" |
158 |
${If} $PYOK == 'OK' |
159 |
${If} $GTKOK == 'OK' |
160 |
${If} $GLADEOK == 'OK' |
161 |
;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH" |
162 |
|
163 |
DetailPrint "--- PYTHON INTERFACE ---" |
164 |
|
165 |
; Set output path to the installation directory. |
166 |
SetOutPath $INSTDIR |
167 |
|
168 |
; Python interface |
169 |
File "_ascpy.dll" |
170 |
File "*.py" |
171 |
SetOutPath $INSTDIR\glade |
172 |
File "glade\*.glade" |
173 |
File "glade\*.png" |
174 |
|
175 |
; Create 'ascend.bat' launcher for PyGTK interface |
176 |
ClearErrors |
177 |
FileOpen $0 $INSTDIR\ascend.bat w |
178 |
IfErrors pydone |
179 |
FileWrite $0 "@echo off" |
180 |
FileWriteByte $0 "13" |
181 |
FileWriteByte $0 "10" |
182 |
FileWrite $0 "set PATH=$PYPATH;$GTKPATH" |
183 |
FileWriteByte $0 "13" |
184 |
FileWriteByte $0 "10" |
185 |
FileWrite $0 "cd " |
186 |
FileWrite $0 $INSTDIR |
187 |
FileWriteByte $0 "13" |
188 |
FileWriteByte $0 "10" |
189 |
FileWrite $0 "$PYPATH\python gtkbrowser.py --pygtk-assets=" |
190 |
FileWriteByte $0 "34" |
191 |
FileWrite $0 "$INSTDIR\glade" |
192 |
FileWriteByte $0 "34" |
193 |
FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8" |
194 |
FileWriteByte $0 "13" |
195 |
FileWriteByte $0 "10" |
196 |
|
197 |
FileClose $0 |
198 |
|
199 |
StrCpy $PYINSTALLED "1" |
200 |
WriteRegDWORD HKLM "SOFTWARE\ASCEND" "Python" 1 |
201 |
${Else} |
202 |
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)" |
203 |
${EndIf} |
204 |
${Else} |
205 |
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)" |
206 |
${EndIf} |
207 |
${Else} |
208 |
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)" |
209 |
${EndIf} |
210 |
Return |
211 |
|
212 |
pydone: |
213 |
MessageBox MB_OK "PyGTK GUI was not installed properly -- problems with creating ascend.bar" |
214 |
SectionEnd |
215 |
|
216 |
;--------------------------------- |
217 |
|
218 |
Section "Tcl/Tk GUI" |
219 |
|
220 |
${If} $TCLOK != 'OK' |
221 |
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)" |
222 |
${Else} |
223 |
DetailPrint "--- TCL/TK INTERFACE ---" |
224 |
SetOutPath $INSTDIR\tcltk |
225 |
File /r /x .svn "..\tcltk\TK\*" |
226 |
SetOutPath $INSTDIR |
227 |
File "..\tcltk\generic\interface\ascendtcl.dll" |
228 |
File "..\tcltk\generic\interface\ascend4.exe" |
229 |
|
230 |
StrCpy $TCLINSTALLED "!" |
231 |
WriteRegDWORD HKLM "SOFTWARE\ASCEND" "TclTk" 1 |
232 |
|
233 |
${EndIf} |
234 |
|
235 |
SectionEnd |
236 |
|
237 |
;--------------------------------- |
238 |
|
239 |
; Optional section (can be disabled by the user) |
240 |
Section "Start Menu Shortcuts" |
241 |
|
242 |
WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1 |
243 |
|
244 |
CreateDirectory "$SMPROGRAMS\ASCEND" |
245 |
CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 |
246 |
CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0 |
247 |
|
248 |
; Link to PyGTK GUI |
249 |
StrCmp $PYINSTALLED "" smdone smpython |
250 |
smpython: |
251 |
CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$INSTDIR\ascend.bat" "" "$INSTDIR\ascend.bat" 0 |
252 |
smdone: |
253 |
|
254 |
SectionEnd |
255 |
|
256 |
;------------------------------------------------------------------ |
257 |
; UNINSTALLER |
258 |
|
259 |
Section "Uninstall" |
260 |
|
261 |
;--- python components --- |
262 |
|
263 |
ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python" |
264 |
IntCmp $0 0 unnopython unpython |
265 |
|
266 |
unpython: |
267 |
DetailPrint "--- REMOVING PYTHON COMPONENTS ---" |
268 |
Delete $INSTDIR\_ascpy.dll |
269 |
Delete $INSTDIR\ascend.bat |
270 |
Delete $INSTDIR\*.py |
271 |
Delete $INSTDIR\glade\*.glade |
272 |
Delete $INSTDIR\glade\*.png |
273 |
RmDir $INSTDIR\glade |
274 |
|
275 |
unnopython: |
276 |
|
277 |
;--- tcl/tk components --- |
278 |
|
279 |
ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk" |
280 |
${If} $0 != 0 |
281 |
DetailPrint "--- REMOVING TCL/TK COMPONENTS ---" |
282 |
Delete $INSTDIR\ascendtcl.dll |
283 |
RMDir /r $INSTDIR\tcltk |
284 |
${EndIf} |
285 |
|
286 |
;--- start menu --- |
287 |
|
288 |
ReadRegDWORD $1 HKLM "SOFTWARE\ASCEND" "StartMenu" |
289 |
IntCmp $1 0 unnostart unstart |
290 |
unstart: |
291 |
; Remove shortcuts, if any |
292 |
DetailPrint "--- REMOVING START MENU SHORTCUTS ---" |
293 |
RmDir /r "$SMPROGRAMS\ASCEND" |
294 |
|
295 |
unnostart: |
296 |
|
297 |
;--- common components --- |
298 |
|
299 |
DetailPrint "--- REMOVING COMMON COMPONENTS ---" |
300 |
; Remove registry keys |
301 |
|
302 |
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" |
303 |
DeleteRegKey HKLM "SOFTWARE\ASCEND" |
304 |
|
305 |
; Remove files and uninstaller |
306 |
|
307 |
Delete $INSTDIR\ascend.dll |
308 |
Delete $INSTDIR\Makefile.bt |
309 |
Delete $INSTDIR\ascend.syn |
310 |
RMDir /r $INSTDIR\models |
311 |
|
312 |
; Remove directories used |
313 |
RMDir "$INSTDIR" |
314 |
|
315 |
SectionEnd |
316 |
|
317 |
;--------------------------------------------------------------------- |
318 |
; UTILITY ROUTINES |
319 |
|
320 |
Function DetectPython |
321 |
ReadRegStr $R6 HKCU "SOFTWARE\Python\PythonCore\2.4\InstallPath" "" |
322 |
${If} $R6 == '' |
323 |
ReadRegStr $R6 HKLM "SOFTWARE\Python\PythonCore\2.4\InstallPath" "" |
324 |
${If} $R6 == '' |
325 |
Push "No registry key found" |
326 |
Push "NOK" |
327 |
Return |
328 |
${EndIf} |
329 |
${EndIf} |
330 |
|
331 |
${If} ${FileExists} "$R6\python.exe" |
332 |
Push "$R6" |
333 |
Push "OK" |
334 |
${Else} |
335 |
Push "No python.exe found" |
336 |
Push "NOK" |
337 |
${EndIf} |
338 |
FunctionEnd |
339 |
|
340 |
;-------------------------------------------------------------------- |
341 |
; Prefer the current user's installation of GTK, fall back to the local machine |
342 |
|
343 |
Function DetectGTK |
344 |
ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath" |
345 |
${If} $R6 == '' |
346 |
ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath" |
347 |
${If} $R6 == '' |
348 |
Push "No GTK registry key found" |
349 |
Push "NOK" |
350 |
Return |
351 |
${EndIf} |
352 |
${EndIf} |
353 |
|
354 |
${If} ${FileExists} "$R6\libgtk-win32-2.0-0.dll" |
355 |
Push "$R6" |
356 |
Push "OK" |
357 |
${Else} |
358 |
Push "No libgtk-win32-2.0-0.dll found in'$R6'" |
359 |
Push "NOK" |
360 |
${EndIf} |
361 |
FunctionEnd |
362 |
|
363 |
;-------------------------------------------------------------------- |
364 |
; Prefer the current user's installation of GTK, fall back to the local machine |
365 |
|
366 |
Function DetectGlade |
367 |
ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath" |
368 |
${If} $R6 == '' |
369 |
ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath" |
370 |
${If} $R6 == '' |
371 |
Push "No GTK registry key found" |
372 |
Push "NOK" |
373 |
Return |
374 |
${EndIf} |
375 |
${EndIf} |
376 |
|
377 |
${If} ${FileExists} "$R6\libglade-2.0-0.dll" |
378 |
Push "$R6" |
379 |
Push "OK" |
380 |
${Else} |
381 |
Push "No libglade-2.0-0.dll found in'$R6'" |
382 |
Push "NOK" |
383 |
${EndIf} |
384 |
FunctionEnd |
385 |
|
386 |
;-------------------------------------------------------------------- |
387 |
|
388 |
Function DetectTcl |
389 |
ReadRegStr $R6 HKCU "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion" |
390 |
${If} $R6 == '' |
391 |
ReadRegStr $R6 HKLM "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion" |
392 |
${If} $R6 == '' |
393 |
Push "No 'CurrentVersion' registry key" |
394 |
Push "NOK" |
395 |
Return |
396 |
${Else} |
397 |
StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6" |
398 |
ReadRegStr $R8 HKLM $R7 "" |
399 |
${EndIf} |
400 |
${Else} |
401 |
StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6" |
402 |
ReadRegStr $R8 HKCU $R7 "" |
403 |
${EndIf} |
404 |
|
405 |
${If} $R8 == '' |
406 |
Push "No value for $R7" |
407 |
Push "NOK" |
408 |
${Else} |
409 |
Push "$R8\bin" |
410 |
Push "OK" |
411 |
${EndIf} |
412 |
FunctionEnd |