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

Contents of /trunk/pygtk/create.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1432 - (show annotations) (download)
Sat May 19 08:42:22 2007 UTC (12 years, 9 months ago) by jpye
File size: 11596 byte(s)
Fixes for the windows installer, start menu, splash screen.
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
100 ; Model Library
101 SetOutPath $INSTDIR\models
102 File /r /x .svn "..\models\*.a4*"
103 File /r /x .svn "..\models\*.tcl"
104 File /r /x .svn "..\models\*.dll" ; extension modules
105 File /r /x .svn "..\models\*.py"; python modules
106
107 SetOutPath $INSTDIR
108 File "Makefile.bt"
109 File "..\tools\textpad\ascend.syn"
110
111 ${If} ${FileExists} "$APPDATA\.ascend.ini"
112 MessageBox MB_OK "The '$APPDATA\.ascend.ini' is NOT being updated. Manually delete this file if ASCEND doesn't behave as expected."
113 ${Else}
114 ; Set 'librarypath' in .ascend.ini
115 WriteINIstr $APPDATA\.ascend.ini Directories librarypath "$DOCUMENTS\ascdata;$INSTDIR\models"
116 ${EndIf}
117
118 ; Write the installation path into the registry
119 WriteRegStr HKLM SOFTWARE\ASCEND "Install_Dir" "$INSTDIR"
120
121 ; Write the uninstall keys for Windows
122 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "DisplayName" "ASCEND Simulation Environment"
123 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "UninstallString" '"$INSTDIR\uninstall.exe"'
124 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoModify" 1
125 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoRepair" 1
126 WriteUninstaller "uninstall.exe"
127
128 ; Write file locations to the registry for access from ascend-config
129 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_LIB" "$INSTDIR"
130 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_BIN" "$INSTDIR"
131 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_INCLUDE" "$INSTDIR\include"
132 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_ASCDATA" "$INSTDIR"
133 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_MODELS" "$INSTDIR\models"
134
135 ; Create 'ascend-config.bat' batch file for launching the python script 'ascend-config'.
136 ClearErrors
137 FileOpen $0 $INSTDIR\ascend-config.bat w
138 IfErrors ascendconfigerror
139 FileWrite $0 "@echo off"
140 FileWriteByte $0 "13"
141 FileWriteByte $0 "10"
142 FileWrite $0 "set PATH=$PATH"
143 FileWriteByte $0 "13"
144 FileWriteByte $0 "10"
145 FileWrite $0 "cd "
146 FileWrite $0 $INSTDIR
147 FileWriteByte $0 "13"
148 FileWriteByte $0 "10"
149 FileWrite $0 "$PYPATH\python "
150 FileWriteByte $0 "34"
151 FileWrite $0 "$INSTDIR\ascend-config"
152 FileWriteByte $0 "34"
153 FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8"
154 FileWriteByte $0 "13"
155 FileWriteByte $0 "10"
156
157 FileClose $0
158
159 Return
160 ascendconfigerror:
161 MessageBox MB_OK "The 'ascend-config.bat' file was not installed properly; problems writing to that file."
162
163 SectionEnd
164
165 ;--------------------------------
166
167 Section "PyGTK GUI"
168 ${If} $PYOK == 'OK'
169 ${If} $GTKOK == 'OK'
170 ${If} $GLADEOK == 'OK'
171 ;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH"
172
173 DetailPrint "--- PYTHON INTERFACE ---"
174
175 ; Set output path to the installation directory.
176 SetOutPath $INSTDIR
177
178 ; Python interface
179 File "_ascpy.dll"
180 File "*.py"
181 SetOutPath $INSTDIR\glade
182 File "glade\*.glade"
183 File "glade\*.png"
184 File "glade\*.svg"
185 File "glade\ascend.ico"
186
187 ; Create 'ascend.bat' launcher for PyGTK interface
188 ClearErrors
189 FileOpen $0 $INSTDIR\ascend.bat w
190 IfErrors pydone
191 FileWrite $0 "@echo off"
192 FileWriteByte $0 "13"
193 FileWriteByte $0 "10"
194 FileWrite $0 "set PATH=$PATH"
195 FileWriteByte $0 "13"
196 FileWriteByte $0 "10"
197 FileWrite $0 "cd "
198 FileWrite $0 $INSTDIR
199 FileWriteByte $0 "13"
200 FileWriteByte $0 "10"
201 FileWrite $0 "$PYPATH\python gtkbrowser.py --pygtk-assets="
202 FileWriteByte $0 "34"
203 FileWrite $0 "$INSTDIR\glade"
204 FileWriteByte $0 "34"
205 FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8"
206 FileWriteByte $0 "13"
207 FileWriteByte $0 "10"
208
209 FileClose $0
210
211 StrCpy $PYINSTALLED "1"
212 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "Python" 1
213 ${Else}
214 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)"
215 ${EndIf}
216 ${Else}
217 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)"
218 ${EndIf}
219 ${Else}
220 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)"
221 ${EndIf}
222 Return
223
224 pydone:
225 MessageBox MB_OK "PyGTK GUI was not installed properly -- problems with creating ascend.bar"
226 SectionEnd
227
228 ;---------------------------------
229
230 Section "Tcl/Tk GUI"
231
232 ${If} $TCLOK != 'OK'
233 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)"
234 ${Else}
235 DetailPrint "--- TCL/TK INTERFACE ---"
236 SetOutPath $INSTDIR\tcltk
237 File /r /x .svn "..\tcltk\TK\*"
238 SetOutPath $INSTDIR
239 File "..\tcltk\generic\interface\ascendtcl.dll"
240 File "..\tcltk\generic\interface\ascend4.exe"
241
242 StrCpy $TCLINSTALLED "!"
243 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "TclTk" 1
244
245 ${EndIf}
246
247 SectionEnd
248
249 ;---------------------------------
250
251 ; Optional section (can be disabled by the user)
252 Section "Start Menu Shortcuts"
253
254 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1
255
256 CreateDirectory "$SMPROGRAMS\ASCEND"
257 CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
258 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0
259
260 ; Link to PyGTK GUI
261 StrCmp $PYINSTALLED "" smdone smpython
262 smpython:
263 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$INSTDIR\ascend.bat" "" "$INSTDIR\glade\ascend.ico" 0 "SW_SHOWMINIMIZED"
264 smdone:
265
266 SectionEnd
267
268 ;------------------------------------------------------------------
269 ; UNINSTALLER
270
271 Section "Uninstall"
272
273 ;--- python components ---
274
275 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
276 IntCmp $0 0 unnopython unpython
277
278 unpython:
279 DetailPrint "--- REMOVING PYTHON COMPONENTS ---"
280 Delete $INSTDIR\_ascpy.dll
281 Delete $INSTDIR\ascend.bat
282 Delete $INSTDIR\*.py
283 Delete $INSTDIR\glade\*.glade
284 Delete $INSTDIR\glade\*.png
285 Delete $INSTDIR\glade\ascend.ico
286 Delete $INSTDIR\glade\*.svg
287 RmDir $INSTDIR\glade
288
289 unnopython:
290
291 ;--- tcl/tk components ---
292
293 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk"
294 ${If} $0 != 0
295 DetailPrint "--- REMOVING TCL/TK COMPONENTS ---"
296 Delete $INSTDIR\ascendtcl.dll
297 RMDir /r $INSTDIR\tcltk
298 ${EndIf}
299
300 ;--- start menu ---
301
302 ReadRegDWORD $1 HKLM "SOFTWARE\ASCEND" "StartMenu"
303 IntCmp $1 0 unnostart unstart
304 unstart:
305 ; Remove shortcuts, if any
306 DetailPrint "--- REMOVING START MENU SHORTCUTS ---"
307 RmDir /r "$SMPROGRAMS\ASCEND"
308
309 unnostart:
310
311 ;--- common components ---
312
313 DetailPrint "--- REMOVING COMMON COMPONENTS ---"
314 ; Remove registry keys
315
316 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND"
317 DeleteRegKey HKLM "SOFTWARE\ASCEND"
318
319 ; Remove files and uninstaller
320
321 Delete $INSTDIR\ascend.dll
322 Delete $INSTDIR\Makefile.bt
323 Delete $INSTDIR\ascend.syn
324 RMDir /r $INSTDIR\models
325
326 ; Remove directories used
327 RMDir "$INSTDIR"
328
329 SectionEnd
330
331 ;---------------------------------------------------------------------
332 ; UTILITY ROUTINES
333
334 Function DetectPython
335 ReadRegStr $R6 HKCU "SOFTWARE\Python\PythonCore\2.4\InstallPath" ""
336 ${If} $R6 == ''
337 ReadRegStr $R6 HKLM "SOFTWARE\Python\PythonCore\2.4\InstallPath" ""
338 ${If} $R6 == ''
339 Push "No registry key found"
340 Push "NOK"
341 Return
342 ${EndIf}
343 ${EndIf}
344
345 ${If} ${FileExists} "$R6\python.exe"
346 Push "$R6"
347 Push "OK"
348 ${Else}
349 Push "No python.exe found"
350 Push "NOK"
351 ${EndIf}
352 FunctionEnd
353
354 ;--------------------------------------------------------------------
355 ; Prefer the current user's installation of GTK, fall back to the local machine
356
357 Function DetectGTK
358 ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
359 ${If} $R6 == ''
360 ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
361 ${If} $R6 == ''
362 Push "No GTK registry key found"
363 Push "NOK"
364 Return
365 ${EndIf}
366 ${EndIf}
367
368 ${If} ${FileExists} "$R6\libgtk-win32-2.0-0.dll"
369 Push "$R6"
370 Push "OK"
371 ${Else}
372 Push "No libgtk-win32-2.0-0.dll found in'$R6'"
373 Push "NOK"
374 ${EndIf}
375 FunctionEnd
376
377 ;--------------------------------------------------------------------
378 ; Prefer the current user's installation of GTK, fall back to the local machine
379
380 Function DetectGlade
381 ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
382 ${If} $R6 == ''
383 ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
384 ${If} $R6 == ''
385 Push "No GTK registry key found"
386 Push "NOK"
387 Return
388 ${EndIf}
389 ${EndIf}
390
391 ${If} ${FileExists} "$R6\libglade-2.0-0.dll"
392 Push "$R6"
393 Push "OK"
394 ${Else}
395 Push "No libglade-2.0-0.dll found in'$R6'"
396 Push "NOK"
397 ${EndIf}
398 FunctionEnd
399
400 ;--------------------------------------------------------------------
401
402 Function DetectTcl
403 ReadRegStr $R6 HKCU "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
404 ${If} $R6 == ''
405 ReadRegStr $R6 HKLM "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
406 ${If} $R6 == ''
407 Push "No 'CurrentVersion' registry key"
408 Push "NOK"
409 Return
410 ${Else}
411 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
412 ReadRegStr $R8 HKLM $R7 ""
413 ${EndIf}
414 ${Else}
415 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
416 ReadRegStr $R8 HKCU $R7 ""
417 ${EndIf}
418
419 ${If} $R8 == ''
420 Push "No value for $R7"
421 Push "NOK"
422 ${Else}
423 Push "$R8\bin"
424 Push "OK"
425 ${EndIf}
426 FunctionEnd

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