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

Contents of /trunk/installer.nsi

Parent Directory Parent Directory | Revision Log Revision Log


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

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