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

Contents of /trunk/nsis/installer.nsi

Parent Directory Parent Directory | Revision Log Revision Log


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

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