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

Contents of /trunk/installer.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1520 - (show annotations) (download)
Sat Jun 30 01:23:36 2007 UTC (15 years, 1 month ago) by jpye
File size: 15749 byte(s)
Fixing for missing yacc/lex on Windows, auto-update of them when yacc/lex *are* avail.
Fixing 'test.py' operation on Windows (ASCENDSOLVERS env var)
Adding missing ida.dll to installer.
Adding some missing export symbols in libascend.
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 "INSTALL_SOLVERS" "$INSTDIR\solvers"
160 WriteRegStr HKLM SOFTWARE\ASCEND "GTKLIBS" "$GTKPATH"
161
162 ; Create 'ascend-config.bat' batch file for launching the python script 'ascend-config'.
163 ClearErrors
164 FileOpen $0 $INSTDIR\ascend-config.bat w
165 IfErrors ascendconfigerror
166 FileWrite $0 "@echo off"
167 FileWriteByte $0 "13"
168 FileWriteByte $0 "10"
169 FileWrite $0 "set PATH=$PATH"
170 FileWriteByte $0 "13"
171 FileWriteByte $0 "10"
172 FileWrite $0 "cd "
173 FileWrite $0 $INSTDIR
174 FileWriteByte $0 "13"
175 FileWriteByte $0 "10"
176 FileWrite $0 "$PYPATH\python "
177 FileWriteByte $0 "34"
178 FileWrite $0 "$INSTDIR\ascend-config"
179 FileWriteByte $0 "34"
180 FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8"
181 FileWriteByte $0 "13"
182 FileWriteByte $0 "10"
183
184 FileClose $0
185
186 Return
187 ascendconfigerror:
188 MessageBox MB_OK "The 'ascend-config.bat' file was not installed properly; problems writing to that file."
189
190 SectionEnd
191
192 ;--------------------------------
193
194 Section "PyGTK GUI"
195 ; Check the dependencies of the PyGTK GUI before proceding...
196 ${If} $PYOK == 'NOK'
197 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)"
198 ${ElseIf} $GTKOK == 'NOK'
199 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)"
200 ${ElseIf} $GLADEOK == 'NOK'
201 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)"
202 ${ElseIf} $PYGTKOK == "NOK"
203 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)"
204 ${ElseIf} $PYCAIROOK == "NOK"
205 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)"
206 ${ElseIf} $PYGOBJECTOK == "NOK"
207 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)"
208 ${Else}
209 ;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH"
210
211 DetailPrint "--- PYTHON INTERFACE ---"
212
213 ; Set output path to the installation directory.
214 SetOutPath $INSTDIR
215
216 ; Python interface
217 File /nonfatal "pygtk\_ascpy.pyd"
218 File "pygtk\*.py"
219 File "pygtk\ascend"
220 File "pygtk\glade\ascend-doc.ico"
221
222 SetOutPath $INSTDIR\glade
223 File "pygtk\glade\*.glade"
224 File "pygtk\glade\*.png"
225 File "pygtk\glade\*.svg"
226
227 StrCpy $PYINSTALLED "1"
228 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "Python" 1
229
230 ;---- file association ----
231
232 ; back up old value of .a4c file association
233 ReadRegStr $1 HKCR ".a4c" ""
234 StrCmp $1 "" a4cnobkp
235 StrCmp $1 "ASCEND.model" a4cnobkp
236
237 ; Remember the old file association if necessary
238 WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4C" $1
239
240 a4cnobkp:
241 WriteRegStr HKCR ".a4c" "" "ASCEND.model"
242
243 ; back up old value of .a4c file association
244 ReadRegStr $1 HKCR ".a4l" ""
245 StrCmp $1 "" a4lnobkp
246 StrCmp $1 "ASCEND.model" a4lnobkp
247
248 ; Remember the old file association if necessary
249 WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4L" $1
250
251 a4lnobkp:
252 WriteRegStr HKCR ".a4l" "" "ASCEND.model"
253
254 ; So, what does an A4L or A4C file actually do?
255
256 ReadRegStr $0 HKCR "ASCEND.model" ""
257 StrCmp $0 "" 0 a4cskip
258
259 WriteRegStr HKCR "ASCEND.model" "" "ASCEND model file"
260 WriteRegStr HKCR "ASCEND.model\shell" "" "open"
261 WriteRegStr HKCR "ASCEND.model\DefaultIcon" "" "$INSTDIR\ascend-doc.ico"
262
263 a4cskip:
264 WriteRegStr HKCR "ASCEND.model\shell\open\command" "" '$PYPATH\pythonw "$INSTDIR\ascend" "%1"'
265
266 System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
267
268 ${EndIf}
269 Return
270
271 SectionEnd
272
273 ;---------------------------------
274
275 Section "Tcl/Tk GUI"
276
277 ${If} $TCLOK != 'OK'
278 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)"
279 ${Else}
280 DetailPrint "--- TCL/TK INTERFACE ---"
281 SetOutPath $INSTDIR\tcltk
282 File /r /x .svn "tcltk\TK\*"
283 SetOutPath $INSTDIR
284 File "tcltk\generic\interface\ascendtcl.dll"
285 File "tcltk\generic\interface\ascend4.exe"
286
287 StrCpy $TCLINSTALLED "1"
288 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "TclTk" 1
289
290 ${EndIf}
291
292 SectionEnd
293
294 ;---------------------------------
295
296 ; Optional section (can be disabled by the user)
297 Section "Start Menu Shortcuts"
298
299 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1
300
301 CreateDirectory "$SMPROGRAMS\ASCEND"
302
303 ; Link to PyGTK GUI
304 StrCmp $PYINSTALLED "" smdone 0
305 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$PYPATH\pythonw.exe" '"$INSTDIR\ascend"' "$INSTDIR\ascend.ico" 0
306 smdone:
307
308 ; Model library shortcut
309 CreateShortCut "$SMPROGRAMS\ASCEND\Model Library.lnk" "$INSTDIR\models" "" "$INSTDIR\models" 0
310
311
312 ; Link to Tcl/Tk GUI
313 StrCmp $TCLINSTALLED "" smnotcl 0
314 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0
315 smnotcl:
316
317 ; Information files
318 CreateShortCut "$SMPROGRAMS\ASCEND\LICENSE.lnk" "$INSTDIR\LICENSE.txt" '' "$INSTDIR\LICENSE.txt" 0
319 CreateShortCut "$SMPROGRAMS\ASCEND\CHANGELOG.lnk" "$INSTDIR\CHANGELOG.txt" '' "$INSTDIR\CHANGELOG.txt" 0
320 CreateShortCut "$SMPROGRAMS\ASCEND\README.lnk" "$INSTDIR\README-windows.txt" '' "$INSTDIR\README-windows.txt" 0
321
322 CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
323
324 SectionEnd
325
326 ;------------------------------------------------------------------
327 ; UNINSTALLER
328
329 Section "Uninstall"
330
331 ;--- python components ---
332
333 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
334 IntCmp $0 0 unnopython unpython
335
336 unpython:
337 DetailPrint "--- REMOVING PYTHON COMPONENTS ---"
338 Delete $INSTDIR\_ascpy.pyd
339 Delete $INSTDIR\ascend
340 Delete $INSTDIR\*.py
341 Delete $INSTDIR\*.pyc
342 Delete $INSTDIR\glade\*.glade
343 Delete $INSTDIR\glade\*.png
344 Delete $INSTDIR\glade\*.svg
345 RmDir $INSTDIR\glade
346 Delete $INSTDIR\ascend-doc.ico
347
348 ;--- file association (for Python GUI) ---
349
350 DetailPrint "--- REMOVING FILE ASSOCIATION ---"
351 ;start of restore script
352 ReadRegStr $1 HKCR ".a4c" ""
353 ${If} $1 == "ASCEND.model"
354 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
355 ${If} $1 == ""
356 ; nothing to restore: delete it
357 DeleteRegKey HKCR ".a4c"
358 ${Else}
359 WriteRegStr HKCR ".a4c" "" $1
360 ${EndIf}
361 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
362 ${EndIf}
363
364 ReadRegStr $1 HKCR ".a4l" ""
365 ${If} $1 == "ASCEND.model"
366 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
367 ${If} $1 == ""
368 ; nothing to restore: delete it
369 DeleteRegKey HKCR ".a4l"
370 ${Else}
371 WriteRegStr HKCR ".a4l" "" $1
372 ${EndIf}
373 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
374 ${EndIf}
375
376 DeleteRegKey HKCR "ASCEND.model" ;Delete key with association settings
377
378 System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
379 ;rest of script
380
381 unnopython:
382
383 ;--- tcl/tk components ---
384
385 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk"
386 ${If} $0 != 0
387 DetailPrint "--- REMOVING TCL/TK COMPONENTS ---"
388 Delete $INSTDIR\ascendtcl.dll
389 Delete $INSTDIR\ascend4.exe
390 RMDir /r $INSTDIR\tcltk
391 ${EndIf}
392
393 ;--- start menu ---
394
395 ReadRegDWORD $1 HKLM "SOFTWARE\ASCEND" "StartMenu"
396 IntCmp $1 0 unnostart unstart
397 unstart:
398 ; Remove shortcuts, if any
399 DetailPrint "--- REMOVING START MENU SHORTCUTS ---"
400 RmDir /r "$SMPROGRAMS\ASCEND"
401
402 unnostart:
403
404 ;--- common components ---
405
406 DetailPrint "--- REMOVING COMMON COMPONENTS ---"
407 ; Remove registry keys
408
409 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND"
410 DeleteRegKey HKLM "SOFTWARE\ASCEND"
411
412 ; Remove files and uninstaller
413
414 Delete $INSTDIR\ascend-config
415 Delete $INSTDIR\ascend-config.bat
416 Delete $INSTDIR\ascend.dll
417 Delete $INSTDIR\LICENSE.txt
418 Delete $INSTDIR\README-windows.txt
419 Delete $INSTDIR\CHANGELOG.txt
420 Delete $INSTDIR\ascend.ico
421 Delete $INSTDIR\Makefile.bt
422 Delete $INSTDIR\ascend.syn
423 RMDir /r $INSTDIR\models
424 Delete $INSTDIR\solvers\qrslv.dll
425 Delete $INSTDIR\solvers\conopt.dll
426 Delete $INSTDIR\solvers\lrslv.dll
427 Delete $INSTDIR\solvers\cmslv.dll
428 Delete $INSTDIR\solvers\lsode.dll
429 Delete $INSTDIR\solvers\ida.dll
430
431 ; Remove directories used
432
433 Delete $INSTDIR\uninstall.exe
434 RMDir $INSTDIR
435
436 SectionEnd
437
438 ;---------------------------------------------------------------------
439 ; UTILITY ROUTINES
440
441 Function DetectPython
442 ReadRegStr $R6 HKCU "SOFTWARE\Python\PythonCore\${PYVERSION}\InstallPath" ""
443 ${If} $R6 == ''
444 ReadRegStr $R6 HKLM "SOFTWARE\Python\PythonCore\${PYVERSION}\InstallPath" ""
445 ${If} $R6 == ''
446 Push "No registry key found"
447 Push "NOK"
448 Return
449 ${EndIf}
450 ${EndIf}
451
452 ${If} ${FileExists} "$R6\python.exe"
453 Push "$R6"
454 Push "OK"
455 ${Else}
456 Push "No python.exe found"
457 Push "NOK"
458 ${EndIf}
459 FunctionEnd
460
461 ;--------------------------------------------------------------------
462 ; Prefer the current user's installation of GTK, fall back to the local machine
463
464 Function DetectGTK
465 ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
466 ${If} $R6 == ''
467 ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
468 ${If} $R6 == ''
469 Push "No GTK registry key found"
470 Push "NOK"
471 Return
472 ${EndIf}
473 ${EndIf}
474
475 ${If} ${FileExists} "$R6\libgtk-win32-2.0-0.dll"
476 Push "$R6"
477 Push "OK"
478 ${Else}
479 Push "No libgtk-win32-2.0-0.dll found in'$R6'"
480 Push "NOK"
481 ${EndIf}
482 FunctionEnd
483
484 ;--------------------------------------------------------------------
485 ; Are necessary PyGTK bits and pieces available?
486
487 Function DetectPyGTK
488 ${If} ${FileExists} "$PYPATH\Lib\site-packages\gtk-2.0\gtk\__init__.py"
489 Push "OK"
490 ${Else}
491 Push "NOK"
492 ${EndIf}
493 FunctionEnd
494
495 Function DetectPyCairo
496 ${If} ${FileExists} "$PYPATH\Lib\site-packages\cairo\__init__.py"
497 Push "OK"
498 ${Else}
499 Push "NOK"
500 ${EndIf}
501 FunctionEnd
502
503 Function DetectPyGObject
504 ${If} ${FileExists} "$PYPATH\Lib\site-packages\gtk-2.0\gobject\__init__.py"
505 Push "OK"
506 ${Else}
507 Push "NOK"
508 ${EndIf}
509 FunctionEnd
510
511 ;--------------------------------------------------------------------
512 ; Prefer the current user's installation of GTK, fall back to the local machine
513
514 Function DetectGlade
515 ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
516 ${If} $R6 == ''
517 ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
518 ${If} $R6 == ''
519 Push "No GTK registry key found"
520 Push "NOK"
521 Return
522 ${EndIf}
523 ${EndIf}
524
525 ${If} ${FileExists} "$R6\libglade-2.0-0.dll"
526 Push "$R6"
527 Push "OK"
528 ${Else}
529 Push "No libglade-2.0-0.dll found in'$R6'"
530 Push "NOK"
531 ${EndIf}
532 FunctionEnd
533
534 ;--------------------------------------------------------------------
535
536 Function DetectTcl
537 ReadRegStr $R6 HKCU "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
538 ${If} $R6 == ''
539 ReadRegStr $R6 HKLM "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
540 ${If} $R6 == ''
541 Push "No 'CurrentVersion' registry key"
542 Push "NOK"
543 Return
544 ${Else}
545 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
546 ReadRegStr $R8 HKLM $R7 ""
547 ${EndIf}
548 ${Else}
549 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
550 ReadRegStr $R8 HKCU $R7 ""
551 ${EndIf}
552
553 ${If} $R8 == ''
554 Push "No value for $R7"
555 Push "NOK"
556 ${Else}
557 Push "$R8\bin"
558 Push "OK"
559 ${EndIf}
560 FunctionEnd

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