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

Contents of /trunk/nsis/download.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2607 - (show annotations) (download)
Tue Apr 24 23:16:19 2012 UTC (11 years, 7 months ago) by jpye
File size: 2265 byte(s)
Working installer for 0.9.8 32-bit.
1 Var DAI_RET
2 Var DAI_MSG
3 Var DAI_TMPFILE
4 Var DAI_REMOVE
5
6 !macro downloadAndInstall DAI_NAME DAI_URL DAI_FN DAI_CMD
7 Push $0
8 Push $1
9
10 StrCpy $DAI_RET ""
11 StrCpy $DAI_REMOVE ""
12
13 ${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 StrCpy $DAI_RET "success"
17 StrCpy $DAI_TMPFILE "${DAI_FN}"
18 ${EndIf}
19 ${EndIf}
20
21 ${If} $DAI_RET != "success"
22 DetailPrint "Downloading file ${DAI_FN}..."
23 DetailPrint "URL: ${DAI_URL}"
24 StrCpy $DAI_TMPFILE "$TEMP\${DAI_FN}"
25
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
31 ${DoWhile} $DAI_RET != "OK"
32 ${If} $DAI_RET == "cancel"
33 StrCpy $DAI_MSG "cancelled"
34 ${Else}
35 StrCpy $DAI_MSG "failed (return '$DAI_RET')"
36 ${EndIf}
37
38 DetailPrint "Download of ${DAI_FN} $DAI_MSG."
39 ${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 ; response was no
41 ;MessageBox MB_OK "File ${DAI_NAME} will not be installed..."
42 Pop $1
43 Pop $0
44 Push 1 ; error code
45 Return
46 ${EndIf}
47
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 ${EndIf}
56
57
58 ;MessageBox MB_OK "Installing ${DAI_NAME}...$\n$\nCommand: ${DAI_CMD}"
59 DetailPrint "Installing ${DAI_NAME} (${DAI_FN})"
60 ExecWait "${DAI_CMD}" $0
61 DetailPrint "Installer return code = $0"
62 ${If} $0 != "0"
63 MessageBox MB_ICONEXCLAMATION|MB_OK "${DAI_NAME} installer returned a non-zero error code '$0'"
64 ${EndIf}
65
66 ${If} $DAI_REMOVE != ""
67 ;MessageBox MB_OK "Deleting $DAI_TMPFILE..."
68 Delete "$DAI_TMPFILE"
69 ${EndIf}
70
71 ; Restore registers
72 Pop $1
73 Pop $0
74
75 ; Return values
76 Push $0
77 !macroend

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