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