1 |
jpye |
1570 |
Var DAI_RET |
2 |
jpye |
2442 |
Var DAI_MSG |
3 |
jpye |
1570 |
Var DAI_TMPFILE |
4 |
jpye |
2442 |
Var DAI_REMOVE |
5 |
jpye |
1570 |
|
6 |
jpye |
2605 |
!macro downloadAndInstall DAI_NAME DAI_URL DAI_FN DAI_CMD |
7 |
jpye |
2442 |
Push $0 |
8 |
|
|
Push $1 |
9 |
jpye |
1570 |
|
10 |
jpye |
2433 |
StrCpy $DAI_RET "" |
11 |
jpye |
2442 |
StrCpy $DAI_REMOVE "" |
12 |
jpye |
1570 |
|
13 |
jpye |
2442 |
${If} ${FileExists} "${DAI_FN}" |
14 |
|
|
DetailPrint "Found local file ${DAI_FN}..." |
15 |
|
|
${If} ${Cmd} `MessageBox MB_ICONQUESTION|MB_YESNO "File ${DAI_FN} was found in the current directory, so it may not be necessary to download it now.$\n$\nWould you like to run this local copy of the installer?" IDYES ` |
16 |
jpye |
2433 |
StrCpy $DAI_RET "success" |
17 |
jpye |
2442 |
StrCpy $DAI_TMPFILE "${DAI_FN}" |
18 |
jpye |
1571 |
${EndIf} |
19 |
jpye |
1570 |
${EndIf} |
20 |
jpye |
2433 |
|
21 |
|
|
${If} $DAI_RET != "success" |
22 |
jpye |
2442 |
DetailPrint "Downloading file ${DAI_FN}..." |
23 |
jpye |
2607 |
DetailPrint "URL: ${DAI_URL}" |
24 |
jpye |
2433 |
StrCpy $DAI_TMPFILE "$TEMP\${DAI_FN}" |
25 |
jpye |
2607 |
|
26 |
|
|
; Download files using the INETC plugin for NSIS, available from |
27 |
|
|
; http://nsis.sourceforge.net/Inetc_plug-in |
28 |
|
|
inetc::get /CAPTION "${DAI_FN}""${DAI_URL}" "$DAI_TMPFILE" /END |
29 |
|
|
Pop $DAI_RET ; return value = exit code, "OK" means OK |
30 |
jpye |
2433 |
|
31 |
jpye |
2607 |
${DoWhile} $DAI_RET != "OK" |
32 |
jpye |
2433 |
${If} $DAI_RET == "cancel" |
33 |
jpye |
2442 |
StrCpy $DAI_MSG "cancelled" |
34 |
jpye |
2433 |
${Else} |
35 |
jpye |
2442 |
StrCpy $DAI_MSG "failed (return '$DAI_RET')" |
36 |
jpye |
2433 |
${EndIf} |
37 |
|
|
|
38 |
jpye |
2442 |
DetailPrint "Download of ${DAI_FN} $DAI_MSG." |
39 |
jpye |
2607 |
${IfNot} ${Cmd} `MessageBox MB_ICONEXCLAMATION|MB_YESNO "${DAI_NAME} download $DAI_MSG. URL was:$\n$\n${DAI_URL}$\n$\nDo you wish to re-attempt the download?" IDYES ` |
40 |
jpye |
2433 |
; response was no |
41 |
jpye |
2442 |
;MessageBox MB_OK "File ${DAI_NAME} will not be installed..." |
42 |
|
|
Pop $1 |
43 |
|
|
Pop $0 |
44 |
|
|
Push 1 ; error code |
45 |
jpye |
2433 |
Return |
46 |
|
|
${EndIf} |
47 |
jpye |
2442 |
|
48 |
|
|
;MessageBox MB_OK "Will re-attempt download of ${DAI_NAME}" |
49 |
|
|
${If} ${FileExists} "$DAI_TMPFILE" |
50 |
|
|
Delete "$DAI_TMPFILE" |
51 |
|
|
${EndIf} |
52 |
|
|
${Loop} |
53 |
|
|
|
54 |
|
|
StrCpy $DAI_REMOVE "1" |
55 |
jpye |
2433 |
${EndIf} |
56 |
jpye |
2442 |
|
57 |
jpye |
1570 |
|
58 |
jpye |
2442 |
;MessageBox MB_OK "Installing ${DAI_NAME}...$\n$\nCommand: ${DAI_CMD}" |
59 |
jpye |
2433 |
DetailPrint "Installing ${DAI_NAME} (${DAI_FN})" |
60 |
|
|
ExecWait "${DAI_CMD}" $0 |
61 |
jpye |
2442 |
DetailPrint "Installer return code = $0" |
62 |
jpye |
2433 |
${If} $0 != "0" |
63 |
|
|
MessageBox MB_ICONEXCLAMATION|MB_OK "${DAI_NAME} installer returned a non-zero error code '$0'" |
64 |
|
|
${EndIf} |
65 |
|
|
|
66 |
jpye |
2442 |
${If} $DAI_REMOVE != "" |
67 |
|
|
;MessageBox MB_OK "Deleting $DAI_TMPFILE..." |
68 |
|
|
Delete "$DAI_TMPFILE" |
69 |
|
|
${EndIf} |
70 |
jpye |
2433 |
|
71 |
jpye |
2442 |
; Restore registers |
72 |
|
|
Pop $1 |
73 |
|
|
Pop $0 |
74 |
|
|
|
75 |
|
|
; Return values |
76 |
jpye |
2433 |
Push $0 |
77 |
jpye |
1570 |
!macroend |