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

Contents of /trunk/pygtk/create.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1463 - (show annotations) (download)
Sun Jun 3 02:48:17 2007 UTC (13 years, 1 month ago) by jpye
File size: 13406 byte(s)
Removed 'ascend.bat' hack from installer, changed to
saner 'pythonw.exe' for starting ASCEND on Windows.
Still needs testing on Linux.
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 WriteRegStr HKLM SOFTWARE\ASCEND "GTKLIBS" "$GTKPATH"
135
136 ; Create 'ascend-config.bat' batch file for launching the python script 'ascend-config'.
137 ClearErrors
138 FileOpen $0 $INSTDIR\ascend-config.bat w
139 IfErrors ascendconfigerror
140 FileWrite $0 "@echo off"
141 FileWriteByte $0 "13"
142 FileWriteByte $0 "10"
143 FileWrite $0 "set PATH=$PATH"
144 FileWriteByte $0 "13"
145 FileWriteByte $0 "10"
146 FileWrite $0 "cd "
147 FileWrite $0 $INSTDIR
148 FileWriteByte $0 "13"
149 FileWriteByte $0 "10"
150 FileWrite $0 "$PYPATH\python "
151 FileWriteByte $0 "34"
152 FileWrite $0 "$INSTDIR\ascend-config"
153 FileWriteByte $0 "34"
154 FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8"
155 FileWriteByte $0 "13"
156 FileWriteByte $0 "10"
157
158 FileClose $0
159
160 Return
161 ascendconfigerror:
162 MessageBox MB_OK "The 'ascend-config.bat' file was not installed properly; problems writing to that file."
163
164 SectionEnd
165
166 ;--------------------------------
167
168 Section "PyGTK GUI"
169 ${If} $PYOK == 'OK'
170 ${If} $GTKOK == 'OK'
171 ${If} $GLADEOK == 'OK'
172 ;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH"
173
174 DetailPrint "--- PYTHON INTERFACE ---"
175
176 ; Set output path to the installation directory.
177 SetOutPath $INSTDIR
178
179 ; Python interface
180 File "_ascpy.dll"
181 File "*.py"
182 File "ascend"
183
184 File "glade\ascend.ico"
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 pydone:
245 MessageBox MB_OK "PyGTK GUI was not installed properly -- problems with creating ascend.bar"
246 SectionEnd
247
248 ;---------------------------------
249
250 Section "Tcl/Tk GUI"
251
252 ${If} $TCLOK != 'OK'
253 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)"
254 ${Else}
255 DetailPrint "--- TCL/TK INTERFACE ---"
256 SetOutPath $INSTDIR\tcltk
257 File /r /x .svn "..\tcltk\TK\*"
258 SetOutPath $INSTDIR
259 File "..\tcltk\generic\interface\ascendtcl.dll"
260 File "..\tcltk\generic\interface\ascend4.exe"
261
262 StrCpy $TCLINSTALLED "1"
263 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "TclTk" 1
264
265 ${EndIf}
266
267 SectionEnd
268
269 ;---------------------------------
270
271 ; Optional section (can be disabled by the user)
272 Section "Start Menu Shortcuts"
273
274 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1
275
276 CreateDirectory "$SMPROGRAMS\ASCEND"
277 CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
278
279 ; Link to Tcl/Tk GUI
280 StrCmp $TCLINSTALLED "" smnotcl 0
281 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0
282 smnotcl:
283
284 ; Link to PyGTK GUI
285 StrCmp $PYINSTALLED "" smdone 0
286 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$PYPATH\pythonw.exe" '"$INSTDIR\ascend"' "$INSTDIR\ascend.ico" 0
287 smdone:
288
289 SectionEnd
290
291 ;------------------------------------------------------------------
292 ; UNINSTALLER
293
294 Section "Uninstall"
295
296 ;--- python components ---
297
298 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
299 IntCmp $0 0 unnopython unpython
300
301 unpython:
302 DetailPrint "--- REMOVING PYTHON COMPONENTS ---"
303 Delete $INSTDIR\_ascpy.dll
304 Delete $INSTDIR\ascend
305 Delete $INSTDIR\*.py
306 Delete $INSTDIR\*.pyc
307 Delete $INSTDIR\glade\*.glade
308 Delete $INSTDIR\glade\*.png
309 Delete $INSTDIR\glade\*.svg
310 RmDir $INSTDIR\glade
311 Delete $INSTDIR\ascend.ico
312 Delete $INSTDIR\ascend-doc.ico
313
314 ;--- file association (for Python GUI) ---
315
316 DetailPrint "--- REMOVING FILE ASSOCIATION ---"
317 ;start of restore script
318 ReadRegStr $1 HKCR ".a4c" ""
319 ${If} $1 == "ASCEND.model"
320 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
321 ${If} $1 == ""
322 ; nothing to restore: delete it
323 DeleteRegKey HKCR ".a4c"
324 ${Else}
325 WriteRegStr HKCR ".a4c" "" $1
326 ${EndIf}
327 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
328 ${EndIf}
329
330 ReadRegStr $1 HKCR ".a4l" ""
331 ${If} $1 == "ASCEND.model"
332 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
333 ${If} $1 == ""
334 ; nothing to restore: delete it
335 DeleteRegKey HKCR ".a4l"
336 ${Else}
337 WriteRegStr HKCR ".a4l" "" $1
338 ${EndIf}
339 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
340 ${EndIf}
341
342 DeleteRegKey HKCR "ASCEND.model" ;Delete key with association settings
343
344 System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
345 ;rest of script
346
347 unnopython:
348
349 ;--- tcl/tk components ---
350
351 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk"
352 ${If} $0 != 0
353 DetailPrint "--- REMOVING TCL/TK COMPONENTS ---"
354 Delete $INSTDIR\ascendtcl.dll
355 Delete $INSTDIR\ascend4.exe
356 RMDir /r $INSTDIR\tcltk
357 ${EndIf}
358
359 ;--- start menu ---
360
361 ReadRegDWORD $1 HKLM "SOFTWARE\ASCEND" "StartMenu"
362 IntCmp $1 0 unnostart unstart
363 unstart:
364 ; Remove shortcuts, if any
365 DetailPrint "--- REMOVING START MENU SHORTCUTS ---"
366 RmDir /r "$SMPROGRAMS\ASCEND"
367
368 unnostart:
369
370 ;--- common components ---
371
372 DetailPrint "--- REMOVING COMMON COMPONENTS ---"
373 ; Remove registry keys
374
375 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND"
376 DeleteRegKey HKLM "SOFTWARE\ASCEND"
377
378 ; Remove files and uninstaller
379
380 Delete $INSTDIR\ascend-config
381 Delete $INSTDIR\ascend-config.bat
382 Delete $INSTDIR\ascend.dll
383 Delete $INSTDIR\Makefile.bt
384 Delete $INSTDIR\ascend.syn
385 RMDir /r $INSTDIR\models
386
387 ; Remove directories used
388
389 Delete $INSTDIR\uninstall.exe
390 RMDir $INSTDIR
391
392 SectionEnd
393
394 ;---------------------------------------------------------------------
395 ; UTILITY ROUTINES
396
397 Function DetectPython
398 ReadRegStr $R6 HKCU "SOFTWARE\Python\PythonCore\2.4\InstallPath" ""
399 ${If} $R6 == ''
400 ReadRegStr $R6 HKLM "SOFTWARE\Python\PythonCore\2.4\InstallPath" ""
401 ${If} $R6 == ''
402 Push "No registry key found"
403 Push "NOK"
404 Return
405 ${EndIf}
406 ${EndIf}
407
408 ${If} ${FileExists} "$R6\python.exe"
409 Push "$R6"
410 Push "OK"
411 ${Else}
412 Push "No python.exe found"
413 Push "NOK"
414 ${EndIf}
415 FunctionEnd
416
417 ;--------------------------------------------------------------------
418 ; Prefer the current user's installation of GTK, fall back to the local machine
419
420 Function DetectGTK
421 ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
422 ${If} $R6 == ''
423 ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
424 ${If} $R6 == ''
425 Push "No GTK registry key found"
426 Push "NOK"
427 Return
428 ${EndIf}
429 ${EndIf}
430
431 ${If} ${FileExists} "$R6\libgtk-win32-2.0-0.dll"
432 Push "$R6"
433 Push "OK"
434 ${Else}
435 Push "No libgtk-win32-2.0-0.dll found in'$R6'"
436 Push "NOK"
437 ${EndIf}
438 FunctionEnd
439
440 ;--------------------------------------------------------------------
441 ; Prefer the current user's installation of GTK, fall back to the local machine
442
443 Function DetectGlade
444 ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
445 ${If} $R6 == ''
446 ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
447 ${If} $R6 == ''
448 Push "No GTK registry key found"
449 Push "NOK"
450 Return
451 ${EndIf}
452 ${EndIf}
453
454 ${If} ${FileExists} "$R6\libglade-2.0-0.dll"
455 Push "$R6"
456 Push "OK"
457 ${Else}
458 Push "No libglade-2.0-0.dll found in'$R6'"
459 Push "NOK"
460 ${EndIf}
461 FunctionEnd
462
463 ;--------------------------------------------------------------------
464
465 Function DetectTcl
466 ReadRegStr $R6 HKCU "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
467 ${If} $R6 == ''
468 ReadRegStr $R6 HKLM "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
469 ${If} $R6 == ''
470 Push "No 'CurrentVersion' registry key"
471 Push "NOK"
472 Return
473 ${Else}
474 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
475 ReadRegStr $R8 HKLM $R7 ""
476 ${EndIf}
477 ${Else}
478 StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
479 ReadRegStr $R8 HKCU $R7 ""
480 ${EndIf}
481
482 ${If} $R8 == ''
483 Push "No value for $R7"
484 Push "NOK"
485 ${Else}
486 Push "$R8\bin"
487 Push "OK"
488 ${EndIf}
489 FunctionEnd

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