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

Diff of /trunk/pygtk/create.nsi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 818 by johnpye, Wed Aug 16 12:54:08 2006 UTC revision 845 by johnpye, Sun Sep 17 05:55:09 2006 UTC
# Line 1  Line 1 
1  ; example2.nsi  ; 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,  ; This script is based on example1.nsi, but it remembers the directory,
7  ; has uninstall support and (optionally) installs start menu shortcuts.  ; has uninstall support and (optionally) installs start menu shortcuts.
# Line 10  Line 13 
13  ; The name of the installer  ; The name of the installer
14  Name "ASCEND"  Name "ASCEND"
15    
16    !include LogicLib.nsh
17    
18  ; The file to write  ; The file to write
19  !ifdef OUTFILE  !ifdef OUTFILE
20  OutFile ${OUTFILE}.exe  OutFile ${OUTFILE}.exe
# Line 18  OutFile ascend-setup.exe Line 23  OutFile ascend-setup.exe
23  !endif  !endif
24    
25    
26    ;SetCompressor /FINAL zlib
27  SetCompressor /SOLID lzma  SetCompressor /SOLID lzma
28    
29  ; The default installation directory  ; The default installation directory
# Line 40  UninstPage instfiles Line 46  UninstPage instfiles
46    
47  ;--------------------------------  ;--------------------------------
48    
49    Var /GLOBAL PYOK
50    Var /GLOBAL PYPATH
51    Var /GLOBAL GTKOK
52    Var /GLOBAL GTKPATH
53    Var /GLOBAL PYINSTALLED
54    Var /GLOBAL TCLOK
55    Var /GLOBAL TCLPATH
56    Var /GLOBAL TCLINSTALLED
57    
58    Function .onInit
59        StrCpy $PYINSTALLED ""
60        StrCpy $TCLINSTALLED ""
61    
62        Call DetectPython
63        Pop $PYOK
64        Pop $PYPATH
65        
66        Call DetectGTK
67        Pop $GTKOK
68        Pop $GTKPATH
69        
70        Call DetectTcl
71        Pop $TCLOK
72        Pop $TCLPATH    
73        
74    FunctionEnd
75    
76    
77  ; The stuff to install  ; The stuff to install
78  Section "ASCEND (required)"  Section "ASCEND (required)"
   
79    SectionIn RO    SectionIn RO
80    
81      DetailPrint "--- COMMON FILES ---"
82        
83    ; Set output path to the installation directory.    ; Set output path to the installation directory.
84    SetOutPath $INSTDIR    SetOutPath $INSTDIR
     
   ; Python interface  
   File "_ascpy.dll"  
85    File "..\ascend.dll"    File "..\ascend.dll"
86    File "config.py"    
   File "*.py"  
   SetOutPath $INSTDIR\glade  
   File "glade\*.glade"  
   File "glade\*.png"  
   
87    ; Model Library    ; Model Library
88    SetOutPath $INSTDIR\models    SetOutPath $INSTDIR\models
89    File /r /x .svn "..\models\*.a4*"    File /r /x .svn "..\models\*.a4*"
# Line 64  Section "ASCEND (required)" Line 91  Section "ASCEND (required)"
91    File /r /x .svn "..\models\*.tcl"    File /r /x .svn "..\models\*.tcl"
92    File /r /x .svn "..\models\*.dll" ; extension modules    File /r /x .svn "..\models\*.dll" ; extension modules
93    
   ; Tcl/Tk interface  
   SetOutPath $INSTDIR\tcltk  
   File /r /x .svn "..\tcltk\TK\*"  
   SetOutPath $INSTDIR  
   File "..\tcltk\generic\interface\ascendtcl.dll"  
   File "..\tcltk\generic\interface\ascend4.exe"  
   
94    SetOutPath $INSTDIR    SetOutPath $INSTDIR
95    File "Makefile.bt"    File "Makefile.bt"
96    File "ascend.syn"    File "ascend.syn"
97    
98    ; Set 'librarypath' in .ascend.ini    ; Set 'librarypath' in .ascend.ini
99    WriteINIstr $APPDATA\.ascend.ini Directories librarypath "$DOCUMENTS\ascdata;$INSTDIR\models"    WriteINIstr $APPDATA\.ascend.ini Directories librarypath "$DOCUMENTS\ascdata;$INSTDIR\models"
   
   ; Create 'ascend.bat' launcher for PyGTK interface  
   ClearErrors  
   FileOpen $0 $INSTDIR\ascend.bat w  
   IfErrors done  
   FileWrite $0 "@echo off"  
   FileWriteByte $0 "13"  
   FileWriteByte $0 "10"  
   FileWrite $0 "set PATH=c:\Python24;c:\GTK\bin"  
   FileWriteByte $0 "13"  
   FileWriteByte $0 "10"  
   FileWrite $0 "cd "  
   FileWrite $0 $INSTDIR  
   FileWriteByte $0 "13"  
   FileWriteByte $0 "10"  
   FileWrite $0 "c:\Python24\python gtkbrowser.py %1 %2 %3 %4 %5 %6 %7 %8"  
   FileWriteByte $0 "13"  
   FileWriteByte $0 "10"  
   
   FileClose $0  
   done:  
