/[ascend]/branches/georgy/nsis/installer.nsi
ViewVC logotype

Contents of /branches/georgy/nsis/installer.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 868 - (show annotations) (download)
Wed Oct 4 09:17:38 2006 UTC (12 years, 6 months ago) by johnpye
Original Path: trunk/pygtk/create.nsi
File size: 9938 byte(s)
Added 'python models' to installer script
Added 'delta_area'.
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 PYOK
50 Var /GLOBAL PYPATH
51 Var /GLOBAL GTKOK
52 Var /GLOBAL GTKPATH
53 Var /GLOBAL GLADEOK
54 Var /GLOBAL GLADEPATH
55 Var /GLOBAL PYINSTALLED
56 Var /GLOBAL TCLOK
57 Var /GLOBAL TCLPATH
58 Var /GLOBAL TCLINSTALLED
59
60 Function .onInit
61 StrCpy $PYINSTALLED ""
62 StrCpy $TCLINSTALLED ""
63
64 Call DetectPython
65 Pop $PYOK
66 Pop $PYPATH
67
68 Call DetectGTK
69 Pop $GTKOK
70 Pop $GTKPATH
71
72 Call DetectGlade
73 Pop $GLADEOK
74 Pop $GLADEPATH
75
76 Call DetectTcl
77 Pop $TCLOK
78 Pop $TCLPATH
79
80 FunctionEnd
81
82
83 ; The stuff to install
84 Section "ASCEND (required)"
85 SectionIn RO
86
87 DetailPrint "--- COMMON FILES ---"
88
89 ; Set output path to the installation directory.
90 SetOutPath $INSTDIR
91 File "..\ascend.dll"
92
93 ; Model Library
94 SetOutPath $INSTDIR\models
95 File /r /x .svn "..\models\*.a4*"
96 File /r /x .svn "..\models\*.bz2"
97 File /r /x .svn "..\models\*.tcl"
98 File /r /x .svn "..\models\*.dll" ; extension modules
99 File /r /x .svn "..\models\*.py"; python modules
100
101 SetOutPath $INSTDIR
102 File "Makefile.bt"
103 File "ascend.syn"
104
105 ; Set 'librarypath' in .ascend.ini
106 WriteINIstr $APPDATA\.ascend.ini Directories librarypath "$DOCUMENTS\ascdata;$INSTDIR\models"
107
108 ; Write the installation path into the registry
109 WriteRegStr HKLM SOFTWARE\ASCEND "Install_Dir" "$INSTDIR"
110
111 ; Write the uninstall keys for Windows
112 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "DisplayName" "ASCEND Simulation Environment"
113 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "UninstallString" '"$INSTDIR\uninstall.exe"'
114 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoModify" 1
115 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoRepair" 1
116 WriteUninstaller "uninstall.exe"
117
118 SectionEnd
119
120 ;--------------------------------
121
122 Section "PyGTK GUI"
123 ${If} $PYOK == 'OK'
124 ${If} $GTKOK == 'OK'
125 ${If} $GLADEOK == 'OK'
126 ;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH"
127
128 DetailPrint "--- PYTHON INTERFACE ---"
129
130 ; Set output path to the installation directory.
131 SetOutPath $INSTDIR
132
133 ; Python interface
134 File "_ascpy.dll"
135 File "*.py"
136 SetOutPath $INSTDIR\glade
137 File "glade\*.glade"
138 File "glade\*.png"
139
140 ; Create 'ascend.bat' launcher for PyGTK interface
141 ClearErrors
142 FileOpen $0 $INSTDIR\ascend.bat w
143 IfErrors pydone
144 FileWrite $0 "@echo off"
145 FileWriteByte $0 "13"
146 FileWriteByte $0 "10"
147 FileWrite $0 "set PATH=$PYPATH;$GTKPATH"
148 FileWriteByte $0 "13"
149 FileWriteByte $0 "10"
150 FileWrite $0 "cd "
151 FileWrite $0 $INSTDIR
152 FileWriteByte $0 "13"
153 FileWriteByte $0 "10"
154 FileWrite $0 "$PYPATH\python gtkbrowser.py --pygtk-assets="
155 FileWriteByte $0 "34"
156 FileWrite $0 "$INSTDIR\glade"
157 FileWriteByte $0 "34"
158 FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8"
159 FileWriteByte $0 "13"
160 FileWriteByte $0 "10"
161
162 FileClose $0
163
164 StrCpy $PYINSTALLED "1"
165 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "Python" 1
166 ${Else}
167 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)"
168 ${EndIf}
169 ${Else}
170 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)"
171 ${EndIf}
172 ${Else}
173 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)"
174 ${EndIf}
175 Return
176
177 pydone:
178 MessageBox MB_OK "PyGTK GUI was not installed properly -- problems with creating ascend.bar"
179 SectionEnd
180
181 ;---------------------------------
182
183 Section "Tcl/Tk GUI"
184
185 ${If} $TCLOK != 'OK'
186 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)"
187 ${Else}
188 DetailPrint "--- TCL/TK INTERFACE ---"
189 SetOutPath $INSTDIR\tcltk
190 File /r /x .svn "..\tcltk\TK\*"
191 SetOutPath $INSTDIR
192 File "..\tcltk\generic\interface\ascendtcl.dll"
193 File "..\tcltk\generic\interface\ascend4.exe"
194
195 StrCpy $TCLINSTALLED "!"
196 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "TclTk" 1
197
198 ${EndIf}
199
200 SectionEnd
201
202 ;---------------------------------
203
204 ; Optional section (can be disabled by the user)
205 Section "Start Menu Shortcuts"
206
207 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1
208
209 CreateDirectory "$SMPROGRAMS\ASCEND"
210 CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
211 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0
212
213 ; Link to PyGTK GUI
214 StrCmp $PYINSTALLED "" smdone smpython
215 smpython:
216 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$INSTDIR\ascend.bat" "" "$INSTDIR\ascend.bat" 0
217 smdone:
218
219 SectionEnd
220
221 ;------------------------------------------------------------------
222 ; UNINSTALLER
223
224 Section "Uninstall"
225
226 ;--- python components ---
227
228 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
229 IntCmp $0 0 unnopython unpython
230
231 unpython:
232 DetailPrint "--- REMOVING PYTHON COMPONENTS ---"
233 Delete $INSTDIR\_ascpy.dll
234 Delete $INSTDIR\ascend.bat
235 Delete $INSTDIR\*.py
236 Delete $INSTDIR\glade\*.glade
237 Delete $INSTDIR\glade\*.png
238 RmDir $INSTDIR\glade
239
240 unnopython:
241
242 ;--- tcl/tk components ---
243
244 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk"
245 ${If} $0 != 0
246 DetailPrint "--- REMOVING TCL/TK COMPONENTS ---"
247 Delete $INSTDIR\ascendtcl.dll
248 RMDir /r $INSTDIR\tcltk
249 ${EndIf}
250
251 ;--- start menu ---
252
253 ReadRegDWORD $1 HKLM "SOFTWARE\ASCEND" "StartMenu"
254 IntCmp $1 0 unnostart unstart
255 unstart:
256 ; Remove shortcuts, if any
257 DetailPrint "--- REMOVING START MENU SHORTCUTS ---"
258 RmDir /r "$SMPROGRAMS\ASCEND"
259
260 unnostart:
261
262 ;--- common components ---
263
264 DetailPrint "--- REMOVING COMMON COMPONENTS ---"
265 ; Remove registry keys
266
267 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND"
268 DeleteRegKey HKLM "SOFTWARE\ASCEND"
269
270 ; Remove files and uninstaller
271
272 Delete $INSTDIR\ascend.dll
273 Delete $INSTDIR\Makefile.bt
274 Delete $INSTDIR\ascend.syn
275 RMDir /r $INSTDIR\models
276
277 ; Remove directories used
278 RMDir "$INSTDIR"
279
280 SectionEnd
281
282 ;---------------------------------------------------------------------
283 ; UTILITY ROUTINES
284
285 Function DetectPython
286 ReadRegStr $R6 HKCU "SOFTWARE\Python\PythonCore\2.4\InstallPath" ""
287 ${If} $R6 == ''
288 ReadRegStr $R6 HKLM "SOFTWARE\Python\PythonCore\2.4\InstallPath" ""
289 ${If} $R6 == ''
290 Push "No registry key found"
291 Push "NOK"
292 Return
293 ${EndIf}
294 ${EndIf}
295
296 ${If} ${FileExists} "$R6\python.exe"
297 Push "$R6"
298 Push "OK"
299 ${Else}
300 Push "No python.exe found"
301 Push "NOK"
302 ${EndIf}
303 FunctionEnd
304
305 ;--------------------------------------------------------------------
306 ; Prefer the current user's installation of GTK, fall back to the local machine
307
308 Function DetectGTK
309 ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
310 ${If} $R6 == ''
311 ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
312 ${If} $R6 == ''
313 Push "No GTK registry key found"
314 Push "NOK"
315 Return
316 ${EndIf}
317 ${EndIf}
318
319 ${If} ${FileExists} "$R6\libgtk-win32-2.0-0.dll"
320 Push "$R6"
321 Push "OK"
322 ${Else}
323 Push "No libgtk-win32-2.0-0.dll found in'$R6'"
324 Push "NOK"
325 ${EndIf}
326 FunctionEnd
327
328 ;--------------------------------------------------------------------
329 ; Prefer the current user's installation of GTK, fall back to the local machine
330
331 Function DetectGlade
332 ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
333 ${If} $R6 == ''
334 ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
335 ${If} $R6 == ''
336 Push "No GTK registry key found"
337 Push "NOK"
338 Return
339 ${EndIf}
340 ${EndIf}
341
342 ${If} ${FileExists} "$R6\libglade-2.0-0.dll"
343 Push "$R6"
344 Push "OK"
345 ${Else}
346 Push "No libglade-2.0-0.dll found in'$R6'"
347 Push "NOK"
348 ${EndIf}
349 FunctionEnd
350
351 ;--------------------------------------------------------------------
352
353 Function DetectTcl
354 ReadRegStr $R6 HKCU "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
355 ${If} $R6 == ''
356 ReadRegStr $R6 HKLM "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
357 ${If} $R6 == ''
358 Push "No 'CurrentVersion' registry key"
359 Push "NOK"
360 Return
361 ${Else}
362 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
363 ReadRegStr $R8 HKLM $R7 ""
364 ${EndIf}
365 ${Else}
366 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
367 ReadRegStr $R8 HKCU $R7 ""
368 ${EndIf}
369
370 ${If} $R8 == ''
371 Push "No value for $R7"
372 Push "NOK"
373 ${Else}
374 Push "$R8\bin"
375 Push "OK"
376 ${EndIf}
377 FunctionEnd

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