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

Contents of /trunk/pygtk/create.nsi

Parent Directory Parent Directory | Revision Log Revision Log


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

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