/[ascend]/trunk/pygtk/create.nsi
ViewVC logotype

Contents of /trunk/pygtk/create.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1464 - (show annotations) (download)
Sun Jun 3 04:09:36 2007 UTC (12 years, 8 months ago) by jpye
File size: 13430 byte(s)
Added 'alert' option to 'loading' module.
Added start menu shortcut to Model Library
Bumped version to 0.9.5.111.
Fixed loading of fourbarplot.py example when matplotlib not available.
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 DEFAULTPATH
50 Var /GLOBAL PYOK
51 Var /GLOBAL PYPATH
52 Var /GLOBAL GTKOK
53 Var /GLOBAL GTKPATH
54 Var /GLOBAL GLADEOK
55 Var /GLOBAL GLADEPATH
56 Var /GLOBAL PYINSTALLED
57 Var /GLOBAL TCLOK
58 Var /GLOBAL TCLPATH
59 Var /GLOBAL TCLINSTALLED
60 Var /GLOBAL PATH
61
62 Function .onInit
63 StrCpy $PYINSTALLED ""
64 StrCpy $TCLINSTALLED ""
65
66 ExpandEnvStrings $DEFAULTPATH "%WINDIR%;%WINDIR%\system32"
67
68 Call DetectPython
69 Pop $PYOK
70 Pop $PYPATH
71
72 Call DetectGTK
73 Pop $GTKOK
74 Pop $GTKPATH
75
76 Call DetectGlade
77 Pop $GLADEOK
78 Pop $GLADEPATH
79
80 Call DetectTcl
81 Pop $TCLOK
82 Pop $TCLPATH
83
84 StrCpy $PATH "$DEFAULTPATH;$PYPATH;$GTKPATH"
85
86 FunctionEnd
87
88
89 ; The stuff to install
90 Section "ASCEND (required)"
91 SectionIn RO
92
93 DetailPrint "--- COMMON FILES ---"
94
95 ; Set output path to the installation directory.
96 SetOutPath $INSTDIR
97 File "..\ascend.dll"
98 File "..\ascend-config"
99 File "glade\ascend.ico"
100
101
102 ; Model Library
103 SetOutPath $INSTDIR\models
104 File /r /x .svn "..\models\*.a4*"
105 File /r /x .svn "..\models\*.tcl"
106 File /r /x .svn "..\models\*.dll" ; extension modules
107 File /r /x .svn "..\models\*.py"; python modules
108
109 SetOutPath $INSTDIR
110 File "Makefile.bt"
111 File "..\tools\textpad\ascend.syn"
112
113 ${If} ${FileExists} "$APPDATA\.ascend.ini"
114 MessageBox MB_OK "The '$APPDATA\.ascend.ini' is NOT being updated. Manually delete this file if ASCEND doesn't behave as expected."
115 ${Else}
116 ; Set 'librarypath' in .ascend.ini
117 WriteINIstr $APPDATA\.ascend.ini Directories librarypath "$DOCUMENTS\ascdata;$INSTDIR\models"
118 ${EndIf}
119
120 ; Write the installation path into the registry
121 WriteRegStr HKLM SOFTWARE\ASCEND "Install_Dir" "$INSTDIR"
122
123 ; Write the uninstall keys for Windows
124 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "DisplayName" "ASCEND Simulation Environment"
125 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "UninstallString" '"$INSTDIR\uninstall.exe"'
126 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoModify" 1
127 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoRepair" 1
128 WriteUninstaller "uninstall.exe"
129
130 ; Write file locations to the registry for access from ascend-config
131 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_LIB" "$INSTDIR"
132 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_BIN" "$INSTDIR"
133 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_INCLUDE" "$INSTDIR\include"
134 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_ASCDATA" "$INSTDIR"
135 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_MODELS" "$INSTDIR\models"
136 WriteRegStr HKLM SOFTWARE\ASCEND "GTKLIBS" "$GTKPATH"
137
138 ; Create 'ascend-config.bat' batch file for launching the python script 'ascend-config'.
139 ClearErrors
140 FileOpen $0 $INSTDIR\ascend-config.bat w
141 IfErrors ascendconfigerror
142 FileWrite $0 "@echo off"
143 FileWriteByte $0 "13"
144 FileWriteByte $0 "10"
145 FileWrite $0 "set PATH=$PATH"
146 FileWriteByte $0 "13"
147 FileWriteByte $0 "10"
148 FileWrite $0 "cd "
149 FileWrite $0 $INSTDIR
150 FileWriteByte $0 "13"
151 FileWriteByte $0 "10"
152 FileWrite $0 "$PYPATH\python "
153 FileWriteByte $0 "34"
154 FileWrite $0 "$INSTDIR\ascend-config"
155 FileWriteByte $0 "34"
156 FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8"
157 FileWriteByte $0 "13"
158 FileWriteByte $0 "10"
159
160 FileClose $0
161
162 Return
163 ascendconfigerror:
164 MessageBox MB_OK "The 'ascend-config.bat' file was not installed properly; problems writing to that file."
165
166 SectionEnd
167
168 ;--------------------------------
169
170 Section "PyGTK GUI"
171 ${If} $PYOK == 'OK'
172 ${If} $GTKOK == 'OK'
173 ${If} $GLADEOK == 'OK'
174 ;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH"
175
176 DetailPrint "--- PYTHON INTERFACE ---"
177
178 ; Set output path to the installation directory.
179 SetOutPath $INSTDIR
180
181 ; Python interface
182 File "_ascpy.dll"
183 File "*.py"
184 File "ascend"
185 File "glade\ascend-doc.ico"
186
187 SetOutPath $INSTDIR\glade
188 File "glade\*.glade"
189 File "glade\*.png"
190 File "glade\*.svg"
191
192 StrCpy $PYINSTALLED "1"
193 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "Python" 1
194
195 ;---- file association ----
196
197 ; back up old value of .a4c file association
198 ReadRegStr $1 HKCR ".a4c" ""
199 StrCmp $1 "" a4cnobkp
200 StrCmp $1 "ASCEND.model" a4cnobkp
201
202 ; Remember the old file association if necessary
203 WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4C" $1
204
205 a4cnobkp:
206 WriteRegStr HKCR ".a4c" "" "ASCEND.model"
207
208 ; back up old value of .a4c file association
209 ReadRegStr $1 HKCR ".a4l" ""
210 StrCmp $1 "" a4lnobkp
211 StrCmp $1 "ASCEND.model" a4lnobkp
212
213 ; Remember the old file association if necessary
214 WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4L" $1
215
216 a4lnobkp:
217 WriteRegStr HKCR ".a4l" "" "ASCEND.model"
218
219 ; So, what does an A4L or A4C file actually do?
220
221 ReadRegStr $0 HKCR "ASCEND.model" ""
222 StrCmp $0 "" 0 a4cskip
223
224 WriteRegStr HKCR "ASCEND.model" "" "ASCEND model file"
225 WriteRegStr HKCR "ASCEND.model\shell" "" "open"
226 WriteRegStr HKCR "ASCEND.model\DefaultIcon" "" "$INSTDIR\ascend-doc.ico"
227
228 a4cskip:
229 WriteRegStr HKCR "ASCEND.model\shell\open\command" "" '$PYPATH\pythonw "$INSTDIR\ascend" "%1"'
230
231 System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
232
233 ${Else}
234 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)"
235 ${EndIf}
236 ${Else}
237 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)"
238 ${EndIf}
239 ${Else}
240 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)"
241 ${EndIf}
242 Return
243
244 SectionEnd
245
246 ;---------------------------------
247
248 Section "Tcl/Tk GUI"
249
250 ${If} $TCLOK != 'OK'
251 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)"
252 ${Else}
253 DetailPrint "--- TCL/TK INTERFACE ---"
254 SetOutPath $INSTDIR\tcltk
255 File /r /x .svn "..\tcltk\TK\*"
256 SetOutPath $INSTDIR
257 File "..\tcltk\generic\interface\ascendtcl.dll"
258 File "..\tcltk\generic\interface\ascend4.exe"
259
260 StrCpy $TCLINSTALLED "1"
261 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "TclTk" 1
262
263 ${EndIf}
264
265 SectionEnd
266
267 ;---------------------------------
268
269 ; Optional section (can be disabled by the user)
270 Section "Start Menu Shortcuts"
271
272 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1
273
274 CreateDirectory "$SMPROGRAMS\ASCEND"
275
276 ; Link to PyGTK GUI
277 StrCmp $PYINSTALLED "" smdone 0
278 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$PYPATH\pythonw.exe" '"$INSTDIR\ascend"' "$INSTDIR\ascend.ico" 0
279 smdone:
280
281 ; Model library shortcut
282 CreateShortCut "$SMPROGRAMS\ASCEND\Model Library.lnk" "$INSTDIR\models" "" "$INSTDIR\models" 0
283
284
285 ; Link to Tcl/Tk GUI
286 StrCmp $TCLINSTALLED "" smnotcl 0
287 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0
288 smnotcl:
289
290 CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
291
292 SectionEnd
293
294 ;------------------------------------------------------------------
295 ; UNINSTALLER
296
297 Section "Uninstall"
298
299 ;--- python components ---
300
301 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
302 IntCmp $0 0 unnopython unpython
303
304 unpython:
305 DetailPrint "--- REMOVING PYTHON COMPONENTS ---"
306 Delete $INSTDIR\_ascpy.dll
307 Delete $INSTDIR\ascend
308 Delete $INSTDIR\*.py
309 Delete $INSTDIR\*.pyc
310 Delete $INSTDIR\glade\*.glade
311 Delete $INSTDIR\glade\*.png
312 Delete $INSTDIR\glade\*.svg
313 RmDir $INSTDIR\glade
314 Delete $INSTDIR\ascend-doc.ico
315
316 ;--- file association (for Python GUI) ---
317
318 DetailPrint "--- REMOVING FILE ASSOCIATION ---"
319 ;start of restore script
320 ReadRegStr $1 HKCR ".a4c" ""
321 ${If} $1 == "ASCEND.model"
322 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
323 ${If} $1 == ""
324 ; nothing to restore: delete it
325 DeleteRegKey HKCR ".a4c"
326 ${Else}
327 WriteRegStr HKCR ".a4c" "" $1
328 ${EndIf}
329 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
330 ${EndIf}
331
332 ReadRegStr $1 HKCR ".a4l" ""
333 ${If} $1 == "ASCEND.model"
334 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
335 ${If} $1 == ""
336 ; nothing to restore: delete it
337 DeleteRegKey HKCR ".a4l"
338 ${Else}
339 WriteRegStr HKCR ".a4l" "" $1
340 ${EndIf}
341 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
342 ${EndIf}
343
344 DeleteRegKey HKCR "ASCEND.model" ;Delete key with association settings
345
346 System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
347 ;rest of script
348
349 unnopython:
350
351 ;--- tcl/tk components ---
352
353 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk"
354 ${If} $0 != 0
355 DetailPrint "--- REMOVING TCL/TK COMPONENTS ---"
356 Delete $INSTDIR\ascendtcl.dll
357 Delete $INSTDIR\ascend4.exe
358 RMDir /r $INSTDIR\tcltk
359 ${EndIf}
360
361 ;--- start menu ---
362
363 ReadRegDWORD $1 HKLM "SOFTWARE\ASCEND" "StartMenu"
364 IntCmp $1 0 unnostart unstart
365 unstart:
366 ; Remove shortcuts, if any
367 DetailPrint "--- REMOVING START MENU SHORTCUTS ---"
368 RmDir /r "$SMPROGRAMS\ASCEND"
369
370 unnostart:
371
372 ;--- common components ---
373
374 DetailPrint "--- REMOVING COMMON COMPONENTS ---"
375 ; Remove registry keys
376
377 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND"
378 DeleteRegKey HKLM "SOFTWARE\ASCEND"
379
380 ; Remove files and uninstaller
381
382 Delete $INSTDIR\ascend-config
383 Delete $INSTDIR\ascend-config.bat
384 Delete $INSTDIR\ascend.dll
385 Delete $INSTDIR\ascend.ico
386 Delete $INSTDIR\Makefile.bt
387 Delete $INSTDIR\ascend.syn
388 RMDir /r $INSTDIR\models
389
390 ; Remove directories used
391
392 Delete $INSTDIR\uninstall.exe
393 RMDir $INSTDIR
394
395 SectionEnd
396
397 ;---------------------------------------------------------------------
398 ; UTILITY ROUTINES
399
400 Function DetectPython
401 ReadRegStr $R6 HKCU "SOFTWARE\Python\PythonCore\2.4\InstallPath" ""
402 ${If} $R6 == ''
403 ReadRegStr $R6 HKLM "SOFTWARE\Python\PythonCore\2.4\InstallPath" ""
404 ${If} $R6 == ''
405 Push "No registry key found"
406 Push "NOK"
407 Return
408 ${EndIf}
409 ${EndIf}
410
411 ${If} ${FileExists} "$R6\python.exe"
412 Push "$R6"
413 Push "OK"
414 ${Else}
415 Push "No python.exe found"
416 Push "NOK"
417 ${EndIf}
418 FunctionEnd
419
420 ;--------------------------------------------------------------------
421 ; Prefer the current user's installation of GTK, fall back to the local machine
422
423 Function DetectGTK
424 ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
425 ${If} $R6 == ''
426 ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
427 ${If} $R6 == ''
428 Push "No GTK registry key found"
429 Push "NOK"
430 Return
431 ${EndIf}
432 ${EndIf}
433
434 ${If} ${FileExists} "$R6\libgtk-win32-2.0-0.dll"
435 Push "$R6"
436 Push "OK"
437 ${Else}
438 Push "No libgtk-win32-2.0-0.dll found in'$R6'"
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 DetectGlade
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\libglade-2.0-0.dll"
458 Push "$R6"
459 Push "OK"
460 ${Else}
461 Push "No libglade-2.0-0.dll found in'$R6'"
462 Push "NOK"
463 ${EndIf}
464 FunctionEnd
465
466 ;--------------------------------------------------------------------
467
468 Function DetectTcl
469 ReadRegStr $R6 HKCU "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
470 ${If} $R6 == ''
471 ReadRegStr $R6 HKLM "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
472 ${If} $R6 == ''
473 Push "No 'CurrentVersion' registry key"
474 Push "NOK"
475 Return
476 ${Else}
477 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
478 ReadRegStr $R8 HKLM $R7 ""
479 ${EndIf}
480 ${Else}
481 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
482 ReadRegStr $R8 HKCU $R7 ""
483 ${EndIf}
484
485 ${If} $R8 == ''
486 Push "No value for $R7"
487 Push "NOK"
488 ${Else}
489 Push "$R8\bin"
490 Push "OK"
491 ${EndIf}
492 FunctionEnd

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