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

Annotation of /trunk/pygtk/create.nsi

Parent Directory Parent Directory | Revision Log Revision Log


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

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