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

Contents of /trunk/installer.nsi

Parent Directory Parent Directory | Revision Log Revision Log


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

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