100        
101    ; Write the installation path into the registry    ; Write the installation path into the registry
102    WriteRegStr HKLM SOFTWARE\ASCEND "Install_Dir" "$INSTDIR"    WriteRegStr HKLM SOFTWARE\ASCEND "Install_Dir" "$INSTDIR"
# Line 111  Section "ASCEND (required)" Line 110  Section "ASCEND (required)"
110        
111  SectionEnd  SectionEnd
112    
113    ;--------------------------------
114    
115    Section "PyGTK GUI"
116    
117        StrCmp $PYOK "OK" pythonfound
118    
119        MessageBox MB_OK "PyGTK GUI can not be installed, because Python was not found on this system. If do you want to use the PyGTK GUI, please check the installation instructions ($PYPATH)"
120        Goto pydone
121    
122    pythonfound:
123    
124        StrCmp $GTKOK "OK" gtkfound
125        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)"
126        Goto pydone
127    
128    gtkfound:
129    
130    ;   MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH"
131    
132        DetailPrint "--- PYTHON INTERFACE ---"
133        
134        ; Set output path to the installation directory.
135        SetOutPath $INSTDIR
136    
137        ; Python interface
138        File "_ascpy.dll"
139        File "*.py"
140        SetOutPath $INSTDIR\glade
141        File "glade\*.glade"
142        File "glade\*.png"
143    
144        ; Create 'ascend.bat' launcher for PyGTK interface
145        ClearErrors
146        FileOpen $0 $INSTDIR\ascend.bat w
147        IfErrors pydone
148        FileWrite $0 "@echo off"
149        FileWriteByte $0 "13"
150        FileWriteByte $0 "10"
151        FileWrite $0 "set PATH=$PYPATH;$GTKPATH"
152        FileWriteByte $0 "13"
153        FileWriteByte $0 "10"
154        FileWrite $0 "cd "
155        FileWrite $0 $INSTDIR
156        FileWriteByte $0 "13"
157        FileWriteByte $0 "10"
158        FileWrite $0 "$PYPATH\python gtkbrowser.py %1 %2 %3 %4 %5 %6 %7 %8"
159        FileWriteByte $0 "13"
160        FileWriteByte $0 "10"
161    
162        FileClose $0
163        
164        StrCpy $PYINSTALLED "1"
165        WriteRegDWORD HKLM "SOFTWARE\ASCEND" "Python" 1
166    pydone:
167    
168    SectionEnd
169    
170    ;---------------------------------
171    
172    Section "Tcl/Tk GUI"
173    
174    ${If} $TCLOK != 'OK'
175        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)"
176    ${Else}
177        DetailPrint "--- TCL/TK INTERFACE ---"
178        SetOutPath $INSTDIR\tcltk
179        File /r /x .svn "..\tcltk\TK\*"
180        SetOutPath $INSTDIR
181        File "..\tcltk\generic\interface\ascendtcl.dll"
182        File "..\tcltk\generic\interface\ascend4.exe"
183        
184        StrCpy $TCLINSTALLED "!"
185        WriteRegDWORD HKLM "SOFTWARE\ASCEND" "TclTk" 1
186    
187    ${EndIf}
188    
189    SectionEnd
190    
191    ;---------------------------------
192    
193  ; Optional section (can be disabled by the user)  ; Optional section (can be disabled by the user)
194  Section "Start Menu Shortcuts"  Section "Start Menu Shortcuts"
195      
196      WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1
197    
198    CreateDirectory "$SMPROGRAMS\ASCEND"    CreateDirectory "$SMPROGRAMS\ASCEND"
199    CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0    CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
   CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$INSTDIR\ascend.bat" "" "$INSTDIR\ascend.bat" 0  
200    CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0    CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0
201    
202      ; Link to PyGTK GUI
203      StrCmp $PYINSTALLED "" smdone smpython
204    smpython:
205      CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$INSTDIR\ascend.bat" "" "$INSTDIR\ascend.bat" 0
206    smdone:
207        
208  SectionEnd  SectionEnd
209    
210  ;--------------------------------  ;------------------------------------------------------------------
211    ; UNINSTALLER
 ; Uninstaller  
