1 | ; |
---|
2 | ; $Id$ |
---|
3 | ; |
---|
4 | ; RTEMS Autotools Installer. |
---|
5 | ; |
---|
6 | ; Copyright Chris Johns (chrisj@rtems.org) |
---|
7 | ; |
---|
8 | |
---|
9 | ;!define EMPTY_INSTALLER |
---|
10 | |
---|
11 | !define PRODUCT_NAME "RTEMS Autotools" |
---|
12 | !define PRODUCT_VERSION ${RTEMS_VERSION} |
---|
13 | !define PRODUCT_PUBLISHER "RTEM Project Team" |
---|
14 | !define PRODUCT_WEB_SITE "http://www.rtems.org/" |
---|
15 | |
---|
16 | ; MUI 1.66 compatible ------ |
---|
17 | !include "MUI.nsh" |
---|
18 | |
---|
19 | ; MUI Settings |
---|
20 | !define MUI_ABORTWARNING |
---|
21 | !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\win-install.ico" |
---|
22 | !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\win-uninstall.ico" |
---|
23 | |
---|
24 | !define MUI_HEADERIMAGE |
---|
25 | !define MUI_HEADERIMAGE_BITMAP "${RTEMS_LOGO}" |
---|
26 | |
---|
27 | !define MUI_COMPONENTSPAGE_SMALLDESC |
---|
28 | |
---|
29 | ; Welcome page |
---|
30 | !insertmacro MUI_PAGE_WELCOME |
---|
31 | ; Details of what will happen. |
---|
32 | Page custom RTEMSMessage |
---|
33 | ; License page |
---|
34 | ;!define MUI_LICENSEPAGE_CHECKBOX |
---|
35 | !insertmacro MUI_PAGE_LICENSE "${RTEMS_LICENSE_FILE}" |
---|
36 | ; Components page |
---|
37 | !insertmacro MUI_PAGE_COMPONENTS |
---|
38 | ; Directory page |
---|
39 | !insertmacro MUI_PAGE_DIRECTORY |
---|
40 | ; Instfiles page |
---|
41 | !insertmacro MUI_PAGE_INSTFILES |
---|
42 | ; Finish page |
---|
43 | !insertmacro MUI_PAGE_FINISH |
---|
44 | |
---|
45 | ; Uninstaller pages |
---|
46 | !insertmacro MUI_UNPAGE_INSTFILES |
---|
47 | |
---|
48 | ; Language files |
---|
49 | !insertmacro MUI_LANGUAGE "English" |
---|
50 | |
---|
51 | ; Reserve files |
---|
52 | !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS |
---|
53 | |
---|
54 | ; MUI end ------ |
---|
55 | |
---|
56 | ReserveFile "rtems.ini" |
---|
57 | !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS |
---|
58 | |
---|
59 | Name "${PRODUCT_NAME} ${PRODUCT_VERSION} (${RTEMS_TARGET})" |
---|
60 | OutFile "${RTEMS_BINARY}/rtems${PRODUCT_VERSION}-tools-${RTEMS_TARGET}-${RTEMS_BUILD_VERSION}.exe" |
---|
61 | InstallDir "C:\opt\rtems-${PRODUCT_VERSION}" |
---|
62 | ShowInstDetails show |
---|
63 | ShowUnInstDetails show |
---|
64 | BrandingText "RTEMS ${RTEMS_TARGET} Tools v${PRODUCT_VERSION}" |
---|
65 | AllowRootDirInstall false |
---|
66 | AutoCloseWindow false |
---|
67 | CRCCheck force |
---|
68 | |
---|
69 | !include "${RTEMS_SOURCE}/msys-path.nsi" |
---|
70 | |
---|
71 | Section "RTEMS ${RTEMS_TARGET} Tools" SecTools |
---|
72 | SetDetailsView show |
---|
73 | AddSize ${RTEMS_TOOLS_SIZE} |
---|
74 | |
---|
75 | /* |
---|
76 | * Detect if MSYS is installed. |
---|
77 | */ |
---|
78 | Call MSYSDetect |
---|
79 | Pop $9 |
---|
80 | StrCmp $9 "not-found" 0 +3 |
---|
81 | MessageBox MB_OK "Could not find a valid MSYS. Please install from http://www.mingw.org/" |
---|
82 | Abort |
---|
83 | SetOutPath "$INSTDIR\Uninstall" |
---|
84 | SetOutPath "$INSTDIR\Packages\Build" |
---|
85 | SetOutPath "$INSTDIR\Packages\Build" |
---|
86 | SetOutPath "$INSTDIR\Packages\Source" |
---|
87 | File "${RTEMS_SOURCE}/build-autotools.sh" |
---|
88 | File "${RTEMS_SOURCE}/ba-wrap.sh" |
---|
89 | File "${RTEMS_PACKAGE_SOURCE}/${RTEMS_AUTOCONF_SOURCE}" |
---|
90 | File "${RTEMS_SOURCE}/autoconf.def" |
---|
91 | File "${RTEMS_SOURCE}/automake.def" |
---|
92 | !insertmacro RTEMS_AUTOCONF_PATCHES |
---|
93 | File "${RTEMS_PACKAGE_SOURCE}/${RTEMS_AUTOMAKE_SOURCE}" |
---|
94 | !insertmacro RTEMS_AUTOMAKE_PATCHES |
---|
95 | |
---|
96 | Delete "$INSTDIR\Packages\Source\at-log.txt" |
---|
97 | |
---|
98 | /* |
---|
99 | * Need to fix the slashes when using a Unix type shell. |
---|
100 | */ |
---|
101 | Push "$INSTDIR\Packages\Source\ba-wrap.sh" |
---|
102 | Push '\\' |
---|
103 | Pop $R0 |
---|
104 | Call StrSlash |
---|
105 | Pop $R1 |
---|
106 | Push "$INSTDIR\Packages\Build" |
---|
107 | Push '\\' |
---|
108 | Pop $R0 |
---|
109 | Call StrSlash |
---|
110 | Pop $R2 |
---|
111 | |
---|
112 | /* |
---|
113 | * Build Autoconf. |
---|
114 | */ |
---|
115 | Push "$INSTDIR\Packages\Source\autoconf.def" |
---|
116 | Push '\\' |
---|
117 | Pop $R0 |
---|
118 | Call StrSlash |
---|
119 | Pop $R0 |
---|
120 | DetailPrint "Building autoconf. Command window closes automatically." |
---|
121 | ExecWait '"$9\bin\sh" --login -c "$R1 -p /opt/rtems-${PRODUCT_VERSION} -b $R2 -c $R0"' $0 |
---|
122 | BringToFront |
---|
123 | IntCmp $0 0 +3 |
---|
124 | MessageBox MB_OK "Autoconf build failed. See $INSTDIR\Packages\Source\at-log.txt" |
---|
125 | Abort |
---|
126 | |
---|
127 | BringToFront |
---|
128 | |
---|
129 | Push "$INSTDIR\Uninstall\${RTEMS_AUTOCONF}-files" |
---|
130 | call InstallFilesFromFile |
---|
131 | |
---|
132 | /* |
---|
133 | * Build Automake. |
---|
134 | */ |
---|
135 | Push "$INSTDIR\Packages\Source\automake.def" |
---|
136 | Push '\\' |
---|
137 | Pop $R0 |
---|
138 | Call StrSlash |
---|
139 | Pop $R0 |
---|
140 | DetailPrint "Building automake. Command window closes automatically." |
---|
141 | ExecWait '"$9\bin\sh" --login -c "$R1 -p /opt/rtems-${PRODUCT_VERSION} -b $R2 -c $R0"' $0 |
---|
142 | BringToFront |
---|
143 | IntCmp $0 0 +3 |
---|
144 | MessageBox MB_OK "Automake build failed. See $INSTDIR\Packages\Source\at-log.txt" |
---|
145 | Abort |
---|
146 | |
---|
147 | BringToFront |
---|
148 | |
---|
149 | Push "$INSTDIR\Uninstall\${RTEMS_AUTOMAKE}-files" |
---|
150 | call InstallFilesFromFile |
---|
151 | |
---|
152 | DetailPrint "Removing Build directory" |
---|
153 | RMDir /r "$INSTDIR\Packages\Build" |
---|
154 | SectionEnd |
---|
155 | |
---|
156 | !macro FILE_WRITE_LINE Handle Text |
---|
157 | FileWrite ${Handle} `${Text}` |
---|
158 | FileWriteByte ${Handle} "13" |
---|
159 | FileWriteByte ${Handle} "10" |
---|
160 | !macroend |
---|
161 | |
---|
162 | Function .onInit |
---|
163 | ;Extract InstallOptions INI files |
---|
164 | !insertmacro MUI_INSTALLOPTIONS_EXTRACT "rtems.ini" |
---|
165 | FunctionEnd |
---|
166 | |
---|
167 | Function RTEMSMessage |
---|
168 | |
---|
169 | !insertmacro MUI_HEADER_TEXT \ |
---|
170 | "RTEMS Tools (Autoconf/Automake)" \ |
---|
171 | "A tool set for the RTEMS operating system." |
---|
172 | |
---|
173 | ;Display the Install Options dialog |
---|
174 | |
---|
175 | Push $R0 |
---|
176 | Push $R1 |
---|
177 | Push $R2 |
---|
178 | |
---|
179 | InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\rtems.ini" |
---|
180 | Pop $R0 |
---|
181 | |
---|
182 | GetDlgItem $R1 $R0 1200 ;1200 + Field number - 1 |
---|
183 | ;$R1 contains the HWND of the first field |
---|
184 | CreateFont $R2 "Tahoma" "8" "300" |
---|
185 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
186 | |
---|
187 | GetDlgItem $R1 $R0 1201 ;1200 + Field number - 1 |
---|
188 | ;$R1 contains the HWND of the first field |
---|
189 | CreateFont $R2 "Tahoma" "12" "700" |
---|
190 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
191 | |
---|
192 | GetDlgItem $R1 $R0 1202 ;1200 + Field number - 1 |
---|
193 | ;$R1 contains the HWND of the first field |
---|
194 | CreateFont $R2 "Tahoma" "8" "300" |
---|
195 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
196 | |
---|
197 | GetDlgItem $R1 $R0 1203 ;1200 + Field number - 1 |
---|
198 | ;$R1 contains the HWND of the first field |
---|
199 | CreateFont $R2 "Tahoma" "8" "300" |
---|
200 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
201 | |
---|
202 | GetDlgItem $R1 $R0 1204 ;1200 + Field number - 1 |
---|
203 | ;$R1 contains the HWND of the first field |
---|
204 | CreateFont $R2 "Tahoma" "8" "300" |
---|
205 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
206 | |
---|
207 | GetDlgItem $R1 $R0 1205 ;1200 + Field number - 1 |
---|
208 | ;$R1 contains the HWND of the first field |
---|
209 | CreateFont $R2 "Tahoma" "8" "300" |
---|
210 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
211 | |
---|
212 | GetDlgItem $R1 $R0 1206 ;1200 + Field number - 1 |
---|
213 | ;$R1 contains the HWND of the first field |
---|
214 | CreateFont $R2 "Tahoma" "8" "300" |
---|
215 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
216 | |
---|
217 | InstallOptions::show |
---|
218 | Pop $R0 |
---|
219 | |
---|
220 | Pop $R2 |
---|
221 | Pop $R1 |
---|
222 | Pop $R0 |
---|
223 | |
---|
224 | FunctionEnd |
---|
225 | |
---|
226 | Var FileList |
---|
227 | |
---|
228 | Function InstallFilesFromFile |
---|
229 | Pop $R6 |
---|
230 | Push $R7 |
---|
231 | Push $R8 |
---|
232 | Push $R9 |
---|
233 | DetailPrint "Installing file list: $R6" |
---|
234 | SetFileAttributes "$R6" NORMAL |
---|
235 | FileOpen $FileList "$R6" r |
---|
236 | IfErrors 0 +3 |
---|
237 | MessageBox MB_OK "Internal error reading file list (0:$R6)." |
---|
238 | Abort |
---|
239 | ReadLoop: |
---|
240 | FileRead $FileList $R7 |
---|
241 | IfErrors Done |
---|
242 | StrCpy $R7 $R7 -1 # has a \n only at the end |
---|
243 | StrCpy $R8 $R7 |
---|
244 | StrCpy $R7 $R7 1 # first character on the line |
---|
245 | StrCpy $R8 $R8 256 2 |
---|
246 | StrCmpS $R7 "D" ReadLoop |
---|
247 | StrCmpS $R7 "b" 0 +3 |
---|
248 | StrCpy $R9 $R8 |
---|
249 | Goto ReadLoop |
---|
250 | StrCmpS $R7 "d" 0 +3 |
---|
251 | CreateDirectory "$INSTDIR\$R8" |
---|
252 | Goto ReadLoop |
---|
253 | StrCmpS $R7 "f" 0 +3 |
---|
254 | CopyFiles /SILENT "$INSTDIR\Packages\Build\$R9\$R8" "$INSTDIR\$R8" |
---|
255 | Goto ReadLoop |
---|
256 | MessageBox MB_OK "Internal error installing package (2:$R6)." |
---|
257 | Abort |
---|
258 | Done: |
---|
259 | FileClose $FileList |
---|
260 | ClearErrors |
---|
261 | Pop $R9 |
---|
262 | Pop $R8 |
---|
263 | Pop $R7 |
---|
264 | FunctionEnd |
---|
265 | |
---|
266 | Function un.RemoveFilesFromFile |
---|
267 | ; Two passes, one to delete files then the directories |
---|
268 | ; This is due to the order in the *-files list. Plus |
---|
269 | ; RMDir seems to stuff things up (maybe a NSIS bug!) |
---|
270 | Pop $R6 |
---|
271 | Push $R7 |
---|
272 | Push $R8 |
---|
273 | Push $R9 |
---|
274 | DetailPrint "Delete file list: $R6" |
---|
275 | SetFileAttributes "$R6" NORMAL |
---|
276 | FileOpen $FileList "$R6" r |
---|
277 | IfErrors 0 +3 |
---|
278 | MessageBox MB_OK "Internal error reading file list (0:$R6)." |
---|
279 | Abort |
---|
280 | ReadLoop: |
---|
281 | FileRead $FileList $R7 |
---|
282 | IfErrors Pass2 |
---|
283 | StrCpy $R7 $R7 -1 # has a \n only at the end |
---|
284 | StrCpy $R8 $R7 |
---|
285 | StrCpy $R7 $R7 1 # first character on the line |
---|
286 | StrCpy $R8 $R8 256 2 |
---|
287 | StrCmp $R7 "b" ReadLoop |
---|
288 | StrCmp $R7 "d" ReadLoop |
---|
289 | StrCmp $R7 "D" ReadLoop |
---|
290 | StrCmp $R7 "f" 0 +3 |
---|
291 | Delete "$INSTDIR\$R8" |
---|
292 | Goto ReadLoop |
---|
293 | MessageBox MB_OK "Internal error removing package (2:$R6)." |
---|
294 | Abort |
---|
295 | Pass2: |
---|
296 | ClearErrors |
---|
297 | FileSeek $FileList 0 SET |
---|
298 | ReadLoop2: |
---|
299 | FileRead $FileList $R7 |
---|
300 | IfErrors Done |
---|
301 | StrCpy $R7 $R7 -1 # has a \n only at the end |
---|
302 | StrCpy $R8 $R7 |
---|
303 | StrCpy $R7 $R7 1 # first character on the line |
---|
304 | StrCpy $R8 $R8 256 2 |
---|
305 | StrCmpS $R7 "b" ReadLoop2 |
---|
306 | StrCmpS $R7 "d" ReadLoop2 |
---|
307 | StrCmpS $R7 "f" ReadLoop2 |
---|
308 | StrCmpS $R7 "D" 0 Fail |
---|
309 | ifFileExists "$INSTDIR\$R8\*.*" 0 ReadLoop2 |
---|
310 | RMDir "$INSTDIR\$R8" #is dir |
---|
311 | Delete "$INSTDIR\$R8" |
---|
312 | ClearErrors |
---|
313 | Goto ReadLoop2 |
---|
314 | Fail: |
---|
315 | MessageBox MB_OK "Internal error removing package (2:$R6)." |
---|
316 | Abort |
---|
317 | Done: |
---|
318 | FileClose $FileList |
---|
319 | ClearErrors |
---|
320 | Delete $R6 |
---|
321 | Pop $R9 |
---|
322 | Pop $R8 |
---|
323 | Pop $R7 |
---|
324 | FunctionEnd |
---|
325 | |
---|
326 | ; Push $filenamestring (e.g. 'c:\this\and\that\filename.htm') |
---|
327 | ; Push '\\' |
---|
328 | ; Pop $R0 |
---|
329 | ; Call StrSlash |
---|
330 | ; Pop $R0 |
---|
331 | ; ;Now $R0 contains 'c:/this/and/that/filename.htm' |
---|
332 | Function StrSlash |
---|
333 | Exch $R0 |
---|
334 | Push $R1 |
---|
335 | Push $R2 |
---|
336 | StrCpy $R1 0 |
---|
337 | loop: |
---|
338 | IntOp $R1 $R1 - 1 |
---|
339 | StrCpy $R2 $R0 1 $R1 |
---|
340 | StrCmp $R2 "" done |
---|
341 | StrCmp $R2 "\" 0 loop ;" keep to get Emacs for fontlock |
---|
342 | StrCpy $R2 $R0 $R1 |
---|
343 | Push $R1 |
---|
344 | IntOp $R1 $R1 + 1 |
---|
345 | StrCpy $R1 $R0 "" $R1 |
---|
346 | StrCpy $R0 "$R2/$R1" |
---|
347 | Pop $R1 |
---|
348 | IntOp $R1 $R1 - 1 |
---|
349 | Goto loop |
---|
350 | done: |
---|
351 | Pop $R2 |
---|
352 | Pop $R1 |
---|
353 | Exch $R0 |
---|
354 | FunctionEnd |
---|
355 | |
---|
356 | Section -Post |
---|
357 | StrCpy $R0 "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-${RTEMS_TARGET}-uninst.exe" |
---|
358 | WriteUninstaller "$R0" |
---|
359 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ |
---|
360 | "DisplayName" "$(^Name)" |
---|
361 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ |
---|
362 | "UninstallString" "$R0" |
---|
363 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ |
---|
364 | "DisplayVersion" "${PRODUCT_VERSION} Build-${RTEMS_BUILD_VERSION}" |
---|
365 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ |
---|
366 | "URLInfoAbout" "${PRODUCT_WEB_SITE}" |
---|
367 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ |
---|
368 | "Publisher" "${PRODUCT_PUBLISHER}" |
---|
369 | SectionEnd |
---|
370 | |
---|
371 | Section Uninstall |
---|
372 | SetDetailsView show |
---|
373 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" |
---|
374 | DetailPrint "Delete the installed files" |
---|
375 | Push "$INSTDIR\Uninstall\${RTEMS_AUTOCONF}-files" |
---|
376 | call un.RemoveFilesFromFile |
---|
377 | Push "$INSTDIR\Uninstall\${RTEMS_AUTOMAKE}-files" |
---|
378 | call un.RemoveFilesFromFile |
---|
379 | RMDir "$INSTDIR\Uninstall" |
---|
380 | Delete "$INSTDIR\Packages\Source\build-autotools.sh" |
---|
381 | Delete "$INSTDIR\Packages\Source\ba-wrap.sh" |
---|
382 | Delete "$INSTDIR\Packages\Source\${RTEMS_AUTOCONF_SOURCE}" |
---|
383 | Delete "$INSTDIR\Packages\Source\${RTEMS_AUTOMAKE_SOURCE}" |
---|
384 | Delete "$INSTDIR\Packages\Source\autoconf.def" |
---|
385 | Delete "$INSTDIR\Packages\Source\automake.def" |
---|
386 | Delete "$INSTDIR\Packages\Source\at-log.txt" |
---|
387 | !insertmacro RTEMS_DELETE_AUTOCONF_PATCHES |
---|
388 | !insertmacro RTEMS_DELETE_AUTOMAKE_PATCHES |
---|
389 | RMDir "$INSTDIR\Packages\Source" |
---|
390 | RMDir "$INSTDIR\Packages\Build" |
---|
391 | Delete $INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-${RTEMS_TARGET}-uninst.exe |
---|
392 | RMDir "$INSTDIR" |
---|
393 | DetailPrint "All done." |
---|
394 | SetAutoClose false |
---|
395 | SectionEnd |
---|