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

Annotation of /trunk/pygtk/create.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 868 - (hide annotations) (download)
Wed Oct 4 09:17:38 2006 UTC (17 years, 7 months ago) by johnpye
File size: 9938 byte(s)
Added 'python models' to installer script
Added 'delta_area'.
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 johnpye 861 ;SetCompressor /FINAL zlib
27 johnpye 578 SetCompressor /SOLID lzma
28    
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 johnpye 845 Var /GLOBAL PYOK
50     Var /GLOBAL PYPATH
51     Var /GLOBAL GTKOK
52     Var /GLOBAL GTKPATH
53 johnpye 859 Var /GLOBAL GLADEOK
54     Var /GLOBAL GLADEPATH
55 johnpye 845 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 johnpye 859
72     Call DetectGlade
73     Pop $GLADEOK
74     Pop $GLADEPATH
75 johnpye 845
76     Call DetectTcl
77     Pop $TCLOK
78     Pop $TCLPATH
79    
80     FunctionEnd
81    
82    
83 johnpye 357 ; The stuff to install
84     Section "ASCEND (required)"
85 johnpye 845 SectionIn RO
86 johnpye 357
87 johnpye 845 DetailPrint "--- COMMON FILES ---"
88 johnpye 357
89     ; Set output path to the installation directory.
90     SetOutPath $INSTDIR
91 johnpye 534 File "..\ascend.dll"
92 johnpye 845
93 johnpye 603 ; Model Library
94 johnpye 357 SetOutPath $INSTDIR\models
95 johnpye 627 File /r /x .svn "..\models\*.a4*"
96     File /r /x .svn "..\models\*.bz2"
97 johnpye 669 File /r /x .svn "..\models\*.tcl"
98 johnpye 781 File /r /x .svn "..\models\*.dll" ; extension modules
99 johnpye 868 File /r /x .svn "..\models\*.py"; python modules
100 johnpye 603
101 johnpye 357 SetOutPath $INSTDIR
102     File "Makefile.bt"
103     File "ascend.syn"
104 johnpye 603
105     ; Set 'librarypath' in .ascend.ini
106 johnpye 357 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 johnpye 845 ;--------------------------------
121    
122     Section "PyGTK GUI"
123 johnpye 859 ${If} $PYOK == 'OK'
124     ${If} $GTKOK == 'OK'
125     ${If} $GLADEOK == 'OK'
126     ;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH"
127 johnpye 845
128 johnpye 859 DetailPrint "--- PYTHON INTERFACE ---"
129 johnpye 845
130 johnpye 859 ; Set output path to the installation directory.
131     SetOutPath $INSTDIR
132 johnpye 845
133 johnpye 859 ; Python interface
134     File "_ascpy.dll"
135     File "*.py"
136     SetOutPath $INSTDIR\glade
137     File "glade\*.glade"
138     File "glade\*.png"
139 johnpye 845
140 johnpye 859 ; 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 johnpye 860 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 johnpye 859 FileWriteByte $0 "13"
160     FileWriteByte $0 "10"
161 johnpye 845
162 johnpye 859 FileClose $0
163 johnpye 845
164 johnpye 859 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 johnpye 845
177     pydone:
178 johnpye 859 MessageBox MB_OK "PyGTK GUI was not installed properly -- problems with creating ascend.bar"
179 johnpye 845 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 johnpye 357 ; Optional section (can be disabled by the user)
205     Section "Start Menu Shortcuts"
206 johnpye 845
207     WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1
208 johnpye 357
209     CreateDirectory "$SMPROGRAMS\ASCEND"
210     CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
211 johnpye 845 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 johnpye 357 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$INSTDIR\ascend.bat" "" "$INSTDIR\ascend.bat" 0
217 johnpye 845 smdone:
218 johnpye 357
219     SectionEnd
220    
221 johnpye 845 ;------------------------------------------------------------------
222     ; UNINSTALLER
223 johnpye 357
224 johnpye 845 Section "Uninstall"
225 johnpye 357
226 johnpye 845 ;--- python components ---
227    
228     ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
229     IntCmp $0 0 unnopython unpython
230 johnpye 357
231 johnpye 845 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 johnpye 357
240 johnpye 845 unnopython:
241 johnpye 357
242 johnpye 845 ;--- tcl/tk components ---
243 johnpye 357
244 johnpye 845 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 johnpye 357
251 johnpye 845 ;--- 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 johnpye 357 SectionEnd
281 johnpye 845
282     ;---------------------------------------------------------------------
283     ; UTILITY ROUTINES
284    
285     Function DetectPython
286 johnpye 859 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 johnpye 845
305 johnpye 859 ;--------------------------------------------------------------------
306     ; Prefer the current user's installation of GTK, fall back to the local machine
307 johnpye 845
308 johnpye 859 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 johnpye 845 FunctionEnd
327    
328     ;--------------------------------------------------------------------
329 johnpye 859 ; Prefer the current user's installation of GTK, fall back to the local machine
330 johnpye 845
331 johnpye 859 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 johnpye 845
342 johnpye 859 ${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 johnpye 845 FunctionEnd
350    
351     ;--------------------------------------------------------------------
352    
353     Function DetectTcl
354 johnpye 859 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 johnpye 845 FunctionEnd

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