/[ascend]/branches/georgy/nsis/installer.nsi
ViewVC logotype

Contents of /branches/georgy/nsis/installer.nsi

Parent Directory Parent Directory | Revision Log Revision Log


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

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