/[ascend]/trunk/installer.nsi
ViewVC logotype

Contents of /trunk/installer.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1515 - (show annotations) (download)
Wed Jun 27 15:09:57 2007 UTC (15 years, 3 months ago) by jpye
File size: 15678 byte(s)
work on fixing Windows for the external solvers changes
1 ; NSIS script to create an ASCEND binary installer for Windows
2 ; by John Pye, 2006-2007.
3 ;
4 ;--------------------------------
5
6 ; The name of the installer
7
8 !ifndef VERSION
9 !define VERSION 0.svn
10 !endif
11
12 Name "ASCEND ${VERSION}"
13
14 !include LogicLib.nsh
15
16 !ifndef PYVERSION
17 !define PYVERSION "2.5"
18 !endif
19
20 ; The file to write
21 !ifdef OUTFILE
22 OutFile ${OUTFILE}
23 !else
24 OutFile "ascend-${VERSION}-py${PYVERSION}.exe"
25 !endif
26
27 ;SetCompressor /FINAL zlib
28 SetCompressor /SOLID lzma
29
30 ; The default installation directory
31 InstallDir $PROGRAMFILES\ASCEND
32
33 ; Registry key to check for directory (so if you install again, it will
34 ; overwrite the old one automatically)
35 InstallDirRegKey HKLM "Software\ASCEND" "Install_Dir"
36
37 ;--------------------------------
38
39 ; Pages
40
41 Page components
42 Page directory
43 Page instfiles
44
45 UninstPage uninstConfirm
46 UninstPage instfiles
47
48 ;--------------------------------
49
50 Var /GLOBAL DEFAULTPATH
51 Var /GLOBAL PYOK
52 Var /GLOBAL PYPATH
53 Var /GLOBAL GTKOK
54 Var /GLOBAL GTKPATH
55 Var /GLOBAL GLADEOK
56 Var /GLOBAL PYGTKOK
57 Var /GLOBAL PYGOBJECTOK
58 Var /GLOBAL PYCAIROOK
59 Var /GLOBAL GLADEPATH
60 Var /GLOBAL PYINSTALLED
61 Var /GLOBAL TCLOK
62 Var /GLOBAL TCLPATH
63 Var /GLOBAL TCLINSTALLED
64 Var /GLOBAL PATH
65
66 Function .onInit
67 StrCpy $PYINSTALLED ""
68 StrCpy $TCLINSTALLED ""
69
70 ExpandEnvStrings $DEFAULTPATH "%WINDIR%;%WINDIR%\system32"
71
72 Call DetectPython
73 Pop $PYOK
74 Pop $PYPATH
75
76 Call DetectGTK
77 Pop $GTKOK
78 Pop $GTKPATH
79
80 Call DetectGlade
81 Pop $GLADEOK
82 Pop $GLADEPATH
83
84 Call DetectTcl
85 Pop $TCLOK
86 Pop $TCLPATH
87
88 Call DetectPyGTK
89 Pop $PYGTKOK
90
91 Call DetectPyGObject
92 Pop $PYGOBJECTOK
93
94 Call DetectPyCairo
95 Pop $PYCAIROOK
96
97 StrCpy $PATH "$DEFAULTPATH;$PYPATH;$GTKPATH"
98
99 FunctionEnd
100
101
102 ; The stuff to install
103 Section "ASCEND (required)"
104 SectionIn RO
105
106 DetailPrint "--- COMMON FILES ---"
107
108 ; Set output path to the installation directory.
109 SetOutPath $INSTDIR
110 File "ascend.dll"
111 File "ascend-config"
112 File "pygtk\glade\ascend.ico"
113 File "LICENSE.txt"
114 File "CHANGELOG.txt"
115 File "README-windows.txt"
116
117 ; Model Library
118 SetOutPath $INSTDIR\models
119 File /r /x .svn "models\*.a4*"
120 File /r /x .svn "models\*.tcl"
121 File /r /x .svn "models\*.dll" ; extension modules
122 File /r /x .svn "models\*.py"; python modules
123
124 SetOutPath $INSTDIR\solvers
125 File "solvers\qrslv\qrslv.dll"
126 File "solvers\conopt\conopt.dll"
127 File "solvers\lrslv\lrslv.dll"
128 File "solvers\cmslv\cmslv.dll"
129 File "solvers\lsode\lsode.dll"
130 ; File "solvers\ida\ida.dll"
131
132 SetOutPath $INSTDIR
133 ;File "Makefile.bt"
134 File "tools\textpad\ascend.syn"
135
136 ${If} ${FileExists} "$APPDATA\.ascend.ini"
137 MessageBox MB_OK "The '$APPDATA\.ascend.ini' is NOT being updated. Manually delete this file if ASCEND doesn't behave as expected."
138 ${Else}
139 ; Set 'librarypath' in .ascend.ini
140 WriteINIstr $APPDATA\.ascend.ini Directories librarypath "$DOCUMENTS\ascdata;$INSTDIR\models"
141 ${EndIf}
142
143 ; Write the installation path into the registry
144 WriteRegStr HKLM SOFTWARE\ASCEND "Install_Dir" "$INSTDIR"
145
146 ; Write the uninstall keys for Windows
147 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "DisplayName" "ASCEND Simulation Environment"
148 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "UninstallString" '"$INSTDIR\uninstall.exe"'
149 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoModify" 1
150 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoRepair" 1
151 WriteUninstaller "uninstall.exe"
152
153 ; Write file locations to the registry for access from ascend-config
154 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_LIB" "$INSTDIR"
155 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_BIN" "$INSTDIR"
156 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_INCLUDE" "$INSTDIR\include"
157 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_ASCDATA" "$INSTDIR"
158 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_MODELS" "$INSTDIR\models"
159 WriteRegStr HKLM SOFTWARE\ASCEND "GTKLIBS" "$GTKPATH"
160
161 ; Create 'ascend-config.bat' batch file for launching the python script 'ascend-config'.
162 ClearErrors
163 FileOpen $0 $INSTDIR\ascend-config.bat w
164 IfErrors ascendconfigerror
165 FileWrite $0 "@echo off"
166 FileWriteByte $0 "13"
167 FileWriteByte $0 "10"
168 FileWrite $0 "set PATH=$PATH"
169 FileWriteByte $0 "13"
170 FileWriteByte $0 "10"
171 FileWrite $0 "cd "
172 FileWrite $0 $INSTDIR
173 FileWriteByte $0 "13"
174 FileWriteByte $0 "10"
175 FileWrite $0 "$PYPATH\python "
176 FileWriteByte $0 "34"
177 FileWrite $0 "$INSTDIR\ascend-config"
178 FileWriteByte $0 "34"
179 FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8"
180 FileWriteByte $0 "13"
181 FileWriteByte $0 "10"
182
183 FileClose $0
184
185 Return
186 ascendconfigerror:
187 MessageBox MB_OK "The 'ascend-config.bat' file was not installed properly; problems writing to that file."
188
189 SectionEnd
190
191 ;--------------------------------
192
193 Section "PyGTK GUI"
194 ; Check the dependencies of the PyGTK GUI before proceding...
195 ${If} $PYOK == 'NOK'
196 MessageBox MB_OK "PyGTK GUI can not be installed, because Python was not found on this system.$\nIf you do want to use the PyGTK GUI, please check the installation instructions$\n$\n(PYPATH=$PYPATH)"
197 ${ElseIf} $GTKOK == 'NOK'
198 MessageBox MB_OK "PyGTK GUI cannot be installed, because GTK+ 2.x was not found on this system.$\nIf you do want to use the PyGTK GUI, please check the installation instructions$\n$\n(GTKPATH=$GTKPATH)"
199 ${ElseIf} $GLADEOK == 'NOK'
200 MessageBox MB_OK "PyGTK GUI cannot be installed, because Glade 2.x was not found on this system.$\nIf you do want to use the PyGTK GUI, please check the installation instructions$\n$\n(GTKPATH=$GTKPATH)"
201 ${ElseIf} $PYGTKOK == "NOK"
202 MessageBox MB_OK "PyGTK GUI cannot be installed, because PyGTK was not found on this system.$\nPlease check the installation instructions.$\n$\n(PYPATH=$PYPATH)"
203 ${ElseIf} $PYCAIROOK == "NOK"
204 MessageBox MB_OK "PyGTK GUI cannot be installed, because PyCairo was not found on this system.$\nPlease check the installation instructions.$\n$\n(PYPATH=$PYPATH)"
205 ${ElseIf} $PYGOBJECTOK == "NOK"
206 MessageBox MB_OK "PyGTK GUI cannot be installed, because PyGObject was not found on this system.$\nPlease check the installation instructions.$\n$\n(PYPATH=$PYPATH)"
207 ${Else}
208 ;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH"
209
210 DetailPrint "--- PYTHON INTERFACE ---"
211
212 ; Set output path to the installation directory.
213 SetOutPath $INSTDIR
214
215 ; Python interface
216 File /nonfatal "pygtk\_ascpy.pyd"
217 File "pygtk\*.py"
218 File "pygtk\ascend"
219 File "pygtk\glade\ascend-doc.ico"
220
221 SetOutPath $INSTDIR\glade
222 File "pygtk\glade\*.glade"
223 File "pygtk\glade\*.png"
224 File "pygtk\glade\*.svg"
225
226 StrCpy $PYINSTALLED "1"
227 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "Python" 1
228
229 ;---- file association ----
230
231 ; back up old value of .a4c file association
232 ReadRegStr $1 HKCR ".a4c" ""
233 StrCmp $1 "" a4cnobkp
234 StrCmp $1 "ASCEND.model" a4cnobkp
235
236 ; Remember the old file association if necessary
237 WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4C" $1
238
239 a4cnobkp:
240 WriteRegStr HKCR ".a4c" "" "ASCEND.model"
241
242 ; back up old value of .a4c file association
243 ReadRegStr $1 HKCR ".a4l" ""
244 StrCmp $1 "" a4lnobkp
245 StrCmp $1 "ASCEND.model" a4lnobkp
246
247 ; Remember the old file association if necessary
248 WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4L" $1
249
250 a4lnobkp:
251 WriteRegStr HKCR ".a4l" "" "ASCEND.model"
252
253 ; So, what does an A4L or A4C file actually do?
254
255 ReadRegStr $0 HKCR "ASCEND.model" ""
256 StrCmp $0 "" 0 a4cskip
257
258 WriteRegStr HKCR "ASCEND.model" "" "ASCEND model file"
259 WriteRegStr HKCR "ASCEND.model\shell" "" "open"
260 WriteRegStr HKCR "ASCEND.model\DefaultIcon" "" "$INSTDIR\ascend-doc.ico"
261
262 a4cskip:
263 WriteRegStr HKCR "ASCEND.model\shell\open\command" "" '$PYPATH\pythonw "$INSTDIR\ascend" "%1"'
264
265 System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
266
267 ${EndIf}
268 Return
269
270 SectionEnd
271
272 ;---------------------------------
273
274 Section "Tcl/Tk GUI"
275
276 ${If} $TCLOK != 'OK'
277 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)"
278 ${Else}
279 DetailPrint "--- TCL/TK INTERFACE ---"
280 SetOutPath $INSTDIR\tcltk
281 File /r /x .svn "tcltk\TK\*"
282 SetOutPath $INSTDIR
283 File "tcltk\generic\interface\ascendtcl.dll"
284 File "tcltk\generic\interface\ascend4.exe"
285
286 StrCpy $TCLINSTALLED "1"
287 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "TclTk" 1
288
289 ${EndIf}
290
291 SectionEnd
292
293 ;---------------------------------
294
295 ; Optional section (can be disabled by the user)
296 Section "Start Menu Shortcuts"
297
298 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1
299
300 CreateDirectory "$SMPROGRAMS\ASCEND"
301
302 ; Link to PyGTK GUI
303 StrCmp $PYINSTALLED "" smdone 0
304 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$PYPATH\pythonw.exe" '"$INSTDIR\ascend"' "$INSTDIR\ascend.ico" 0
305 smdone:
306
307 ; Model library shortcut
308 CreateShortCut "$SMPROGRAMS\ASCEND\Model Library.lnk" "$INSTDIR\models" "" "$INSTDIR\models" 0
309
310
311 ; Link to Tcl/Tk GUI
312 StrCmp $TCLINSTALLED "" smnotcl 0
313 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0
314 smnotcl:
315
316 ; Information files
317 CreateShortCut "$SMPROGRAMS\ASCEND\LICENSE.lnk" "$INSTDIR\LICENSE.txt" '' "$INSTDIR\LICENSE.txt" 0
318 CreateShortCut "$SMPROGRAMS\ASCEND\CHANGELOG.lnk" "$INSTDIR\CHANGELOG.txt" '' "$INSTDIR\CHANGELOG.txt" 0
319 CreateShortCut "$SMPROGRAMS\ASCEND\README.lnk" "$INSTDIR\README-windows.txt" '' "$INSTDIR\README-windows.txt" 0
320
321 CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
322
323 SectionEnd
324
325 ;------------------------------------------------------------------
326 ; UNINSTALLER
327
328 Section "Uninstall"
329
330 ;--- python components ---
331
332 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
333 IntCmp $0 0 unnopython unpython
334
335 unpython:
336 DetailPrint "--- REMOVING PYTHON COMPONENTS ---"
337 Delete $INSTDIR\_ascpy.pyd
338 Delete $INSTDIR\ascend
339 Delete $INSTDIR\*.py
340 Delete $INSTDIR\*.pyc
341 Delete $INSTDIR\glade\*.glade
342 Delete $INSTDIR\glade\*.png
343 Delete $INSTDIR\glade\*.svg
344 RmDir $INSTDIR\glade
345 Delete $INSTDIR\ascend-doc.ico
346
347 ;--- file association (for Python GUI) ---
348
349 DetailPrint "--- REMOVING FILE ASSOCIATION ---"
350 ;start of restore script
351 ReadRegStr $1 HKCR ".a4c" ""
352 ${If} $1 == "ASCEND.model"
353 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
354 ${If} $1 == ""
355 ; nothing to restore: delete it
356 DeleteRegKey HKCR ".a4c"
357 ${Else}
358 WriteRegStr HKCR ".a4c" "" $1
359 ${EndIf}
360 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
361 ${EndIf}
362
363 ReadRegStr $1 HKCR ".a4l" ""
364 ${If} $1 == "ASCEND.model"
365 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
366 ${If} $1 == ""
367 ; nothing to restore: delete it
368 DeleteRegKey HKCR ".a4l"
369 ${Else}
370 WriteRegStr HKCR ".a4l" "" $1
371 ${EndIf}
372 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
373 ${EndIf}
374
375 DeleteRegKey HKCR "ASCEND.model" ;Delete key with association settings
376
377 System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
378 ;rest of script
379
380 unnopython:
381
382 ;--- tcl/tk components ---
383
384 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk"
385 ${If} $0 != 0
386 DetailPrint "--- REMOVING TCL/TK COMPONENTS ---"
387 Delete $INSTDIR\ascendtcl.dll
388 Delete $INSTDIR\ascend4.exe
389 RMDir /r $INSTDIR\tcltk
390 ${EndIf}
391
392 ;--- start menu ---
393
394 ReadRegDWORD $1 HKLM "SOFTWARE\ASCEND" "StartMenu"
395 IntCmp $1 0 unnostart unstart
396 unstart:
397 ; Remove shortcuts, if any
398 DetailPrint "--- REMOVING START MENU SHORTCUTS ---"
399 RmDir /r "$SMPROGRAMS\ASCEND"
400
401 unnostart:
402
403 ;--- common components ---
404
405 DetailPrint "--- REMOVING COMMON COMPONENTS ---"
406 ; Remove registry keys
407
408 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND"
409 DeleteRegKey HKLM "SOFTWARE\ASCEND"
410
411 ; Remove files and uninstaller
412
413 Delete $INSTDIR\ascend-config
414 Delete $INSTDIR\ascend-config.bat
415 Delete $INSTDIR\ascend.dll
416 Delete $INSTDIR\LICENSE.txt
417 Delete $INSTDIR\README-windows.txt
418 Delete $INSTDIR\CHANGELOG.txt
419 Delete $INSTDIR\ascend.ico
420 Delete $INSTDIR\Makefile.bt
421 Delete $INSTDIR\ascend.syn
422 RMDir /r $INSTDIR\models
423 Delete $INSTDIR\solvers\qrslv.dll
424 Delete $INSTDIR\solvers\conopt.dll
425 Delete $INSTDIR\solvers\lrslv.dll
426 Delete $INSTDIR\solvers\cmslv.dll
427 Delete $INSTDIR\solvers\lsode.dll
428 Delete $INSTDIR\solvers\ida.dll
429
430 ; Remove directories used
431
432 Delete $INSTDIR\uninstall.exe
433 RMDir $INSTDIR
434
435 SectionEnd
436
437 ;---------------------------------------------------------------------
438 ; UTILITY ROUTINES
439
440 Function DetectPython
441 ReadRegStr $R6 HKCU "SOFTWARE\Python\PythonCore\${PYVERSION}\InstallPath" ""
442 ${If} $R6 == ''
443 ReadRegStr $R6 HKLM "SOFTWARE\Python\PythonCore\${PYVERSION}\InstallPath" ""
444 ${If} $R6 == ''
445 Push "No registry key found"
446 Push "NOK"
447 Return
448 ${EndIf}
449 ${EndIf}
450
451 ${If} ${FileExists} "$R6\python.exe"
452 Push "$R6"
453 Push "OK"
454 ${Else}
455 Push "No python.exe found"
456 Push "NOK"
457 ${EndIf}
458 FunctionEnd
459
460 ;--------------------------------------------------------------------
461 ; Prefer the current user's installation of GTK, fall back to the local machine
462
463 Function DetectGTK
464 ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
465 ${If} $R6 == ''
466 ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
467 ${If} $R6 == ''
468 Push "No GTK registry key found"
469 Push "NOK"
470 Return
471 ${EndIf}
472 ${EndIf}
473
474 ${If} ${FileExists} "$R6\libgtk-win32-2.0-0.dll"
475 Push "$R6"
476 Push "OK"
477 ${Else}
478 Push "No libgtk-win32-2.0-0.dll found in'$R6'"
479 Push "NOK"
480 ${EndIf}
481 FunctionEnd
482
483 ;--------------------------------------------------------------------
484 ; Are necessary PyGTK bits and pieces available?
485
486 Function DetectPyGTK
487 ${If} ${FileExists} "$PYPATH\Lib\site-packages\gtk-2.0\gtk\__init__.py"
488 Push "OK"
489 ${Else}
490 Push "NOK"
491 ${EndIf}
492 FunctionEnd
493
494 Function DetectPyCairo
495 ${If} ${FileExists} "$PYPATH\Lib\site-packages\cairo\__init__.py"
496 Push "OK"
497 ${Else}
498 Push "NOK"
499 ${EndIf}
500 FunctionEnd
501
502 Function DetectPyGObject
503 ${If} ${FileExists} "$PYPATH\Lib\site-packages\gtk-2.0\gobject\__init__.py"
504 Push "OK"
505 ${Else}
506 Push "NOK"
507 ${EndIf}
508 FunctionEnd
509
510 ;--------------------------------------------------------------------
511 ; Prefer the current user's installation of GTK, fall back to the local machine
512
513 Function DetectGlade
514 ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
515 ${If} $R6 == ''
516 ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
517 ${If} $R6 == ''
518 Push "No GTK registry key found"
519 Push "NOK"
520 Return
521 ${EndIf}
522 ${EndIf}
523
524 ${If} ${FileExists} "$R6\libglade-2.0-0.dll"
525 Push "$R6"
526 Push "OK"
527 ${Else}
528 Push "No libglade-2.0-0.dll found in'$R6'"
529 Push "NOK"
530 ${EndIf}
531 FunctionEnd
532
533 ;--------------------------------------------------------------------
534
535 Function DetectTcl
536 ReadRegStr $R6 HKCU "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
537 ${If} $R6 == ''
538 ReadRegStr $R6 HKLM "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
539 ${If} $R6 == ''
540 Push "No 'CurrentVersion' registry key"
541 Push "NOK"
542 Return
543 ${Else}
544 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
545 ReadRegStr $R8 HKLM $R7 ""
546 ${EndIf}
547 ${Else}
548 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
549 ReadRegStr $R8 HKCU $R7 ""
550 ${EndIf}
551
552 ${If} $R8 == ''
553 Push "No value for $R7"
554 Push "NOK"
555 ${Else}
556 Push "$R8\bin"
557 Push "OK"
558 ${EndIf}
559 FunctionEnd

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22