212    
213  Section "Uninstall"  Section "Uninstall"
214    
215    ;--- python components ---
216    
217        ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
218        IntCmp $0 0 unnopython unpython
219        
220    ; Remove registry keys  unpython:
221    DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND"      DetailPrint "--- REMOVING PYTHON COMPONENTS ---"
222    DeleteRegKey HKLM SOFTWARE\ASCEND      Delete $INSTDIR\_ascpy.dll
223        Delete $INSTDIR\ascend.bat
224    ; Remove files and uninstaller      Delete $INSTDIR\*.py
225    Delete $INSTDIR\_ascpy.dll      Delete $INSTDIR\glade\*.glade
226    Delete $INSTDIR\ascendtcl.dll      Delete $INSTDIR\glade\*.png
227    Delete $INSTDIR\ascend.dll      RmDir $INSTDIR\glade
228    Delete $INSTDIR\ascend.bat  
229    Delete $INSTDIR\*.py  unnopython:
230    Delete $INSTDIR\glade\*  
231    Delete $INSTDIR\Makefile.bt  ;--- tcl/tk components ---
232    Delete $INSTDIR\ascend.syn  
233    Delete $INSTDIR\models\*      ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk"
234    Delete $INSTDIR\models\johnpye\*      ${If} $0 != 0
235    RMDir /r $INSTDIR\tcltk          DetailPrint "--- REMOVING TCL/TK COMPONENTS ---"
236    RMDir $INSTDIR\models\johnpye          Delete $INSTDIR\ascendtcl.dll
237    RMDIR $INSTDIR\models          RMDir /r $INSTDIR\tcltk
238        ${EndIf}
239    ; Remove shortcuts, if any  
240    Delete "$SMPROGRAMS\ASCEND\*.*"  ;--- start menu ---
241    
242    ; Remove directories used      ReadRegDWORD $1 HKLM "SOFTWARE\ASCEND" "StartMenu"
243    RMDir "$SMPROGRAMS\ASCEND"      IntCmp $1 0 unnostart unstart
244    RMDir "$INSTDIR"  unstart:
245        ; Remove shortcuts, if any
246        DetailPrint "--- REMOVING START MENU SHORTCUTS ---"
247        RmDir /r "$SMPROGRAMS\ASCEND"
248    
249    unnostart:
250    
251    ;--- common components ---
252    
253        DetailPrint "--- REMOVING COMMON COMPONENTS ---"
254        ; Remove registry keys
255    
256        DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND"
257        DeleteRegKey HKLM "SOFTWARE\ASCEND"
258    
259        ; Remove files and uninstaller
260    
261        Delete $INSTDIR\ascend.dll
262        Delete $INSTDIR\Makefile.bt
263        Delete $INSTDIR\ascend.syn
264        RMDir /r $INSTDIR\models
265    
266        ; Remove directories used
267        RMDir "$INSTDIR"
268    
269  SectionEnd  SectionEnd
270    
271    ;---------------------------------------------------------------------
272    ; UTILITY ROUTINES
273    
274    Function DetectPython
275      ReadRegStr $R6 HKCU "SOFTWARE\Python\PythonCore\2.4\InstallPath" ""
276      StrCmp $R6 "" NoFound1
277    
278      IfFileExists "$R6\python.exe" 0 NoFound
279      Push "$R6"
280      Push "OK"
281      Return
282    
283    NoFound:
284      Push "No python.exe found"
285      Push "NOK"
286      Return
287    
288    NoFound1:
289      Push "No registry key found"
290      Push "NOK"
291      Return
292      
293    FunctionEnd
294    
295    ;--------------------------------------------------------------------
296    
297    Function DetectGTK
298      ReadRegStr $R6 HKLM "SOFTWARE\GTK\2.0" "DllPath"
299      StrCmp $R6 "" GtkNoFound
300      IfFileExists "$R6\pkg-config.exe" 0 GtkNoFound1
301      Push "$R6"
302      Push "OK"
303      Return
304    
305    GtkNoFound:
306      Push "No registry key"
307      Push "NOK"
308      Return
309      
310    GtkNoFound1:
311      Push "No pkg-config.exe found"
312      Push "NOK"
313      Return
314    
315    FunctionEnd
316    
317    ;--------------------------------------------------------------------
318    
319    Function DetectTcl
320      ReadRegStr $R6 HKLM "SOFTWARE\ActiveState\ActiveTcl" "CurrentVersion"
321      ${If} $R6 == ''
322        Push "No 'CurrentVersion' registry key"
323        Push "NOK"
324      ${Else}
325        StrCpy $R7 "SOFTWARE\ActiveState\ActiveTcl\$R6"
326        ReadRegStr $R8 HKLM $R7 ""
327        ${If} $R8 == ''
328            Push "No value for $R7"
329            Push "NOK"
330        ${Else}
331            Push "$R8\bin"
332            Push "OK"
333        ${EndIf}
334      ${EndIf}
335    FunctionEnd
336      
337      

Legend:
Removed from v.818  
changed lines
  Added in v.845

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