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

Annotation of /trunk/pygtk/create.nsi

Parent Directory Parent Directory | Revision Log Revision Log


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

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