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

Contents of /trunk/nsis/installer.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2608 - (show annotations) (download)
Tue Apr 24 23:46:19 2012 UTC (12 years, 3 months ago) by jpye
File size: 22065 byte(s)
Some fixes for 64-bit installer.
1 ; NSIS script to create an ASCEND binary installer for Windows
2 ; by John Pye, 2006-2012.
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 !include x64.nsh
20
21 !ifndef PYVERSION
22 !define PYVERSION "2.7"
23 !endif
24
25 !ifndef PYPATCH
26 !define PYPATCH ".1"
27 !endif
28
29 ; The file to write
30 OutFile ${OUTFILE}
31
32 !if "${INSTARCH}" == "x64"
33 !define INST64
34 !endif
35
36 ; The default installation directory
37 !ifdef INST64
38 InstallDir $PROGRAMFILES64\ASCEND
39 !else
40 InstallDir $PROGRAMFILES32\ASCEND
41 !endif
42
43 ; NOTE we *don't* user InstallDirRegKey because it doesn't work correctly on Win64.
44 ;InstallDirRegKey HKLM "Software\ASCEND" "Install_Dir"
45
46 RequestExecutionLevel admin
47
48 ;--------------------------------
49
50 ; Pages
51
52 Page license
53 LicenseData "..\LICENSE.txt"
54
55 Page components
56 Page directory
57 Page custom dependenciesCreate dependenciesLeave
58 Page instfiles
59 Page custom ascendIniCreate ascendIniLeave
60 Page custom ascendEnvVarCreate ascendEnvVarLeave
61
62 UninstPage uninstConfirm
63 UninstPage instfiles
64
65 ;--------------------------------
66
67 !define GTKSEARCHPATH "c:\GTK"
68
69 Var DEFAULTPATH
70 Var HAVE_PYTHON
71 Var PYPATH
72 Var HAVE_GTK
73 Var GTKPATH
74 Var HAVE_PYGTK
75 Var HAVE_PYGOBJECT
76 Var HAVE_PYCAIRO
77 Var PYINSTALLED
78
79 Var PDFINSTALLED
80
81 Var PATH
82
83 Var NEED_PYTHON
84 Var NEED_GTK
85 Var NEED_PYGTK
86 Var NEED_PYCAIRO
87 Var NEED_PYGOBJECT
88
89 Var ASCENDINIFOUND
90 Var ASCENDENVVARFOUND
91 Var ASCENDLIBRARY
92
93 Var PYTHONTARGETDIR
94
95 ; .onInit has been moved to after section decls so that they can be references
96
97 ;------------------------------------------------------------
98 ; DOWNLOAD AND INSTALL DEPENDENCIES FIRST
99
100 ; Use the official python.org Python packages
101 !define PYTHON_VERSION "${PYVERSION}${PYPATCH}${PYARCH}"
102 !define PYTHON_FN "python-${PYTHON_VERSION}.msi"
103 !define PYTHON_URL "http://python.org/ftp/python/${PYTHON_VERSION}/${PYTHON_FN}"
104 !define PYTHON_CMD "msiexec /i $DAI_TMPFILE /passive ALLUSERS=1 TARGETDIR=$PYTHONTARGETDIR"
105
106 !define THIRDPARTY_DIR "http://downloads.sourceforge.net/project/ascend-sim/thirdparty/"
107 !define GTK_VER "2.22"
108
109 !ifdef INST64
110 !define WINXX "win64"
111 !define AMDXX ".win-amd64"
112 !define NNBIT "64-bit"
113 !define X64I386 "x64"
114 !define GTK_PATCH ".1-20101229"
115 !else
116 !define WINXX "win32"
117 !define AMDXX ".win32"
118 !define X64I386 "i386"
119 !define NNBIT "32-bit"
120 !define GTK_PATCH ".1-20101227"
121 !endif
122
123 ; Host our own GTK bundles, repackaged as installers.
124 ; User should still be able to use the ftp.gnome.org zip files, we just can't easily install them from here.
125 ; Also, but having GTK installer, we can store the installation location in the registry (and have both 64 and 32 bit versions)
126 !define GTK_FN "gtk+-${GTK_VER}${GTK_PATCH}-${X64I386}-a4.exe"
127 !define GTK_URL "${THIRDPARTY_DIR}${GTK_FN}"
128 !define GTK_MFT "gtk+-bundle_${GTK_VER}${GTK_PATCH}_${WINXX}.mft"
129 !define GTK_CMD "$DAI_TMPFILE /S"
130
131 ; We will host the PyGTK, PyGObject and PyCairo dependencies on SF.net ourselves... for the moment.
132 ; Note that PyGTK version should match GTK+ version.
133 !define PYGTK_PATCH ".0"
134 !define PYCAIRO_VER "1.10.0"
135 !define PYGOBJECT_VER "2.28.6"
136 !define PYGTK_FN "pygtk-${GTK_VER}${PYGTK_PATCH}${AMDXX}-py${PYVERSION}.exe"
137 !define PYCAIRO_FN "py2cairo-${PYCAIRO_VER}${AMDXX}-py${PYVERSION}.exe"
138 !define PYGOBJECT_FN "pygobject-${PYGOBJECT_VER}${AMDXX}-py${PYVERSION}.exe"
139 !define PYGTK_URL "${THIRDPARTY_DIR}${PYGTK_FN}"
140 !define PYCAIRO_URL "${THIRDPARTY_DIR}${PYCAIRO_FN}"
141 !define PYGOBJECT_URL "${THIRDPARTY_DIR}${PYGOBJECT_FN}"
142 !define PYGTK_CMD "$DAI_TMPFILE"
143 !define PYCAIRO_CMD "$DAI_TMPFILE"
144 !define PYGOBJECT_CMD "$DAI_TMPFILE"
145
146 !include "download.nsi"
147
148 Section "-python"
149 DetailPrint "--- DOWNLOAD PYTHON ---"
150 ${If} $NEED_PYTHON == '1'
151 !insertmacro downloadAndInstall "Python" "${PYTHON_URL}" "${PYTHON_FN}" "${PYTHON_CMD}"
152 Call DetectPython
153 ${If} $HAVE_PYTHON == 'NOK'
154 MessageBox MB_OK "Python installation appears to have failed. You may need to retry manually."
155 ${EndIf}
156 ${EndIf}
157 SectionEnd
158
159 Section "-gtk"
160 DetailPrint "--- DOWNLOAD GTK ---"
161 ${If} $NEED_GTK == '1'
162 !insertmacro downloadAndInstall "GTK" "${GTK_URL}" "${GTK_FN}" "${GTK_CMD}"
163 Call DetectGTK
164 ${If} $HAVE_GTK == 'NOK'
165 MessageBox MB_OK "GTK installation appears to have failed. You may need to retry manually."
166 ${EndIf}
167 ${EndIf}
168 SectionEnd
169
170 Section "-pygtk"
171 DetailPrint "--- DOWNLOAD PYGTK ---"
172 ${If} $NEED_PYGTK == '1'
173 !insertmacro downloadAndInstall "PyGTK" "${PYGTK_URL}" "${PYGTK_FN}" "${PYGTK_CMD}"
174 Call DetectPyGTK
175 ${If} $HAVE_PYGTK == 'NOK'
176 MessageBox MB_OK "PyGTK installation appears to have failed. You may need to retry manually"
177 ${EndIf}
178 ${EndIf}
179 SectionEnd
180
181 Section "-pycairo"
182 DetailPrint "--- DOWNLOAD PYCAIRO ---"
183 ${If} $NEED_PYCAIRO == '1'
184 !insertmacro downloadAndInstall "PyCAIRO" "${PYCAIRO_URL}" "${PYCAIRO_FN}" "${PYCAIRO_CMD}"
185 Call DetectPyCairo
186 ${If} $HAVE_PYCAIRO == 'NOK'
187 MessageBox MB_OK "PyCairo installation appears to have failed. You may need to retry manually."
188 ${EndIf}
189 ${EndIf}
190 SectionEnd
191
192 Section "-pygobject"
193 DetailPrint "--- DOWNLOAD PYGOBJECT ---"
194 ${If} $NEED_PYGOBJECT == '1'
195 !insertmacro downloadAndInstall "PyGObject" "${PYGOBJECT_URL}" "${PYGOBJECT_FN}" "${PYGOBJECT_CMD}"
196 Call DetectPyGObject
197 ${If} $HAVE_PYGOBJECT == 'NOK'
198 MessageBox MB_OK "PyGObject installation appears to have failed. You may need to retry manually."
199 ${EndIf}
200 ${EndIf}
201 SectionEnd
202
203 ;------------------------------------------------------------------------
204 ; INSTALL CORE STUFF including model library
205
206 ; The stuff to install
207 Section "ASCEND (required)"
208 SectionIn RO
209
210 DetailPrint "--- COMMON FILES ---"
211
212 ; Set output path to the installation directory.
213 SetOutPath $INSTDIR
214 File "..\ascend.dll"
215 File "..\ascend-config"
216 File "..\pygtk\glade\ascend.ico"
217 File "..\LICENSE.txt"
218 File "..\CHANGELOG.txt"
219 File "..\README-windows.txt"
220 ${IPOPTDLL_LINE}
221 ${IPOPTDLL_LINE2}
222
223 ; Model Library
224 SetOutPath $INSTDIR\models
225 File /r /x .svn "..\models\*.a4*"
226 File /r /x .svn "..\models\*.tcl"
227 File /r /x .svn "..\models\*_ascend.dll" ; extension modules
228 File /r /x .svn "..\models\*.py"; python modules
229
230 SetOutPath $INSTDIR\solvers
231 File "..\solvers\qrslv\qrslv_ascend.dll"
232 File "..\solvers\conopt\conopt_ascend.dll"
233 File "..\solvers\lrslv\lrslv_ascend.dll"
234 File "..\solvers\cmslv\cmslv_ascend.dll"
235 File "..\solvers\lsode\lsode_ascend.dll"
236 File "..\solvers\ida\ida_ascend.dll"
237 File "..\solvers\dopri5\dopri5_ascend.dll"
238 File "..\solvers\ipopt\ipopt_ascend.dll"
239
240 SetOutPath $INSTDIR
241 ;File "Makefile.bt"
242 File "..\tools\textpad\ascend.syn"
243
244 ; Check for pre-existing .ascend.ini for current user (warn after installation, if so)
245 ${If} ${FileExists} "$APPDATA\.ascend.ini"
246 StrCpy $ASCENDINIFOUND "1"
247 ${Else}
248 ; Set 'librarypath' in .ascend.ini
249 WriteINIstr $APPDATA\.ascend.ini Directories librarypath "$DOCUMENTS\ascdata;$INSTDIR\models"
250 ${EndIf}
251
252 ; Check for ASCENDLIBRARY environment variable for current user
253 ExpandEnvStrings $ASCENDLIBRARY "%ASCENDLIBRARY%"
254 ${IfNot} $ASCENDLIBRARY == "%ASCENDLIBRARY%"
255 StrCpy $ASCENDENVVARFOUND "1"
256 ${EndIf}
257
258 ; Write the installation path into the registry
259 WriteRegStr HKLM SOFTWARE\ASCEND "Install_Dir" "$INSTDIR"
260
261 ; Write the uninstall keys for Windows
262 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "DisplayName" "ASCEND Simulation Environment"
263 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "UninstallString" '"$INSTDIR\uninstall.exe"'
264 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoModify" 1
265 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND" "NoRepair" 1
266 WriteUninstaller "uninstall.exe"
267
268 ; Write file locations to the registry for access from ascend-config
269 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_LIB" "$INSTDIR"
270 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_BIN" "$INSTDIR"
271 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_INCLUDE" "$INSTDIR\include"
272 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_ASCDATA" "$INSTDIR"
273 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_MODELS" "$INSTDIR\models"
274 WriteRegStr HKLM SOFTWARE\ASCEND "INSTALL_SOLVERS" "$INSTDIR\solvers"
275 WriteRegStr HKLM SOFTWARE\ASCEND "GTKLIBS" "$GTKPATH"
276
277 ; Write default values of ASCENDLIBRARY and ASCENDSOLVERS (user can override with env vars)
278 WriteRegStr HKLM SOFTWARE\ASCEND "ASCENDLIBRARY" "$INSTDIR\models"
279 WriteRegStr HKLM SOFTWARE\ASCEND "ASCENDSOLVERS" "$INSTDIR\solvers"
280
281 Return
282 SectionEnd
283
284 ;--------------------------------
285
286 Section "PyGTK GUI" sect_pygtk
287 !ifdef INST64
288 SetRegView 64
289 !endif
290 ; Check the dependencies of the PyGTK GUI before proceding...
291 ${If} $HAVE_PYTHON == 'NOK'
292 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)"
293 ${ElseIf} $HAVE_GTK == 'NOK'
294 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)"
295 ${ElseIf} $HAVE_PYGTK == "NOK"
296 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)"
297 ${ElseIf} $HAVE_PYCAIRO == "NOK"
298 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)"
299 ${ElseIf} $HAVE_PYGOBJECT == "NOK"
300 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)"
301 ${Else}
302 ;MessageBox MB_OK "Python: $PYPATH, GTK: $GTKPATH"
303
304 DetailPrint "--- PYTHON INTERFACE ---"
305
306 ; File icon
307 SetOutPath $INSTDIR
308 File "..\pygtk\glade\ascend-doc.ico"
309 File "..\pygtk\ascend"
310
311 ; Python interface
312 SetOutPath $INSTDIR\python
313 File "..\ascxx\_ascpy.pyd"
314 File "..\ascxx\ascpy.py"
315 File "..\pygtk\*.py"
316
317 ; FPROPS: python bindings
318 File "..\models\johnpye\fprops\python\_fprops.pyd"
319 File "..\models\johnpye\fprops\python\*.py"
320
321 ; GLADE assets
322 SetOutPath $INSTDIR\glade
323 File "..\pygtk\glade\*.glade"
324 File "..\pygtk\glade\*.png"
325 File "..\pygtk\glade\*.svg"
326
327 StrCpy $PYINSTALLED "1"
328 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "Python" 1
329
330 ; Create 'ascend.bat' batch file for launching the PyGTK GUI.
331 ClearErrors
332 FileOpen $0 $INSTDIR\ascend.bat w
333 ${If} ${Errors}
334 MessageBox MB_OK "The 'ascend.bat' file was not installed properly; problems writing to that file."
335 ${Else}
336 FileWrite $0 "@echo off"
337 FileWriteByte $0 "13"
338 FileWriteByte $0 "10"
339 FileWrite $0 "set PATH=$PATH"
340 FileWriteByte $0 "13"
341 FileWriteByte $0 "10"
342 FileWrite $0 "cd "
343 FileWrite $0 $INSTDIR
344 FileWriteByte $0 "13"
345 FileWriteByte $0 "10"
346 FileWrite $0 "$PYPATH\python "
347 FileWriteByte $0 "34"
348 FileWrite $0 "$INSTDIR\ascend"
349 FileWriteByte $0 "34"
350 FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8"
351 FileWriteByte $0 "13"
352 FileWriteByte $0 "10"
353 FileClose $0
354 ${EndIf}
355
356 ;---- file association ----
357
358 ; back up old value of .a4c file association
359 ReadRegStr $1 HKCR ".a4c" ""
360 StrCmp $1 "" a4cnobkp
361 StrCmp $1 "ASCEND.model" a4cnobkp
362
363 ; Remember the old file association if necessary
364 WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4C" $1
365
366 a4cnobkp:
367 WriteRegStr HKCR ".a4c" "" "ASCEND.model"
368
369 ; back up old value of .a4c file association
370 ReadRegStr $1 HKCR ".a4l" ""
371 StrCmp $1 "" a4lnobkp
372 StrCmp $1 "ASCEND.model" a4lnobkp
373
374 ; Remember the old file association if necessary
375 WriteRegStr HKLM "SOFTWARE\ASCEND" "BackupAssocA4L" $1
376
377 a4lnobkp:
378 WriteRegStr HKCR ".a4l" "" "ASCEND.model"
379
380 ; So, what does an A4L or A4C file actually do?
381
382 ReadRegStr $0 HKCR "ASCEND.model" ""
383 StrCmp $0 "" 0 a4cskip
384
385 WriteRegStr HKCR "ASCEND.model" "" "ASCEND model file"
386 WriteRegStr HKCR "ASCEND.model\shell" "" "open"
387 WriteRegStr HKCR "ASCEND.model\DefaultIcon" "" "$INSTDIR\ascend-doc.ico"
388
389 a4cskip:
390 WriteRegStr HKCR "ASCEND.model\shell\open\command" "" '$PYPATH\pythonw.exe "$INSTDIR\ascend" "%1"'
391
392 System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
393
394 ${EndIf}
395 Return
396
397 SectionEnd
398
399 ;---------------------------------
400
401 Section "Documentation" sect_doc
402 SetOutPath $INSTDIR
403 File "..\doc\book.pdf"
404 StrCpy $PDFINSTALLED "1"
405 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "PDF" 1
406 SectionEnd
407
408 ; Optional section (can be disabled by the user)
409 Section "Start Menu Shortcuts" sect_menu
410
411 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "StartMenu" 1
412
413 CreateDirectory "$SMPROGRAMS\ASCEND"
414
415 ; Link to PyGTK GUI
416 ${If} $PYINSTALLED == "1"
417 CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND.lnk" "$PYPATH\pythonw.exe" '"$INSTDIR\ascend"' "$INSTDIR\ascend.ico" 0
418 ${EndIf}
419
420 ; Model library shortcut
421 CreateShortCut "$SMPROGRAMS\ASCEND\Model Library.lnk" "$INSTDIR\models" "" "$INSTDIR\models" 0
422
423 ; ; Link to Tcl/Tk GUI
424 ; ${If} $TCLINSTALLED == "1"
425 ; CreateShortCut "$SMPROGRAMS\ASCEND\ASCEND Tcl/Tk.lnk" "$INSTDIR\ascend4.exe" "" "$INSTDIR\ascend4.exe" 0
426 ; ${EndIf}
427
428 ; Documentation
429 ${If} $PDFINSTALLED == "1"
430 CreateShortCut "$SMPROGRAMS\ASCEND\User's Manual.lnk" "$INSTDIR\book.pdf" "" "$INSTDIR\book.pdf" 0
431 ${EndIf}
432
433 ; Information files
434 CreateShortCut "$SMPROGRAMS\ASCEND\LICENSE.lnk" "$INSTDIR\LICENSE.txt" '' "$INSTDIR\LICENSE.txt" 0
435 CreateShortCut "$SMPROGRAMS\ASCEND\CHANGELOG.lnk" "$INSTDIR\CHANGELOG.txt" '' "$INSTDIR\CHANGELOG.txt" 0
436 CreateShortCut "$SMPROGRAMS\ASCEND\README.lnk" "$INSTDIR\README-windows.txt" '' "$INSTDIR\README-windows.txt" 0
437
438 CreateShortCut "$SMPROGRAMS\ASCEND\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
439
440 SectionEnd
441
442 ;------------------------------------------------------------------
443 ; HEADER FILES for DEVELOPERS
444
445 Section /o "Header files (for developers)" sect_devel
446 WriteRegDWORD HKLM "SOFTWARE\ASCEND" "HeaderFiles" 1
447
448 SetOutPath $INSTDIR\include\ascend
449 File /r /x .svn "..\ascend\*.h"
450
451 ; Create 'ascend-config.bat' batch file for launching the python script 'ascend-config'.
452 ClearErrors
453 FileOpen $0 $INSTDIR\ascend-config.bat w
454 ${If} ${Errors}
455 MessageBox MB_OK "The 'ascend-config.bat' file was not installed properly; problems writing to that file."
456 ${Else}
457 FileWrite $0 "@echo off"
458 FileWriteByte $0 "13"
459 FileWriteByte $0 "10"
460 FileWrite $0 "set PATH=$PATH"
461 FileWriteByte $0 "13"
462 FileWriteByte $0 "10"
463 FileWrite $0 "cd "
464 FileWrite $0 $INSTDIR
465 FileWriteByte $0 "13"
466 FileWriteByte $0 "10"
467 FileWrite $0 "$PYPATH\python "
468 FileWriteByte $0 "34"
469 FileWrite $0 "$INSTDIR\ascend-config"
470 FileWriteByte $0 "34"
471 FileWrite $0 " %1 %2 %3 %4 %5 %6 %7 %8"
472 FileWriteByte $0 "13"
473 FileWriteByte $0 "10"
474 FileClose $0
475 ${EndIf}
476 SetOutPath $INSTDIR
477 SectionEnd
478
479 ;------------------------------------------------------------------
480 ; UNINSTALLER
481
482 Section "Uninstall"
483 !ifdef INST64
484 SetRegView 64
485 !endif
486
487 ;--- python components ---
488
489 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
490 ${If} $0 <> 0
491
492 DetailPrint "--- REMOVING PYTHON COMPONENTS ---"
493 Delete $INSTDIR\python\_ascpy.pyd
494 Delete $INSTDIR\python\_fprops.pyd
495 Delete $INSTDIR\python\*.py
496 Delete $INSTDIR\python\*.pyc
497 Delete $INSTDIR\glade\*.glade
498 Delete $INSTDIR\glade\*.png
499 Delete $INSTDIR\glade\*.svg
500 Delete $INSTDIR\ascend-doc.ico
501 Delete $INSTDIR\ascend
502 Delete $INSTDIR\ascend.bat
503 RmDir $INSTDIR\glade
504 RmDir $INSTDIR\python
505
506 ;--- file association (for Python GUI) ---
507
508 DetailPrint "--- REMOVING FILE ASSOCIATION ---"
509 ;start of restore script
510 ReadRegStr $1 HKCR ".a4c" ""
511 ${If} $1 == "ASCEND.model"
512 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
513 ${If} $1 == ""
514 ; nothing to restore: delete it
515 DeleteRegKey HKCR ".a4c"
516 ${Else}
517 WriteRegStr HKCR ".a4c" "" $1
518 ${EndIf}
519 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4C"
520 ${EndIf}
521
522 ReadRegStr $1 HKCR ".a4l" ""
523 ${If} $1 == "ASCEND.model"
524 ReadRegStr $1 HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
525 ${If} $1 == ""
526 ; nothing to restore: delete it
527 DeleteRegKey HKCR ".a4l"
528 ${Else}
529 WriteRegStr HKCR ".a4l" "" $1
530 ${EndIf}
531 DeleteRegValue HKLM "SOFTWARE\ASCEND" "BackupAssocA4L"
532 ${EndIf}
533
534 DeleteRegKey HKCR "ASCEND.model" ;Delete key with association settings
535
536 System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
537 ;rest of script
538
539 ${EndIf}
540
541 ;--- tcl/tk components ---
542
543 ; ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "TclTk"
544 ; ${If} $0 <> 0
545 ; DetailPrint "--- REMOVING TCL/TK COMPONENTS ---"
546 ; Delete $INSTDIR\ascendtcl.dll
547 ; Delete $INSTDIR\ascend4.exe
548 ; RMDir /r $INSTDIR\tcltk
549 ; ${EndIf}
550
551 ;--- documentation ---
552
553 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "PDF"
554 ${If} $0 <> 0
555 DetailPrint "--- REMOVING DOCUMENTATION ---"
556 Delete $INSTDIR\book.pdf
557 ${EndIf}
558
559 ;--- header files ---
560
561 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "HeaderFiles"
562 ${If} $0 <> 0
563 DetailPrint "--- REMOVING HEADER FILES ---"
564 RMDir /r $INSTDIR\include
565 ${EndIf}
566
567 ;--- start menu ---
568
569 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "StartMenu"
570 ${If} $0 <> 0
571 ; Remove shortcuts, if any
572 DetailPrint "--- REMOVING START MENU SHORTCUTS ---"
573 RmDir /r "$SMPROGRAMS\ASCEND"
574 ${EndIf}
575
576 ;--- common components ---
577
578 DetailPrint "--- REMOVING COMMON COMPONENTS ---"
579 ; Remove registry keys
580
581 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ASCEND"
582 DeleteRegKey HKLM "SOFTWARE\ASCEND"
583
584 ; Remove files and uninstaller
585
586 Delete $INSTDIR\ascend-config
587 Delete $INSTDIR\ascend-config.bat
588 Delete $INSTDIR\ascend.dll
589 Delete $INSTDIR\LICENSE.txt
590 Delete $INSTDIR\README-windows.txt
591 Delete $INSTDIR\CHANGELOG.txt
592 Delete $INSTDIR\ascend.ico
593 Delete $INSTDIR\Makefile.bt
594 Delete $INSTDIR\ascend.syn
595 Delete $INSTDIR\ipopt38.dll
596 RMDir /r $INSTDIR\models
597 Delete $INSTDIR\solvers\qrslv_ascend.dll
598 Delete $INSTDIR\solvers\conopt_ascend.dll
599 Delete $INSTDIR\solvers\lrslv_ascend.dll
600 Delete $INSTDIR\solvers\cmslv_ascend.dll
601 Delete $INSTDIR\solvers\lsode_ascend.dll
602 Delete $INSTDIR\solvers\ida_ascend.dll
603 Delete $INSTDIR\solvers\dopri5_ascend.dll
604 Delete $INSTDIR\solvers\ipopt_ascend.dll
605 RMDir $INSTDIR\solvers
606
607 ${DEL_IPOPTDLL_LINE}
608 ${DEL_IPOPTDLL_LINE2}
609
610 ; Remove directories used
611
612 Delete $INSTDIR\uninstall.exe
613 RMDir $INSTDIR
614
615 SectionEnd
616
617 !include "dependencies.nsi"
618
619 !include "detect.nsi"
620
621 !include "ascendini.nsi"
622
623 !include "envvarwarning.nsi"
624
625 Function .onInit
626 !ifdef INST64
627 ${IfNot} ${RunningX64}
628 MessageBox MB_OK "This ASCEND installer is for 64-bit Windows versions only.$\n$\nVisit http://ascend4.org for 32-bit versions."
629 Abort
630 ${EndIf}
631 SetRegView 64
632 !endif
633
634 ;Get the previously-chosen $INSTDIR
635 ReadRegStr $0 HKLM "SOFTWARE\ASCEND" "Install_Dir"
636 ${If} $0 != ""
637 StrCpy $INSTDIR $0
638 ${EndIf}
639
640 ;set the default python target dir
641 StrCpy $PYTHONTARGETDIR "c:\Python${PYVERSION}"
642 !ifndef INST64
643 ${If} ${RunningX64}
644 ; this is a 32-bit installer on 64-bit Windows: install Python to a special location
645 StrCpy $PYTHONTARGETDIR "c:\Python${PYVERSION}_32"
646 ${EndIf}
647 ; FIXME we should check whether that directory already exists before going ahead...
648 !endif
649
650 StrCpy $PYINSTALLED ""
651 StrCpy $ASCENDINIFOUND ""
652 StrCpy $PDFINSTALLED ""
653 StrCpy $ASCENDENVVARFOUND ""
654
655 ExpandEnvStrings $DEFAULTPATH "%WINDIR%;%WINDIR%\system32"
656
657 Call DetectPython
658 Call DetectGTK
659 Call DetectPyGTK
660 Call DetectPyGObject
661 Call DetectPyCairo
662
663 ;MessageBox MB_OK "GTK path is $GTKPATH"
664 StrCpy $PATH "$GTKPATH;$DEFAULTPATH;$PYPATH"
665
666 ReadRegStr $0 HKLM "SOFTWARE\ASCEND" "Install_Dir"
667 ${If} $0 != ""
668 ;MessageBox MB_OK "Previous installation detected..."
669
670 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "Python"
671 ${If} $0 = 0
672 ;MessageBox MB_OK "Python was previously deselected"
673 SectionGetFlags "${sect_pygtk}" $1
674 IntOp $1 $1 ^ ${SF_SELECTED}
675 SectionSetFlags "${sect_pygtk}" $1
676 ${Else}
677 SectionGetFlags "${sect_pygtk}" $1
678 IntOp $1 $1 ^ ${SF_RO}
679 SectionSetFlags "${sect_pygtk}" $1
680 ${EndIf}
681
682 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "PDF"
683 ${If} $0 = 0
684 ;MessageBox MB_OK "Documentation was previously deselected"
685 SectionGetFlags "${sect_doc}" $1
686 IntOp $1 $1 ^ ${SF_SELECTED}
687 SectionSetFlags "${sect_doc}" $1
688 ${Else}
689 SectionGetFlags "${sect_doc}" $1
690 IntOp $1 $1 ^ ${SF_RO}
691 SectionSetFlags "${sect_doc}" $1
692 ${EndIf}
693
694 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "StartMenu"
695 ${If} $0 = 0
696 ;MessageBox MB_OK "Start Menu was previously deselected"
697 SectionGetFlags "${sect_menu}" $1
698 IntOp $1 $1 ^ ${SF_SELECTED}
699 SectionSetFlags "${sect_menu}" $1
700 ${Else}
701 SectionGetFlags "${sect_menu}" $1
702 IntOp $1 $1 ^ ${SF_RO}
703 SectionSetFlags "${sect_menu}" $1
704 ${EndIf}
705
706 ReadRegDWORD $0 HKLM "SOFTWARE\ASCEND" "HeaderFiles"
707 ${If} $0 <> 0
708 ;MessageBox MB_OK "Header files were previously selected"
709 SectionGetFlags "${sect_devel}" $1
710 IntOp $1 $1 | ${SF_SELECTED}
711 IntOp $1 $1 | ${SF_RO}
712 SectionSetFlags "${sect_devel}" $1
713 ${EndIf}
714 ${EndIf}
715
716 FunctionEnd
717
718
719 Function un.onInit
720 !ifdef INST64
721 SetRegView 64
722 !endif
723
724 ;Get the previously-chosen $INSTDIR
725 ReadRegStr $0 HKLM "SOFTWARE\ASCEND" "Install_Dir"
726 ${If} $0 != ""
727 StrCpy $INSTDIR $0
728 ${EndIf}
729 FunctionEnd

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