/[ascend]/trunk/installer.nsi
ViewVC logotype

Contents of /trunk/installer.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1569 - (show annotations) (download)
Fri Aug 3 13:32:44 2007 UTC (12 years, 6 months ago) by jpye
File size: 15468 byte(s)
Using 'InstallOptions' stuff in NSIS installer for selection of dependencies.
1 ; NSIS script to create an ASCEND binary installer for Windows
2 ; by John Pye, 2006-2007.
3 ;
4 ;--------------------------------
5
6 ; The name of the installer
7
8 !ifndef VERSION
9 !define VERSION 0.svn
10 !endif
11
12 Name "ASCEND ${VERSION}"
13
14 ;SetCompressor /FINAL zlib
15 SetCompressor /SOLID lzma
16
17 !include LogicLib.nsh
18 !include nsDialogs.nsh
19
20 !include dependencies.nsi
21 !include detect.nsi
22 !include download.nsi
23
24 !ifndef PYVERSION
25 !define PYVERSION "2.5"
26 !endif
27
28 !ifndef PYPATCH
29 !define PYPATCH ".1"
30 !endif
31
32 ; The file to write
33 !ifdef OUTFILE
34 OutFile ${OUTFILE}
35 !else
36 OutFile "ascend-${VERSION}-py${PYVERSION}.exe"
37 !endif
38
39
40 ; The default installation directory
41 InstallDir $PROGRAMFILES\ASCEND
42
43 ; Registry key to check for directory (so if you install again, it will
44 ; overwrite the old one automatically)
45 InstallDirRegKey HKLM "Software\ASCEND" "Install_Dir"
46
47 ;--------------------------------
48
49 ; Pages
50
51 Page license
52 LicenseData LICENSE.txt
53
54 Page components
55 Page directory
56 Page custom dependenciesCreate dependenciesLeave
57 Page instfiles
58
59 UninstPage uninstConfirm
60 UninstPage instfiles
61
62 ;--------------------------------
63
64 Var /GLOBAL DEFAULTPATH
65 Var /GLOBAL PYOK
66 Var /GLOBAL PYPATH
67 Var /GLOBAL GTKOK
68 Var /GLOBAL GTKPATH
69 Var /GLOBAL GLADEOK
70 Var /GLOBAL PYGTKOK
71 Var /GLOBAL PYGOBJECTOK
72 Var /GLOBAL PYCAIROOK
73 Var /GLOBAL GLADEPATH
74 Var /GLOBAL PYINSTALLED
75 Var /GLOBAL TCLOK
76 Var /GLOBAL TCLPATH
77 Var /GLOBAL TCLINSTALLED
78 Var /GLOBAL PATH
79
80 Var /GLOBAL PYDOWNLOAD
81 Var /GLOBAL PYGTKDOWNLOAD
82 Var /GLOBAL PYGOBJECTDOWNLOAD
83 Var /GLOBAL PYCAIRODOWNLOAD
84 Var /GLOBAL GTKDOWNLOAD
85
86 Function .onInit
87 StrCpy $PYINSTALLED ""
88 StrCpy $TCLINSTALLED ""
89
90 ExpandEnvStrings $DEFAULTPATH "%WINDIR%;%WINDIR%\system32"
91
92 Call DetectPython
93 Pop $PYOK
94 Pop $PYPATH
95
96 Call DetectGTK
97 Pop $GTKOK
98 Pop $GTKPATH
99
100 Call DetectGlade
101 Pop $GLADEOK
102 Pop $GLADEPATH
103
104 Call DetectTcl
105 Pop $TCLOK
106 Pop $TCLPATH
107
108 Call DetectPyGTK
109 Pop $PYGTKOK
110
111 Call DetectPyGObject
112 Pop $PYGOBJECTOK
113
114 Call DetectPyCairo
115 Pop $PYCAIROOK
116
117 StrCpy $PATH "$DEFAULTPATH;$PYPATH;$GTKPATH"
118
119 FunctionEnd
120
121 ; The stuff to install
122 Section "ASCEND (required)"
123 SectionIn RO
124
125 DetailPrint "--- COMMON FILES ---"
126
127 ; Set output path to the installation directory.
128 SetOutPath $INSTDIR
129 File "ascend.dll"
130 File "ascend-config"
131 File "pygtk\glade\ascend.ico"
132 File "LICENSE.txt"
133 File "CHANGELOG.txt"
134 File "README-windows.txt"
135
136 ; Model Library
137 SetOutPath $INSTDIR\models
138 File /r /x .svn "models\*.a4*"
139 File /r /x .svn "models\*.tcl"
140 File /r /x .svn "models\*.dll" ; extension modules
141 File /r /x .svn "models\*.py"; python modules
142
143 SetOutPath $INSTDIR\solvers
144 File "solvers\qrslv\qrslv.dll"
145 File "solvers\conopt\conopt.dll"
146 File "solvers\lrslv\lrslv.dll"
147 File "solvers\cmslv\cmslv.dll"
148 File "solvers\lsode\lsode.dll"
149 File "solvers\ida\ida.dll"
150
151 SetOutPath $INSTDIR
152 ;File "Makefile.bt"
153 File "tools\textpad\ascend.syn"
154
155 ${If} ${FileExists} "$APPDATA\.ascend.ini"
156 MessageBox MB_OK "The '$APPDATA\.ascend.ini' is NOT being updated. Manually delete this file if ASCEND doesn't behave as expected."
157 ${Else}
158 ; Set 'librarypath' in .ascend.ini
159 WriteINIstr $APPDATA\.ascend.ini Directories librarypath "$DOCUMENTS\ascdata;$INSTDIR\models"
160 ${EndIf}
161
162 ; Write the installation path into the registry
163 WriteRegStr HKLM SOFTWARE\ASCEND "Install_Dir" "$INSTDIR"
164
165 ; Write the uninstall keys for Windows
166 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "DisplayName" "ASCEND Simulation Environment"
167 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "UninstallString" '"$INSTDIR\uninstall.exe"'
168 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoModify" 1
169 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoRepair" 1
170 WriteUninstaller "uninstall.exe"
171
172 ; Write file locations to the registry for access from ascend-config
173 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_LIB" "$INSTDIR"
174 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_BIN" "$INSTDIR"
175 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_INCLUDE" "$INSTDIR\include"
176 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_ASCDATA" "$INSTDIR"
177 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_MODELS" "$INSTDIR\models"
178 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_SOLVERS" "$INSTDIR\solvers"
179 WriteRegStr HKLM SOFTWARE\ASCEND "GTKLIBS" "$GTKPATH"
180
181 ; Create 'ascend-config.bat' batch file for launching the python script 'ascend-config'.
182 ClearErrors
183 FileOpen $0 $INSTDIR\ascend-config.bat w
184 IfErrors ascendconfigerror
185 FileWrite $0 "@echo off"
186 FileWriteByte $0 "13"
187 FileWriteByte $0 "10"
188 FileWrite $0 "set PATH=$PATH"
189 FileWriteByte $0 "13"
190 FileWriteByte $0 "10"
191 FileWrite $0 "cd "
192 FileWrite $0 $INSTDIR
193 FileWriteByte $0 "13"
194 FileWriteByte $0 "10"
195 FileWrite $0 "$PYPATH\python "
196 FileWriteByte $0 "34"
197 FileWrite $0 "$INSTDIR\ascend-config"
198 FileWriteByte $0 "34"
199 FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8"
200 FileWriteByte $0 "13"
201 FileWriteByte $0 "10"
202
203 FileClose $0
204
205 Return
206 ascendconfigerror:
207 MessageBox MB_OK "The 'ascend-config.bat' file was not installed properly; problems writing to that file."
208
209 SectionEnd
210
211 !define PYTHON_VERSION "${PYVERSION}${PYPATCH}"
212 !define PYTHON_FN "python-${PYTHON_VERSION}.msi"
213 !define PYTHON_URL "http://www.python.org/ftp/python/${PYTHON_VERSION}/${PYTHON_FN}"
214 !define PYTHON_CMD FILE "msiexec /i /passive $DAI_TMPFILE"
215
216 !define GTK_FN "gtk-2.10.11-win32-1.exe"
217 !define GTK_URL "http://downloads.sourceforge.net/gladewin32/${GTK_FN}"
218 !define GTK_CMD "${GTK_FN}"
219
220 !define PYGOBJECT_FN "pygobject-2.12.3-1.win32-py${PYVERSION}.exe"
221 !define PYGOBJECT_URL "http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.12/${PYGOBJECT_FN}"
222 !define PYGOBJECT_CMD "${PYGOBJECT_FN}"
223
224 !define PYCAIRO_FN "pycairo-1.2.6-1.win32-py${PYVERSION}.exe"
225 !define PYCAIRO_URL "http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.2/${PYCAIRO_FN}"
226 !define PYCAIRO_CMD "${PYGOBJECT_FN}"
227
228 !define PYGTK_FN "pygtk-2.10.4-1.win32-py${PYVERSION}.exe"
229 !define PYGTK_URL "http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.10/${PYGTK_FN}"
230 !define PYGTK_CMD "${PYGTK_FN}"
231
232 Section "-download the selected missing dependencies"
233 ${If} $PYDOWNLOAD == '1'
234 !insertmacro downloadAndInstall "Python" PYTHON_URL PYTHON_FN PYTHON_CMD
235 Call DetectPython
236 Pop $PYOK
237 Pop $PYPATH
238 ${EndIf}
239 ${If} $GTKDOWNLOAD == '1'
240 !insertmacro downloadAndInstall "GTK+" GTK_URL GTK_FN GTK_CMD
241 Call DetectGTK
242 Pop $GTKOK
243 Pop $GTKPATH
244 Call DetectGlade
245 Pop $GLADEOK
246 Pop $GLADEPATH
247 ${EndIf}
248 ${If} $PYGOBJECTDOWNLOAD == '1'
249 !insertmacro downloadAndInstall "PyGObject" PYGOBJECT_URL PYGOBJECT_FN PYGOBJECT_CMD
250 Call DetectPyGObject
251 Pop $PYGOBJECTOK
252 ${EndIf}
253 ${If} $PYCAIRODOWNLOAD == '1'
254 !insertmacro downloadAndInstall "PyCairo" PYCAIRO_URL PYCAIRO_FN PYCAIRO_CMD
255 Call DetectPyCairo
256 Pop $PYCAIROOK
257 ${EndIf}
258 ${If} $PYGTKDOWNLOAD == '1'
259 !insertmacro downloadAndInstall "PyGTK" PYGTK_URL PYGTK_FN PYGTK_CMD
260 Call DetectPyGTK
261 Pop $PYGTKOK
262
263 ${EndIf}
264 SectionEnd
265
266 ;--------------------------------
267
268 Section "PyGTK GUI"
269 ; Check the dependencies of the PyGTK GUI before proceding...
270 ${If} $PYOK == 'NOK'
271 MessageBox MB_OK "PyGTK GUI can not be installed, because Python was not found on this system.$\nIf you do want to use the PyGTK GUI, please check the installation instructions$\n$\n(PYPATH=$PYPATH)"
272 ${ElseIf} $GTKOK == 'NOK'
273 MessageBox MB_OK "PyGTK GUI cannot be installed, because GTK+ 2.x was not found on this system.$\nIf you do want to use the PyGTK GUI, please check the installation instructions$\n$\n(GTKPATH=$GTKPATH)"
274 ${ElseIf} $GLADEOK == 'NOK'
275 MessageBox MB_OK "PyGTK GUI cannot be installed, because Glade 2.x was not found on this system.$\nIf you do want to use the PyGTK GUI, please check the installation instructions$\n$\n(GTKPATH=$GTKPATH).\n\nIf you do have GTK+ runtime installed, make sure\nyou have a version that includes support for Glade."
276 ${ElseIf} $PYGTKOK == "NOK"
277 MessageBox MB_OK "PyGTK GUI cannot be installed, because PyGTK was not found on this system.$\nPlease check the installation instructions.$\n$\n(PYPATH=$PYPATH)"
278 ${ElseIf} $PYCAIROOK == "NOK"
279 MessageBox MB_OK "PyGTK GUI cannot be installed, because PyCairo was not found on this system.$\nPlease check the installation instructions.$\n$\n(PYPATH=$PYPATH)"
280 ${ElseIf} $PYGOBJECTOK == "NOK"
281 MessageBox MB_OK "PyGTK GUI cannot be installed, because PyGObject was not found on this system.$\nPlease check the installation instructions.$\n$\n(PYPATH=$PYPATH)"
282 ${Else}
283 ;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH"
284
285 DetailPrint "--- PYTHON INTERFACE ---"
286
287 ; Set output path to the installation directory.
288 SetOutPath $INSTDIR
289
290 ; Python interface
291 File /nonfatal "pygtk\_ascpy.pyd"
292 File "pygtk\*.py"
293 File "pygtk\ascend"
294 File "pygtk\glade\ascend-doc.ico"
295
296 SetOutPath $INSTDIR\glade
297 File "pygtk\glade\*.glade"
298 File "pygtk\glade\*.png"
299 File "pygtk\glade\*.svg"
300
301 StrCpy $PYINSTALLED "1"
302 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "Python" 1
303
304 ;---- file association ----
305
306 ; back up old value of .a4c file association
307 ReadRegStr $1 HKCR ".a4c" ""
308 StrCmp $1 "" a4cnobkp
309 StrCmp $1 "ASCEND.model" a4cnobkp
310
311 ; Remember the old file association if necessary
312 WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4C" $1
313
314 a4cnobkp:
315 WriteRegStr HKCR ".a4c" "" "ASCEND.model"
316
317 ; back up old value of .a4c file association
318 ReadRegStr $1 HKCR ".a4l" ""
319 StrCmp $1 "" a4lnobkp
320 StrCmp $1 "ASCEND.model" a4lnobkp
321
322 ; Remember the old file association if necessary
323 WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4L" $1
324
325 a4lnobkp:
326 WriteRegStr HKCR ".a4l" "" "ASCEND.model"
327
328 ; So, what does an A4L or A4C file actually do?
329
330 ReadRegStr $0 HKCR "ASCEND.model" ""
331 StrCmp $0 "" 0 a4cskip
332
333 WriteRegStr HKCR "ASCEND.model" "" "ASCEND model file"
334 WriteRegStr HKCR "ASCEND.model\shell" "" "open"
335 WriteRegStr HKCR "ASCEND.model\DefaultIcon" "" "$INSTDIR\ascend-doc.ico"
336
337 a4cskip:
338 WriteRegStr HKCR "ASCEND.model\shell\open\command" "" '$PYPATH\pythonw "$INSTDIR\ascend" "%1"'
339
340 System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
341
342 ${EndIf}
343 Return
344
345 SectionEnd
346
347 ;---------------------------------
348
349 Section "Tcl/Tk GUI"
350
351 ${If} $TCLOK != 'OK'
352 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)"
353 ${Else}
354 DetailPrint "--- TCL/TK INTERFACE ---"
355 SetOutPath $INSTDIR\tcltk
356 File /r /x .svn "tcltk\TK\*"
357 SetOutPath $INSTDIR
358 File "tcltk\generic\interface\ascendtcl.dll"
359 File "tcltk\generic\interface\ascend4.exe"
360
361 StrCpy $TCLINSTALLED "1"
362 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "TclTk" 1
363
364 ${EndIf}
365
366 SectionEnd
367
368 ;---------------------------------
369
370 ; Optional section (can be disabled by the user)
371 Section "Start Menu Shortcuts"
372
373 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1
374
375 CreateDirectory "$SMPROGRAMS\ASCEND"
376
377 ; Link to PyGTK GUI
378 StrCmp $PYINSTALLED "" smdone 0
379 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$PYPATH\pythonw.exe" '"$INSTDIR\ascend"' "$INSTDIR\ascend.ico" 0
380 smdone:
381
382 ; Model library shortcut
383 CreateShortCut "$SMPROGRAMS\ASCEND\Model Library.lnk" "$INSTDIR\models" "" "$INSTDIR\models" 0
384
385
386 ; Link to Tcl/Tk GUI
387 StrCmp $TCLINSTALLED "" smnotcl 0
388 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0
389 smnotcl:
390
391 ; Information files
392 CreateShortCut "$SMPROGRAMS\ASCEND\LICENSE.lnk" "$INSTDIR\LICENSE.txt" '' "$INSTDIR\LICENSE.txt" 0
393 CreateShortCut "$SMPROGRAMS\ASCEND\CHANGELOG.lnk" "$INSTDIR\CHANGELOG.txt" '' "$INSTDIR\CHANGELOG.txt" 0
394 CreateShortCut "$SMPROGRAMS\ASCEND\README.lnk" "$INSTDIR\README-windows.txt" '' "$INSTDIR\README-windows.txt" 0
395
396 CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
397
398 SectionEnd
399
400 ;------------------------------------------------------------------
401 ; UNINSTALLER
402
403 Section "Uninstall"
404
405 ;--- python components ---
406
407 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
408 IntCmp $0 0 unnopython unpython
409
410 unpython:
411 DetailPrint "--- REMOVING PYTHON COMPONENTS ---"
412 Delete $INSTDIR\_ascpy.pyd
413 Delete $INSTDIR\ascend
414 Delete $INSTDIR\*.py
415 Delete $INSTDIR\*.pyc
416 Delete $INSTDIR\glade\*.glade
417 Delete $INSTDIR\glade\*.png
418 Delete $INSTDIR\glade\*.svg
419 RmDir $INSTDIR\glade
420 Delete $INSTDIR\ascend-doc.ico
421
422 ;--- file association (for Python GUI) ---
423
424 DetailPrint "--- REMOVING FILE ASSOCIATION ---"
425 ;start of restore script
426 ReadRegStr $1 HKCR ".a4c" ""
427 ${If} $1 == "ASCEND.model"
428 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
429 ${If} $1 == ""
430 ; nothing to restore: delete it
431 DeleteRegKey HKCR ".a4c"
432 ${Else}
433 WriteRegStr HKCR ".a4c" "" $1
434 ${EndIf}
435 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
436 ${EndIf}
437
438 ReadRegStr $1 HKCR ".a4l" ""
439 ${If} $1 == "ASCEND.model"
440 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
441 ${If} $1 == ""
442 ; nothing to restore: delete it
443 DeleteRegKey HKCR ".a4l"
444 ${Else}
445 WriteRegStr HKCR ".a4l" "" $1
446 ${EndIf}
447 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
448 ${EndIf}
449
450 DeleteRegKey HKCR "ASCEND.model" ;Delete key with association settings
451
452 System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
453 ;rest of script
454
455 unnopython:
456
457 ;--- tcl/tk components ---
458
459 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk"
460 ${If} $0 != 0
461 DetailPrint "--- REMOVING TCL/TK COMPONENTS ---"
462 Delete $INSTDIR\ascendtcl.dll
463 Delete $INSTDIR\ascend4.exe
464 RMDir /r $INSTDIR\tcltk
465 ${EndIf}
466
467 ;--- start menu ---
468
469 ReadRegDWORD $1 HKLM "SOFTWARE\ASCEND" "StartMenu"
470 IntCmp $1 0 unnostart unstart
471 unstart:
472 ; Remove shortcuts, if any
473 DetailPrint "--- REMOVING START MENU SHORTCUTS ---"
474 RmDir /r "$SMPROGRAMS\ASCEND"
475
476 unnostart:
477
478 ;--- common components ---
479
480 DetailPrint "--- REMOVING COMMON COMPONENTS ---"
481 ; Remove registry keys
482
483 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND"
484 DeleteRegKey HKLM "SOFTWARE\ASCEND"
485
486 ; Remove files and uninstaller
487
488 Delete $INSTDIR\ascend-config
489 Delete $INSTDIR\ascend-config.bat
490 Delete $INSTDIR\ascend.dll
491 Delete $INSTDIR\LICENSE.txt
492 Delete $INSTDIR\README-windows.txt
493 Delete $INSTDIR\CHANGELOG.txt
494 Delete $INSTDIR\ascend.ico
495 Delete $INSTDIR\Makefile.bt
496 Delete $INSTDIR\ascend.syn
497 RMDir /r $INSTDIR\models
498 Delete $INSTDIR\solvers\qrslv.dll
499 Delete $INSTDIR\solvers\conopt.dll
500 Delete $INSTDIR\solvers\lrslv.dll
501 Delete $INSTDIR\solvers\cmslv.dll
502 Delete $INSTDIR\solvers\lsode.dll
503 Delete $INSTDIR\solvers\ida.dll
504
505 ; Remove directories used
506
507 Delete $INSTDIR\uninstall.exe
508 RMDir $INSTDIR
509
510 SectionEnd
511

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