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

Contents of /trunk/pygtk/create.nsi

Parent Directory Parent Directory | Revision Log Revision Log


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

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