-
Notifications
You must be signed in to change notification settings - Fork 2
/
springinstaller.nsi
570 lines (489 loc) · 17.8 KB
/
springinstaller.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
!define APP_NAME "Spring Installer"
!define APP_REG_ROOT "HKLM"
!define APP_REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
SetCompress force
SetCompressor /SOLID /FINAL lzma
!addplugindir "plugins"
!include "MUI2.nsh"
; http://nsis.sourceforge.net/Docs/Modern%20UI%202/Readme.html
; Config for Modern Interface
!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_TEXT "Thanks for installing this game"
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_RUN_TEXT "Start game"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Readme file for game"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION showReadme
!define MUI_FINISHPAGE_RUN ""
!define MUI_FINISHPAGE_RUN_FUNCTION runExit
!define MUI_HEADERIMAGE
;!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis.bmp" ; optional
!define MUI_WELCOMEFINISHPAGE_BITMAP "graphics\SideBanner.bmp"
;!define MUI_WELCOMEPAGE_TITLE "Hey"
;!define MUI_WELCOMEPAGE_TITLE_3LINES ""
;!define MUI_WELCOMEPAGE_TEXT "blabla"
!define INETC_GET_RESULTOK "OK"
!define SPRING_MAIN_SECTION "Spring"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
!macro createTempDir returnvar basepath
GetTempFileName ${returnvar} ${basepath}
Delete ${returnvar}
CreateDirectory ${returnvar}
!macroend
!include "LogicLib.nsh"
!include "include\strrep.nsi"
!include "include\StrLoc.nsi"
!include "include\ReadCustomerData.nsi"
!include "include\UninstallLog.nsh"
!include "include\unpack.nsh"
Outfile "springinstaller.exe"
InstallDir "$PROGRAMFILES\Spring"
Name $GAMENAME
; hidden section to be reused for sections read from .ini
Section "" SEC_0
SectionEnd
Section "" SEC_1
SectionEnd
Section "" SEC_2
SectionEnd
Section "" SEC_3
SectionEnd
Section "" SEC_4
SectionEnd
Section "" SEC_5
SectionEnd
Section "" SEC_6
SectionEnd
Section "" SEC_7
SectionEnd
Section "" SEC_8
SectionEnd
Section "" SEC_9
SectionEnd
Section "" SEC_10
SectionEnd
Section "" SEC_11
SectionEnd
Section "" SEC_12
SectionEnd
Section "" SEC_13
SectionEnd
Section "" SEC_14
SectionEnd
Section "" SEC_15
SectionEnd
VAR /GLOBAL DESC_SECTION_0
VAR /GLOBAL DESC_SECTION_1
VAR /GLOBAL DESC_SECTION_2
VAR /GLOBAL DESC_SECTION_3
VAR /GLOBAL DESC_SECTION_4
VAR /GLOBAL DESC_SECTION_5
VAR /GLOBAL DESC_SECTION_6
VAR /GLOBAL DESC_SECTION_7
VAR /GLOBAL DESC_SECTION_8
VAR /GLOBAL DESC_SECTION_9
VAR /GLOBAL DESC_SECTION_10
VAR /GLOBAL DESC_SECTION_11
VAR /GLOBAL DESC_SECTION_12
VAR /GLOBAL DESC_SECTION_13
VAR /GLOBAL DESC_SECTION_14
VAR /GLOBAL DESC_SECTION_15
VAR /GLOBAL SPRING_INI ; name of ini file
VAR /GLOBAL README ; http url to readme
VAR /GLOBAL VERSION ; version of spring engine
VAR /GLOBAL FILES ; count of files to install
VAR /GLOBAL GAMENAME ; name of the game, is used as filename!
VAR /GLOBAL INSTALLERNAME ; name of installer.exe without .exe
VAR /GLOBAL SOURCEDIR
VAR /GLOBAL EXEC_EXIT ; to be run on exit (optional)
VAR /GLOBAL EXEC_EXIT_PARAMETER ; to be run on exit (optional)
VAR /GLOBAL SIZE ; size of installed files
VAR /GLOBAL UPDATEURL ; url of this file
VAR /GLOBAL TEMPDIR ; tempdir
; temp vars
VAR /GLOBAL MIRROR_COUNT ; count of mirrors of current file
VAR /GLOBAL MD5 ; md5 of current file
VAR /GLOBAL DIRECTORY ; subdirectory where current file to install to
VAR /GLOBAL MIRROR ; current mirror
VAR /GLOBAL FILENAME ; filename of current file
VAR /GLOBAL EXEC ; to execute after file is downladed, %SOURCEDIR% and %INSTALLDIR% are replaced
VAR /GLOBAL EXEC_PARAMS ; params for execute, %SOURCEDIR% and %INSTALLDIR% are replaced
VAR /GLOBAL 7ZIP_EXTRACT_PATH ; extract file to path
VAR /GLOBAL ZIP_EXTRACT_PATH ; extract zip file to this path
VAR /GLOBAL SHORTCUT ; name of shortcut to create in starmenu, %GAMENAME% is replaced
VAR /GLOBAL SHORTCUT_TARGET ; target of shortcut, %INSTALLDIR% is replaced
VAR /GLOBAL SHORTCUT_PARAMETER ; parameter, %INSTALLDIR% is replaced
VAR /GLOBAL SHORTCUT_ICON ; parameter, %INSTALLDIR% is replaced
VAR /GLOBAL SHORTCUT_DIRECTORY ; parameter, %INSTALLDIR% is replaced
VAR /GLOBAL SECTION ; section for current file
VAR /GLOBAL INCLUDE ; ==yes if file is to be included
VAR /GLOBAL ALWAYSUPDATE ; always redownload file
!macro escapeVar var
!insertmacro ReplaceSubStr ${var} "%GAMENAME%" $GAMENAME
!insertmacro ReplaceSubStr ${var} "%INSTALLERNAME%" $INSTALLERNAME
!insertmacro ReplaceSubStr ${var} "%SOURCEDIR%" $SOURCEDIR
!insertmacro ReplaceSubStr ${var} "%SPRING_INI%" $SPRING_INI
!insertmacro ReplaceSubStr ${var} "%INSTALLDIR%" $INSTDIR
!insertmacro ReplaceSubStr ${var} "%VERSION%" $VERSION
!insertmacro ReplaceSubStr ${var} "%STARTMENU%" $SMPROGRAMS
!macroend
Function FatalError
System::Store "s"
Pop $0
DetailPrint $0
MessageBox MB_YESNO "Error occured: $0, would you like to open the help forum?" IDNO noshow
ExecShell "open" "http://springrts.com/phpbb/viewtopic.php?f=14&t=25381"
noshow:
Abort
System::Store "l"
FunctionEnd
; downloads a file, uses + _modifies_ global vars
; top on stack contains section name
Function fetchFile
System::Store "s"
Pop $0 ; Section name, for example File0
DetailPrint "Section $SPRING_INI:$0"
ReadINIStr $SECTION $SPRING_INI $0 "section"
${If} $SECTION >= 0
${AndIf} $Section <= 15
IntOp $SECTION ${SEC_0} + $SECTION
SectionGetFlags $SECTION $1 ; get current flags
IntOp $1 $1 & ${SF_SELECTED}
${IfNot} $1 = ${SF_SELECTED} ; selected?
goto noFetch
${EndIf}
${EndIf}
ReadINIStr $MIRROR_COUNT $SPRING_INI $0 "mirror_count"
ReadINIStr $MIRROR $SPRING_INI $0 "mirror1"
;TODO: retry with mirrors
; ReadINIStr $MIRROR $SPRING_INI "Spring" "mirror2"
; ReadINIStr $MIRROR $SPRING_INI "Spring" "mirror3"
ReadINIStr $FILENAME $SPRING_INI $0 "filename"
ReadINIStr $MD5 $SPRING_INI $0 "md5"
ReadINIStr $DIRECTORY $SPRING_INI $0 "directory"
ReadINIStr $EXEC $SPRING_INI $0 "exec"
ReadINIStr $EXEC_PARAMS $SPRING_INI $0 "exec_params"
ReadINIStr $7ZIP_EXTRACT_PATH $SPRING_INI $0 "un7zip"
ReadINIStr $ZIP_EXTRACT_PATH $SPRING_INI $0 "unzip"
ReadINIStr $SHORTCUT $SPRING_INI $0 "shortcut"
ReadINIStr $SHORTCUT_TARGET $SPRING_INI $0 "shortcut_target"
ReadINIStr $SHORTCUT_PARAMETER $SPRING_INI $0 "shortcut_parameter"
ReadINIStr $SHORTCUT_ICON $SPRING_INI $0 "shortcut_icon"
ReadINIStr $SHORTCUT_DIRECTORY $SPRING_INI $0 "shortcut_directory"
ReadINIStr $INCLUDE $SPRING_INI $0 "isinclude"
ReadINIStr $ALWAYSUPDATE $SPRING_INI $0 "alwaysupdate"
!insertmacro escapeVar $FILENAME
!insertmacro escapeVar $MIRROR
${If} $MIRROR_COUNT == ""
StrCpy $MIRROR_COUNT 1
${EndIf}
${If} $FILENAME != "" ; non-downloading actions are possible, too
${IfNot} ${FileExists} "$SOURCEDIR\$FILENAME" ; skip download if file is already there
${OrIf} $ALWAYSUPDATE == "yes"
DetailPrint "Downloading $MIRROR to $SOURCEDIR\$FILENAME"
inetc::get /RESUME "Your internet connection seems to have dropped out!\nPlease reconnect and click Retry to resume downloading..." $MIRROR "$SOURCEDIR\$FILENAME" /END
Pop $R0
${If} $R0 != ${INETC_GET_RESULTOK}
Rename $SPRING_INI "$SPRING_INI.invalid"
Push "Download failed $R0"
Call FatalError
${EndIf}
${IfNot} ${FileExists} "$SOURCEDIR\$FILENAME"
Push "$SOURCEDIR\$FILENAME didn't exist after download"
Call FatalError
${EndIf}
${EndIf}
${EndIf}
${If} "$MD5" != "" ; only check md5 is set in .ini
DetailPrint "$SOURCEDIR\$FILENAME :"
md5dll::GetMD5File "$SOURCEDIR\$FILENAME"
Pop $R0
${If} $R0 == $MD5
DetailPrint "md5 match:[$R0]"
${Else}
Push "$FILENAME: md5 mismatch:[$R0]"
Call FatalError
;TODO: prompt for redownload?
${EndIf}
${EndIf}
;TODO: add extracted files to uninstall log
; extract file if requested
${If} $7ZIP_EXTRACT_PATH != ""
${CreateDirectory} "$INSTDIR\$7ZIP_EXTRACT_PATH"
!insertmacro un7zip "$SOURCEDIR\$FILENAME" "$INSTDIR\$7ZIP_EXTRACT_PATH" "$TEMPDIR"
${EndIf}
${If} $ZIP_EXTRACT_PATH != ""
${CreateDirectory} "$INSTDIR\$ZIP_EXTRACT_PATH"
!insertmacro unzip "$SOURCEDIR\$FILENAME" "$INSTDIR\$ZIP_EXTRACT_PATH" "$TEMPDIR"
${EndIf}
${If} $DIRECTORY != ""
${CreateDirectory} "$INSTDIR\$DIRECTORY"
${CopyFiles} "$SOURCEDIR\$FILENAME" "$INSTDIR\$DIRECTORY\$FILENAME"
${EndIf}
; run program if requested
${If} $EXEC != ""
!insertmacro escapeVar $EXEC
!insertmacro escapeVar $EXEC_PARAMS
DetailPrint "$EXEC $EXEC_PARAMS"
ClearErrors
ExecWait '"$EXEC" $EXEC_PARAMS'
${If} ${Errors}
Push "Couldn't run $EXEC $EXEC_PARAMS'"
Call FatalError
${EndIf}
${EndIf}
${If} $SHORTCUT != ""
!insertmacro escapeVar $SHORTCUT
!insertmacro escapeVar $SHORTCUT_TARGET
!insertmacro escapeVar $SHORTCUT_PARAMETER
!insertmacro escapeVar $SHORTCUT_ICON
!insertmacro escapeVar $SHORTCUT_DIRECTORY
StrCpy "$SHORTCUT_DIRECTORY" "$SMPROGRAMS\$GAMENAME\$SHORTCUT_DIRECTORY" ; use same prefix for all shortcuts
${CreateDirectory} $SHORTCUT_DIRECTORY
${CreateShortCut} "$SHORTCUT_DIRECTORY\$SHORTCUT" $SHORTCUT_TARGET $SHORTCUT_PARAMETER $SHORTCUT_ICON 0
${EndIf}
${If} $INCLUDE == "yes"
Push $SPRING_INI ; save var on stack
Push $FILES
StrCpy $SPRING_INI "$SOURCEDIR\$FILENAME"
DetailPrint "Using include $SPRING_INI"
ReadINIStr $3 $SPRING_INI ${SPRING_MAIN_SECTION} "files" ; count of files
StrCpy $0 1
${While} $0 <= $3
Push "file$0"
Call fetchFile
IntOp $0 $0 + 1
${EndWhile}
Pop $FILES ; restore var from stack
Pop $SPRING_INI
${EndIf}
nofetch:
System::Store "l"
FunctionEnd
; called on installation end (when selected)
Function showReadme
ExecShell "open" $README
FunctionEnd
; run on exit (when selected)
Function runExit
${If} $EXEC_EXIT != ""
${AndIfNot} ${Silent}
ClearErrors
ExecShell "open" $EXEC_EXIT $EXEC_EXIT_PARAMETER
${If} ${Errors}
MessageBox MB_OK "Could not run '$EXEC_EXIT' '$EXEC_EXIT_PARAMETER'"
${EndIf}
${EndIf}
FunctionEnd
Section "-Install" SEC_INSTALL
${WriteRegStr} "${APP_REG_ROOT}" "${APP_REG_UNINSTALL}" "DisplayName" "${APP_NAME}"
${WriteRegStr} "${APP_REG_ROOT}" "${APP_REG_UNINSTALL}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
${WriteRegStr} "${APP_REG_ROOT}" "${APP_REG_UNINSTALL}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
!insertmacro createTempDir $TEMPDIR $INSTDIR
DetailPrint "Files: $FILES"
StrCpy $0 1
${While} $0 <= $FILES
Push "file$0"
Call fetchFile
IntOp $0 $0 + 1
${EndWhile}
writeUninstaller "$INSTDIR\uninstall.exe"
RMDIR $TEMPDIR
SectionEnd
;reads sizes from .ini and sets it to sections
Function SetSizes
StrCpy $0 1
${While} $0 <= $FILES
;$0 counter
;$1 size of file
;$2 section #
;$3 SEC_ID
;$4 sectionsize
;$5 sectionname
StrCpy $5 "file$0"
ReadINIStr $1 $SPRING_INI $5 "size"
ReadINIStr $2 $SPRING_INI $5 "section"
IntOp $3 ${SEC_0} + $2
SectionGetSize $3 $4
; size is in kbytes
IntOp $1 $1 / 1024
IntOp $4 $1 + $4
SectionSetSize $3 $4
IntOp $0 $0 + 1
${EndWhile}
FunctionEnd
Function .onInit
;initialize global vars
StrCpy $INSTALLERNAME $EXEFILE -4 ; remove .exe suffix from installer name
StrCpy $SOURCEDIR "$TEMP\$INSTALLERNAME - files"
StrCpy $SPRING_INI "$SOURCEDIR\$INSTALLERNAME.ini"
CreateDirectory $SOURCEDIR
${If} ${FileExists} $SPRING_INI
ReadINIStr $R0 $SPRING_INI ${SPRING_MAIN_SECTION} "alwaysupdate" ; count of files
${Else}
StrCpy $R0 "yes" ; download file
${EndIf}
${If} $R0 == "yes" ; ini doesn't exist, download it
ReadINIStr $UPDATEURL $SPRING_INI ${SPRING_MAIN_SECTION} "updateurl" ; count of files
${If} $UPDATEURL == ""
Push "SPRING:"
Call ReadCustomerData
Pop $UPDATEURL
${EndIf}
${If} $UPDATEURL != ""
${Do}
retrydownload:
inetc::get /RESUME "Your internet connection seems to have dropped out!\nPlease reconnect and click Retry to resume downloading..." $UPDATEURL $SPRING_INI /END
Pop $1
${If} $1 != ${INETC_GET_RESULTOK}
MessageBox MB_YESNO "Downloading $UPDATEURL failed, try again? $1" IDYES retrydownload
Abort
${EndIf}
${LoopUntil} $1 == ${INETC_GET_RESULTOK}
${Else}
Push "Config file not updated: couldn't extract url of config file from please attach with $\necho SPRING:http://path/to/ini$\n>>$EXEPATH"
Call FatalError
${EndIf}
${EndIf}
${IfNot} ${FileExists} $SPRING_INI
Push "Couldn't open $SPRING_INI"
Call FatalError
${EndIf}
ReadINIStr $R0 $SPRING_INI ${SPRING_MAIN_SECTION} "fileformat" ; count of files
${If} $R0 != "0.2"
Push "Invalid file format for $SPRING_INI: $R0, please update this installer!"
Call FatalError
${EndIf}
StrCpy $0 0
${While} $0 < 15
; $0=counter
; $1=option in .ini
; $2=SEC_ID
; $3=section flags
StrCpy $1 "section$0"
IntOp $2 ${SEC_0} + $0
ReadINIStr $R0 $SPRING_INI ${SPRING_MAIN_SECTION} $1
SectionSetText $2 $R0
StrCpy $1 "section$0_force"
ReadINIStr $R0 $SPRING_INI ${SPRING_MAIN_SECTION} $1
StrCpy $1 "section$0_selected"
ReadINIStr $R1 $SPRING_INI ${SPRING_MAIN_SECTION} $1
${If} $R0 == "yes"
SectionGetFlags $2 $3 ; get current flags
IntOp $3 $3 | ${SF_RO}
SectionSetFlags $2 $3
${EndIf}
${If} $R1 == "no"
SectionGetFlags $2 $3 ; get current flags
IntOp $3 $3 - ${SF_SELECTED}
SectionSetFlags $2 $3
${EndIf}
IntOp $0 $0 + 1
${EndWhile}
ReadINIStr $DESC_SECTION_0 $SPRING_INI ${SPRING_MAIN_SECTION} "section0_description"
ReadINIStr $DESC_SECTION_1 $SPRING_INI ${SPRING_MAIN_SECTION} "section1_description"
ReadINIStr $DESC_SECTION_2 $SPRING_INI ${SPRING_MAIN_SECTION} "section2_description"
ReadINIStr $DESC_SECTION_3 $SPRING_INI ${SPRING_MAIN_SECTION} "section3_description"
ReadINIStr $DESC_SECTION_4 $SPRING_INI ${SPRING_MAIN_SECTION} "section4_description"
ReadINIStr $DESC_SECTION_5 $SPRING_INI ${SPRING_MAIN_SECTION} "section5_description"
ReadINIStr $DESC_SECTION_6 $SPRING_INI ${SPRING_MAIN_SECTION} "section6_description"
ReadINIStr $DESC_SECTION_7 $SPRING_INI ${SPRING_MAIN_SECTION} "section7_description"
ReadINIStr $DESC_SECTION_8 $SPRING_INI ${SPRING_MAIN_SECTION} "section8_description"
ReadINIStr $DESC_SECTION_9 $SPRING_INI ${SPRING_MAIN_SECTION} "section9_description"
ReadINIStr $DESC_SECTION_10 $SPRING_INI ${SPRING_MAIN_SECTION} "section10_description"
ReadINIStr $DESC_SECTION_11 $SPRING_INI ${SPRING_MAIN_SECTION} "section11_description"
ReadINIStr $DESC_SECTION_12 $SPRING_INI ${SPRING_MAIN_SECTION} "section12_description"
ReadINIStr $DESC_SECTION_13 $SPRING_INI ${SPRING_MAIN_SECTION} "section13_description"
ReadINIStr $DESC_SECTION_14 $SPRING_INI ${SPRING_MAIN_SECTION} "section14_description"
ReadINIStr $DESC_SECTION_15 $SPRING_INI ${SPRING_MAIN_SECTION} "section15_description"
ReadINIStr $FILES $SPRING_INI ${SPRING_MAIN_SECTION} "files" ; count of files
ReadINIStr $README $SPRING_INI ${SPRING_MAIN_SECTION} "readme" ; url to readme
ReadINIStr $GAMENAME $SPRING_INI ${SPRING_MAIN_SECTION} "gamename" ; name of game
ReadINIStr $VERSION $SPRING_INI ${SPRING_MAIN_SECTION} "version" ; version of engine
ReadINIStr $EXEC_EXIT "$SPRING_INI" ${SPRING_MAIN_SECTION} "runonexit" ; (optional) execute on clock on "Finish" button
ReadINIStr $EXEC_EXIT_PARAMETER "$SPRING_INI" ${SPRING_MAIN_SECTION} "runonexit_parameter" ; parameter for exec_exit
ReadINIStr $SIZE "$SPRING_INI" ${SPRING_MAIN_SECTION} "size" ; size of all installed files
!insertmacro escapeVar $EXEC_EXIT
!insertmacro escapeVar $EXEC_EXIT_PARAMETER
call SetSizes
; SectionSetSize SEC_INSTALL $SIZE
FunctionEnd
Section /o "Clean downloaded files" SEC_CLEAN
; TODO
Delete "$SPRING_INI"
MessageBox MB_OK "Please delete $SOURCEDIR"
SectionEnd
;--------------------------------
; Uninstaller
;--------------------------------
Section Uninstall
;Can't uninstall if uninstall log is missing!
IfFileExists "$INSTDIR\${UninstLog}" +4
Delete "$INSTDIR\uninstall.exe"
MessageBox MB_OK|MB_ICONSTOP "$(UninstLogMissing)"
Abort
Push $R0
Push $R1
Push $R2
SetFileAttributes "$INSTDIR\${UninstLog}" NORMAL
FileOpen $UninstLog "$INSTDIR\${UninstLog}" r
StrCpy $R1 -1
GetLineCount:
ClearErrors
FileRead $UninstLog $R0
IntOp $R1 $R1 + 1
StrCpy $R0 $R0 -2
Push $R0
IfErrors 0 GetLineCount
Pop $R0
LoopRead:
StrCmp $R1 0 LoopDone
Pop $R0
IfFileExists "$R0\*.*" 0 +3
RMDir $R0 #is dir
Goto +9
IfFileExists $R0 0 +3
Delete $R0 #is file
Goto +6
StrCmp $R0 "${APP_REG_ROOT} ${APP_REG_UNINSTALL}" 0 +3
DeleteRegKey ${APP_REG_ROOT} "${APP_REG_UNINSTALL}" #is Reg Element
Goto +3
StrCmp $R0 "${APP_REG_ROOT} ${APP_REG_UNINSTALL}" 0 +2
DeleteRegKey ${APP_REG_ROOT} "${APP_REG_UNINSTALL}" #is Reg Element
IntOp $R1 $R1 - 1
Goto LoopRead
LoopDone:
FileClose $UninstLog
Delete "$INSTDIR\${UninstLog}"
Pop $R2
Pop $R1
Pop $R0
;Remove registry keys
;DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
;DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
Delete "$INSTDIR\uninstall.exe"
SectionEnd
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_0} $DESC_SECTION_0
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_1} $DESC_SECTION_1
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_2} $DESC_SECTION_2
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_3} $DESC_SECTION_3
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_4} $DESC_SECTION_4
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_5} $DESC_SECTION_5
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_6} $DESC_SECTION_6
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_7} $DESC_SECTION_7
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_8} $DESC_SECTION_8
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_9} $DESC_SECTION_9
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_10} $DESC_SECTION_10
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_11} $DESC_SECTION_11
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_12} $DESC_SECTION_12
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_13} $DESC_SECTION_13
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_14} $DESC_SECTION_14
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_15} $DESC_SECTION_15
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_CLEAN} "Delete downloadcache files at the end of installation"
!insertmacro MUI_FUNCTION_DESCRIPTION_END