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

Annotation of /trunk/pygtk/create.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1461 - (hide annotations) (download)
Sat Jun 2 13:54:06 2007 UTC (15 years, 9 months ago) by jpye
File size: 14005 byte(s)
Added file association for .A4C and .A4L files to ASCEND in Windows Installer.
Fixed Windows icons.
1 johnpye 845 ; NSIS script to create an ASCEND binary installer.
2     ; by John Pye, 2006.
3 johnpye 357 ;
4 johnpye 845 ; Based on example2.nsi from the NSIS distribution.
5     ;
6 johnpye 628 ; This script is based on example1.nsi, but it remembers the directory,
7 johnpye 357 ; 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 johnpye 818 Name "ASCEND"
15 johnpye 357
16 johnpye 845 !include LogicLib.nsh
17    
18 johnpye 357 ; The file to write
19 johnpye 578 !ifdef OUTFILE
20     OutFile ${OUTFILE}.exe
21     !else
22     OutFile ascend-setup.exe
23     !endif
24 johnpye 357
25 johnpye 465
26 jpye 1422 ;SetCompressor /FINAL zlib
27     SetCompressor /SOLID lzma
28 johnpye 578
29 johnpye 357 ; 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 jpye 1381 Var /GLOBAL DEFAULTPATH
50 johnpye 845 Var /GLOBAL PYOK
51     Var /GLOBAL PYPATH
52     Var /GLOBAL GTKOK
53     Var /GLOBAL GTKPATH
54 johnpye 859 Var /GLOBAL GLADEOK
55     Var /GLOBAL GLADEPATH
56 johnpye 845 Var /GLOBAL PYINSTALLED
57     Var /GLOBAL TCLOK
58     Var /GLOBAL TCLPATH
59     Var /GLOBAL TCLINSTALLED
60 jpye 1381 Var /GLOBAL PATH
61 johnpye 845
62     Function .onInit
63     StrCpy $PYINSTALLED ""
64     StrCpy $TCLINSTALLED ""
65 jpye 1381
66     ExpandEnvStrings $DEFAULTPATH "%WINDIR%;%WINDIR%\system32"
67 johnpye 845
68     Call DetectPython
69     Pop $PYOK
70     Pop $PYPATH
71    
72     Call DetectGTK
73     Pop $GTKOK
74     Pop $GTKPATH
75 johnpye 859
76     Call DetectGlade
77     Pop $GLADEOK
78     Pop $GLADEPATH
79 johnpye 845
80     Call DetectTcl
81     Pop $TCLOK
82     Pop $TCLPATH
83    
84 jpye 1381 StrCpy $PATH "$DEFAULTPATH;$PYPATH;$GTKPATH"
85    
86 johnpye 845 FunctionEnd
87    
88    
89 johnpye 357 ; The stuff to install
90     Section "ASCEND (required)"
91 johnpye 922 SectionIn RO
92 johnpye 357
93 johnpye 922 DetailPrint "--- COMMON FILES ---"
94    
95     ; Set output path to the installation directory.
96     SetOutPath $INSTDIR
97     File "..\ascend.dll"
98     File "..\ascend-config"
99 johnpye 603
100 johnpye 922 ; 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 johnpye 603
107 johnpye 922 SetOutPath $INSTDIR
108     File "Makefile.bt"
109 jpye 1422 File "..\tools\textpad\ascend.syn"
110 johnpye 922
111 johnpye 1076 ${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 johnpye 922
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 jpye 1381 FileWrite $0 "set PATH=$PATH"
143 johnpye 922 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 johnpye 357 SectionEnd
164    
165 johnpye 845 ;--------------------------------
166    
167     Section "PyGTK GUI"
168 johnpye 859 ${If} $PYOK == 'OK'
169     ${If} $GTKOK == 'OK'
170     ${If} $GLADEOK == 'OK'
171     ;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH"
172 johnpye 845
173 johnpye 859 DetailPrint "--- PYTHON INTERFACE ---"
174 johnpye 845
175 johnpye 859 ; Set output path to the installation directory.
176     SetOutPath $INSTDIR
177 johnpye 845
178 johnpye 859 ; Python interface
179     File "_ascpy.dll"
180     File "*.py"
181 jpye 1461 File "glade\ascend.ico"
182     File "glade\ascend-doc.ico"
183    
184 johnpye 859 SetOutPath $INSTDIR\glade
185     File "glade\*.glade"
186     File "glade\*.png"
187 jpye 1432 File "glade\*.svg"
188 johnpye 845
189 johnpye 859 ; Create 'ascend.bat' launcher for PyGTK interface
190     ClearErrors
191     FileOpen $0 $INSTDIR\ascend.bat w
192     IfErrors pydone
193     FileWrite $0 "@echo off"
194     FileWriteByte $0 "13"
195     FileWriteByte $0 "10"
196 jpye 1381 FileWrite $0 "set PATH=$PATH"
197 johnpye 859 FileWriteByte $0 "13"
198     FileWriteByte $0 "10"
199     FileWrite $0 "cd "
200     FileWrite $0 $INSTDIR
201     FileWriteByte $0 "13"
202     FileWriteByte $0 "10"
203 johnpye 860 FileWrite $0 "$PYPATH\python gtkbrowser.py --pygtk-assets="
204     FileWriteByte $0 "34"
205     FileWrite $0 "$INSTDIR\glade"
206     FileWriteByte $0 "34"
207     FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8"
208 johnpye 859 FileWriteByte $0 "13"
209     FileWriteByte $0 "10"
210 johnpye 845
211 johnpye 859 FileClose $0
212 johnpye 845
213 johnpye 859 StrCpy $PYINSTALLED "1"
214     WriteRegDWORD HKLM "SOFTWARE\ASCEND" "Python" 1
215 jpye 1461
216     ;---- file association ----
217    
218     ; back up old value of .a4c file association
219     ReadRegStr $1 HKCR ".a4c" ""
220     StrCmp $1 "" a4cnobkp
221     StrCmp $1 "ASCEND.model" a4cnobkp
222    
223     ; Remember the old file association if necessary
224     WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4C" $1
225    
226     a4cnobkp:
227     WriteRegStr HKCR ".a4c" "" "ASCEND.model"
228    
229     ; back up old value of .a4c file association
230     ReadRegStr $1 HKCR ".a4l" ""
231     StrCmp $1 "" a4lnobkp
232     StrCmp $1 "ASCEND.model" a4lnobkp
233    
234     ; Remember the old file association if necessary
235     WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4L" $1
236    
237     a4lnobkp:
238     WriteRegStr HKCR ".a4l" "" "ASCEND.model"
239    
240     ; So, what does an A4L or A4C file actually do?
241    
242     ReadRegStr $0 HKCR "ASCEND.model" ""
243     StrCmp $0 "" 0 a4cskip
244    
245     WriteRegStr HKCR "ASCEND.model" "" "ASCEND model file"
246     WriteRegStr HKCR "ASCEND.model\shell" "" "open"
247     WriteRegStr HKCR "ASCEND.model\DefaultIcon" "" "$INSTDIR\ascend-doc.ico"
248    
249     a4cskip:
250     WriteRegStr HKCR "ASCEND.model\shell\open\command" "" '$INSTDIR\ascend.bat "%1"'
251    
252     System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
253    
254 johnpye 859 ${Else}
255     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)"
256     ${EndIf}
257     ${Else}
258     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)"
259     ${EndIf}
260     ${Else}
261     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)"
262     ${EndIf}
263     Return
264 johnpye 845
265     pydone:
266 johnpye 859 MessageBox MB_OK "PyGTK GUI was not installed properly -- problems with creating ascend.bar"
267 johnpye 845 SectionEnd
268    
269     ;---------------------------------
270    
271     Section "Tcl/Tk GUI"
272    
273     ${If} $TCLOK != 'OK'
274     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)"
275     ${Else}
276     DetailPrint "--- TCL/TK INTERFACE ---"
277     SetOutPath $INSTDIR\tcltk
278     File /r /x .svn "..\tcltk\TK\*"
279     SetOutPath $INSTDIR
280     File "..\tcltk\generic\interface\ascendtcl.dll"
281     File "..\tcltk\generic\interface\ascend4.exe"
282    
283 jpye 1461 StrCpy $TCLINSTALLED "1"
284 johnpye 845 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "TclTk" 1
285    
286     ${EndIf}
287    
288     SectionEnd
289    
290     ;---------------------------------
291    
292 johnpye 357 ; Optional section (can be disabled by the user)
293     Section "Start Menu Shortcuts"
294 johnpye 845
295     WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1
296 johnpye 357
297     CreateDirectory "$SMPROGRAMS\ASCEND"
298     CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
299 jpye 1461
300     ; Link to Tcl/Tk GUI
301     StrCmp $TCLINSTALLED "" smnotcl 0
302 johnpye 845 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0
303 jpye 1461 smnotcl:
304 johnpye 845
305     ; Link to PyGTK GUI
306 jpye 1461 StrCmp $PYINSTALLED "" smdone 0
307     CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$INSTDIR\ascend.bat" "" "$INSTDIR\ascend.ico" 0 "SW_SHOWMINIMIZED"
308 johnpye 845 smdone:
309 johnpye 357
310     SectionEnd
311    
312 johnpye 845 ;------------------------------------------------------------------
313     ; UNINSTALLER
314 johnpye 357
315 johnpye 845 Section "Uninstall"
316 johnpye 357
317 johnpye 845 ;--- python components ---
318    
319     ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
320     IntCmp $0 0 unnopython unpython
321 johnpye 357
322 johnpye 845 unpython:
323     DetailPrint "--- REMOVING PYTHON COMPONENTS ---"
324     Delete $INSTDIR\_ascpy.dll
325     Delete $INSTDIR\ascend.bat
326     Delete $INSTDIR\*.py
327 jpye 1433 Delete $INSTDIR\*.pyc
328 johnpye 845 Delete $INSTDIR\glade\*.glade
329     Delete $INSTDIR\glade\*.png
330 jpye 1432 Delete $INSTDIR\glade\*.svg
331 johnpye 845 RmDir $INSTDIR\glade
332 jpye 1461 Delete $INSTDIR\ascend.ico
333     Delete $INSTDIR\ascend-doc.ico
334 johnpye 357
335 jpye 1461 ;--- file association (for Python GUI) ---
336    
337     DetailPrint "--- REMOVING FILE ASSOCIATION ---"
338     ;start of restore script
339     ReadRegStr $1 HKCR ".a4c" ""
340     ${If} $1 == "ASCEND.model"
341     ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
342     ${If} $1 == ""
343     ; nothing to restore: delete it
344     DeleteRegKey HKCR ".a4c"
345     ${Else}
346     WriteRegStr HKCR ".a4c" "" $1
347     ${EndIf}
348     DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
349     ${EndIf}
350    
351     ReadRegStr $1 HKCR ".a4l" ""
352     ${If} $1 == "ASCEND.model"
353     ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
354     ${If} $1 == ""
355     ; nothing to restore: delete it
356     DeleteRegKey HKCR ".a4l"
357     ${Else}
358     WriteRegStr HKCR ".a4l" "" $1
359     ${EndIf}
360     DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
361     ${EndIf}
362    
363     DeleteRegKey HKCR "ASCEND.model" ;Delete key with association settings
364    
365     System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
366     ;rest of script
367    
368 johnpye 845 unnopython:
369 johnpye 357
370 johnpye 845 ;--- tcl/tk components ---
371 johnpye 357
372 johnpye 845 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk"
373     ${If} $0 != 0
374     DetailPrint "--- REMOVING TCL/TK COMPONENTS ---"
375     Delete $INSTDIR\ascendtcl.dll
376 jpye 1433 Delete $INSTDIR\ascend4.exe
377 johnpye 845 RMDir /r $INSTDIR\tcltk
378     ${EndIf}
379 johnpye 357
380 johnpye 845 ;--- start menu ---
381    
382     ReadRegDWORD $1 HKLM "SOFTWARE\ASCEND" "StartMenu"
383     IntCmp $1 0 unnostart unstart
384     unstart:
385     ; Remove shortcuts, if any
386     DetailPrint "--- REMOVING START MENU SHORTCUTS ---"
387     RmDir /r "$SMPROGRAMS\ASCEND"
388    
389     unnostart:
390    
391     ;--- common components ---
392    
393     DetailPrint "--- REMOVING COMMON COMPONENTS ---"
394     ; Remove registry keys
395    
396     DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND"
397     DeleteRegKey HKLM "SOFTWARE\ASCEND"
398    
399     ; Remove files and uninstaller
400    
401 jpye 1433 Delete $INSTDIR\ascend-config
402     Delete $INSTDIR\ascend-config.bat
403 johnpye 845 Delete $INSTDIR\ascend.dll
404     Delete $INSTDIR\Makefile.bt
405     Delete $INSTDIR\ascend.syn
406     RMDir /r $INSTDIR\models
407    
408     ; Remove directories used
409    
410 jpye 1433 Delete $INSTDIR\uninstall.exe
411     RMDir $INSTDIR
412    
413 johnpye 357 SectionEnd
414 johnpye 845
415     ;---------------------------------------------------------------------
416     ; UTILITY ROUTINES
417    
418     Function DetectPython
419 johnpye 859 ReadRegStr $R6 HKCU "SOFTWARE\Python\PythonCore\2.4\InstallPath" ""
420     ${If} $R6 == ''
421     ReadRegStr $R6 HKLM "SOFTWARE\Python\PythonCore\2.4\InstallPath" ""
422     ${If} $R6 == ''
423     Push "No registry key found"
424     Push "NOK"
425     Return
426     ${EndIf}
427     ${EndIf}
428    
429     ${If} ${FileExists} "$R6\python.exe"
430     Push "$R6"
431     Push "OK"
432     ${Else}
433     Push "No python.exe found"
434     Push "NOK"
435     ${EndIf}
436     FunctionEnd
437 johnpye 845
438 johnpye 859 ;--------------------------------------------------------------------
439     ; Prefer the current user's installation of GTK, fall back to the local machine
440 johnpye 845
441 johnpye 859 Function DetectGTK
442     ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
443     ${If} $R6 == ''
444     ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
445     ${If} $R6 == ''
446     Push "No GTK registry key found"
447     Push "NOK"
448     Return
449     ${EndIf}
450     ${EndIf}
451    
452     ${If} ${FileExists} "$R6\libgtk-win32-2.0-0.dll"
453     Push "$R6"
454     Push "OK"
455     ${Else}
456     Push "No libgtk-win32-2.0-0.dll found in'$R6'"
457     Push "NOK"
458     ${EndIf}
459 johnpye 845 FunctionEnd
460    
461     ;--------------------------------------------------------------------
462 johnpye 859 ; Prefer the current user's installation of GTK, fall back to the local machine
463 johnpye 845
464 johnpye 859 Function DetectGlade
465     ReadRegStr $R6 HKCU "SOFTWARE\GTK\2.0" "DllPath"
466     ${If} $R6 == ''
467     ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
468     ${If} $R6 == ''
469     Push "No GTK registry key found"
470     Push "NOK"
471     Return
472     ${EndIf}
473     ${EndIf}
474 johnpye 845
475 johnpye 859 ${If} ${FileExists} "$R6\libglade-2.0-0.dll"
476     Push "$R6"
477     Push "OK"
478     ${Else}
479     Push "No libglade-2.0-0.dll found in'$R6'"
480     Push "NOK"
481     ${EndIf}
482 johnpye 845 FunctionEnd
483    
484     ;--------------------------------------------------------------------
485    
486     Function DetectTcl
487 johnpye 859 ReadRegStr $R6 HKCU "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
488     ${If} $R6 == ''
489     ReadRegStr $R6 HKLM "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
490     ${If} $R6 == ''
491     Push "No 'CurrentVersion' registry key"
492     Push "NOK"
493     Return
494     ${Else}
495     StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
496     ReadRegStr $R8 HKLM $R7 ""
497     ${EndIf}
498     ${Else}
499     StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
500     ReadRegStr $R8 HKCU $R7 ""
501     ${EndIf}
502    
503     ${If} $R8 == ''
504     Push "No value for $R7"
505     Push "NOK"
506     ${Else}
507     Push "$R8\bin"
508     Push "OK"
509     ${EndIf}
510 johnpye 845 FunctionEnd

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