1 | ; |
---|
2 | ; $Id$ |
---|
3 | ; |
---|
4 | ; RTEMS Tools Installer. |
---|
5 | ; |
---|
6 | ; Copyright Chris Johns (chrisj@rtems.org) |
---|
7 | ; |
---|
8 | |
---|
9 | ;!define EMPTY_INSTALLER |
---|
10 | |
---|
11 | !define PRODUCT_NAME "RTEMS Tools" |
---|
12 | !define PRODUCT_VERSION ${RTEMS_VERSION} |
---|
13 | !define PRODUCT_PUBLISHER "RTEMS 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 | !ifdef COMMON_FILES |
---|
61 | OutFile "${RTEMS_BINARY}/rtems${PRODUCT_VERSION}-tools-${RTEMS_BUILD_VERSION}.exe" |
---|
62 | !else |
---|
63 | OutFile "${RTEMS_BINARY}/${RTEMS_OUTFILE}" |
---|
64 | !endif |
---|
65 | InstallDir "C:\opt\rtems-${PRODUCT_VERSION}" |
---|
66 | ShowInstDetails show |
---|
67 | ShowUnInstDetails show |
---|
68 | BrandingText "RTEMS ${RTEMS_TARGET} Tools v${PRODUCT_VERSION}" |
---|
69 | AllowRootDirInstall false |
---|
70 | AutoCloseWindow false |
---|
71 | CRCCheck force |
---|
72 | |
---|
73 | !include "${RTEMS_SOURCE}/msys-path.nsi" |
---|
74 | |
---|
75 | Section -SecFiles |
---|
76 | !insertmacro RTEMS_INSTALL_FILES |
---|
77 | SectionEnd |
---|
78 | |
---|
79 | !ifdef COMMON_FILES |
---|
80 | Section -SecCommon |
---|
81 | SetOutPath "$INSTDIR" |
---|
82 | File "${RTEMS_SOURCE}/AUTHORS" |
---|
83 | File "${RTEMS_SOURCE}/COPYING" |
---|
84 | File "${RTEMS_SOURCE}/README" |
---|
85 | SectionEnd |
---|
86 | !endif |
---|
87 | |
---|
88 | !macro FILE_WRITE_LINE Handle Text |
---|
89 | FileWrite ${Handle} `${Text}` |
---|
90 | FileWriteByte ${Handle} "13" |
---|
91 | FileWriteByte ${Handle} "10" |
---|
92 | !macroend |
---|
93 | |
---|
94 | Function .onInit |
---|
95 | ;Extract InstallOptions INI files |
---|
96 | !insertmacro MUI_INSTALLOPTIONS_EXTRACT "rtems.ini" |
---|
97 | FunctionEnd |
---|
98 | |
---|
99 | Function RTEMSMessage |
---|
100 | |
---|
101 | !insertmacro MUI_HEADER_TEXT \ |
---|
102 | "RTEMS Tools (${RTEMS_TARGET})" \ |
---|
103 | "A tool set for the RTEMS operating system." |
---|
104 | |
---|
105 | ;Display the Install Options dialog |
---|
106 | |
---|
107 | Push $R0 |
---|
108 | Push $R1 |
---|
109 | Push $R2 |
---|
110 | |
---|
111 | InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\rtems.ini" |
---|
112 | Pop $R0 |
---|
113 | |
---|
114 | GetDlgItem $R1 $R0 1200 ;1200 + Field number - 1 |
---|
115 | ;$R1 contains the HWND of the first field |
---|
116 | CreateFont $R2 "Tahoma" "8" "300" |
---|
117 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
118 | |
---|
119 | GetDlgItem $R1 $R0 1201 ;1200 + Field number - 1 |
---|
120 | ;$R1 contains the HWND of the first field |
---|
121 | CreateFont $R2 "Tahoma" "12" "700" |
---|
122 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
123 | |
---|
124 | GetDlgItem $R1 $R0 1202 ;1200 + Field number - 1 |
---|
125 | ;$R1 contains the HWND of the first field |
---|
126 | CreateFont $R2 "Tahoma" "8" "300" |
---|
127 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
128 | |
---|
129 | GetDlgItem $R1 $R0 1203 ;1200 + Field number - 1 |
---|
130 | ;$R1 contains the HWND of the first field |
---|
131 | CreateFont $R2 "Tahoma" "8" "300" |
---|
132 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
133 | |
---|
134 | GetDlgItem $R1 $R0 1204 ;1200 + Field number - 1 |
---|
135 | ;$R1 contains the HWND of the first field |
---|
136 | CreateFont $R2 "Tahoma" "8" "300" |
---|
137 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
138 | |
---|
139 | GetDlgItem $R1 $R0 1205 ;1200 + Field number - 1 |
---|
140 | ;$R1 contains the HWND of the first field |
---|
141 | CreateFont $R2 "Tahoma" "8" "300" |
---|
142 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
143 | |
---|
144 | GetDlgItem $R1 $R0 1206 ;1200 + Field number - 1 |
---|
145 | ;$R1 contains the HWND of the first field |
---|
146 | CreateFont $R2 "Tahoma" "8" "300" |
---|
147 | SendMessage $R1 ${WM_SETFONT} $R2 0 |
---|
148 | |
---|
149 | InstallOptions::show |
---|
150 | Pop $R0 |
---|
151 | |
---|
152 | Pop $R2 |
---|
153 | Pop $R1 |
---|
154 | Pop $R0 |
---|
155 | |
---|
156 | FunctionEnd |
---|
157 | |
---|
158 | ; Push $filenamestring (e.g. 'c:\this\and\that\filename.htm') |
---|
159 | ; Push '\\' |
---|
160 | ; Pop $R0 |
---|
161 | ; Call StrSlash |
---|
162 | ; Pop $R0 |
---|
163 | ; ;Now $R0 contains 'c:/this/and/that/filename.htm' |
---|
164 | Function StrSlash |
---|
165 | Exch $R0 |
---|
166 | Push $R1 |
---|
167 | Push $R2 |
---|
168 | StrCpy $R1 0 |
---|
169 | loop: |
---|
170 | IntOp $R1 $R1 - 1 |
---|
171 | StrCpy $R2 $R0 1 $R1 |
---|
172 | StrCmp $R2 "" done |
---|
173 | StrCmp $R2 "\" 0 loop ; " |
---|
174 | StrCpy $R2 $R0 $R1 |
---|
175 | Push $R1 |
---|
176 | IntOp $R1 $R1 + 1 |
---|
177 | StrCpy $R1 $R0 "" $R1 |
---|
178 | StrCpy $R0 "$R2/$R1" |
---|
179 | Pop $R1 |
---|
180 | IntOp $R1 $R1 - 1 |
---|
181 | Goto loop |
---|
182 | done: |
---|
183 | Pop $R2 |
---|
184 | Pop $R1 |
---|
185 | Exch $R0 |
---|
186 | FunctionEnd |
---|
187 | |
---|
188 | !ifdef COMMON_FILES |
---|
189 | Section -BatchFiles |
---|
190 | FileOpen $9 $INSTDIR\rtems.bat w |
---|
191 | !insertmacro FILE_WRITE_LINE $9 "@echo off" |
---|
192 | !insertmacro FILE_WRITE_LINE $9 "rem RTEMS batch file: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}" |
---|
193 | !insertmacro FILE_WRITE_LINE $9 "set PATH=$INSTDIR\bin;c:\mingw\bin;c:\msys\1.0\bin;%PATH%" |
---|
194 | !insertmacro FILE_WRITE_LINE $9 "set PROMPT=RTEMS $$P$$G" |
---|
195 | !insertmacro FILE_WRITE_LINE $9 "If $\"x%OS%x$\" == $\"xWindows_NTx$\" Goto WinNT_Title" |
---|
196 | !insertmacro FILE_WRITE_LINE $9 "doskey > Nul" |
---|
197 | !insertmacro FILE_WRITE_LINE $9 "goto Finished" |
---|
198 | !insertmacro FILE_WRITE_LINE $9 ":WinNT_Title" |
---|
199 | !insertmacro FILE_WRITE_LINE $9 "Title RTEMS ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}" |
---|
200 | !insertmacro FILE_WRITE_LINE $9 ":Finished" |
---|
201 | FileClose $9 |
---|
202 | |
---|
203 | FileOpen $9 $INSTDIR\rtems-cmd.bat w |
---|
204 | !insertmacro FILE_WRITE_LINE $9 "@echo off" |
---|
205 | !insertmacro FILE_WRITE_LINE $9 "rem RTEMS batch file: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}" |
---|
206 | !insertmacro FILE_WRITE_LINE $9 "If $\"x%OS%x$\" == $\"xWindows_NTx$\" Goto WinNT" |
---|
207 | !insertmacro FILE_WRITE_LINE $9 "start command.com /e:4096 /k $INSTDIR\rtems.bat %1 %2 %3 %4" |
---|
208 | !insertmacro FILE_WRITE_LINE $9 "exit" |
---|
209 | !insertmacro FILE_WRITE_LINE $9 ":WinNT" |
---|
210 | !insertmacro FILE_WRITE_LINE $9 "start cmd.exe /k $INSTDIR\rtems.bat %1 %2 %3 %4" |
---|
211 | !insertmacro FILE_WRITE_LINE $9 "exit" |
---|
212 | FileClose $9 |
---|
213 | |
---|
214 | FileOpen $9 $INSTDIR\sh-run.bat w |
---|
215 | !insertmacro FILE_WRITE_LINE $9 "@echo off" |
---|
216 | !insertmacro FILE_WRITE_LINE $9 "rem RTEMS batch file: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}" |
---|
217 | !insertmacro FILE_WRITE_LINE $9 "rem We can only handle 9 parameters. More is too hard." |
---|
218 | !insertmacro FILE_WRITE_LINE $9 "call $INSTDIR\rtems.bat" |
---|
219 | !insertmacro FILE_WRITE_LINE $9 "%1 %2 %3 %4 %5 %6 %7 %8 %9" |
---|
220 | FileClose $9 |
---|
221 | |
---|
222 | FileOpen $9 $INSTDIR\vs-make.sh w |
---|
223 | !insertmacro FILE_WRITE_LINE $9 "#! /bin/sh" |
---|
224 | !insertmacro FILE_WRITE_LINE $9 "# RTEMS script: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}" |
---|
225 | !insertmacro FILE_WRITE_LINE $9 "if [ ! -d $$1 ]; then" |
---|
226 | !insertmacro FILE_WRITE_LINE $9 " echo $\"error: no build directory found$\"" |
---|
227 | !insertmacro FILE_WRITE_LINE $9 " exit 1" |
---|
228 | !insertmacro FILE_WRITE_LINE $9 "fi" |
---|
229 | !insertmacro FILE_WRITE_LINE $9 "cd $$1" |
---|
230 | !insertmacro FILE_WRITE_LINE $9 "shift" |
---|
231 | !insertmacro FILE_WRITE_LINE $9 "make $$* 2>&1 | sed -e 's/c:\([0-9]*\):/c(\1):/' \\" |
---|
232 | !insertmacro FILE_WRITE_LINE $9 " -e 's/h:\([0-9]*\):/h(\1):/' \\" |
---|
233 | !insertmacro FILE_WRITE_LINE $9 " -e 's/S:\([0-9]*\):/S(\1):/' \\" |
---|
234 | !insertmacro FILE_WRITE_LINE $9 " -e 's/s:\([0-9]*\):/s(\1):/'" |
---|
235 | FileClose $9 |
---|
236 | SectionEnd |
---|
237 | |
---|
238 | Section -MSYSLinks |
---|
239 | Call MSYSDetectSilent |
---|
240 | Pop $R0 |
---|
241 | ifFileExists "$R0\etc\fstab" 0 Done |
---|
242 | Push $R0 |
---|
243 | Push $INSTDIR |
---|
244 | Push '\\' |
---|
245 | Pop $R0 |
---|
246 | Call StrSlash |
---|
247 | Pop $R1 |
---|
248 | Pop $R0 |
---|
249 | DetailPrint "Setting MSYS fstab: $R1 -> /opt/rtems-${PRODUCT_VERSION}" |
---|
250 | StrCpy $R1 "$R1 /opt/rtems-${PRODUCT_VERSION}$\n" |
---|
251 | FileOpen $9 "$R0\etc\fstab" a |
---|
252 | ifErrors 0 +3 |
---|
253 | MessageBox MB_OK "Cannot open $R0\etc\fstab. MSYS mount point no added." |
---|
254 | Goto Close |
---|
255 | FileSeek $9 0 SET |
---|
256 | ReadLoop: |
---|
257 | FileRead $9 $R2 |
---|
258 | ifErrors Append |
---|
259 | StrCmp $R1 $R2 Close ReadLoop |
---|
260 | Append: |
---|
261 | FileSeek $9 0 END |
---|
262 | FileWrite $9 $R1 |
---|
263 | Close: |
---|
264 | FileClose $9 |
---|
265 | Done: |
---|
266 | ClearErrors |
---|
267 | SectionEnd |
---|
268 | !endif |
---|
269 | |
---|
270 | Section -Post |
---|
271 | !ifdef COMMON_FILES |
---|
272 | WriteUninstaller "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-uninst.exe" |
---|
273 | !else |
---|
274 | WriteUninstaller "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-${RTEMS_TARGET}-uninst.exe" |
---|
275 | !endif |
---|
276 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ |
---|
277 | "DisplayName" "$(^Name)" |
---|
278 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ |
---|
279 | "UninstallString" "$INSTDIR\uninst.exe" |
---|
280 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ |
---|
281 | "DisplayVersion" "${PRODUCT_VERSION}" |
---|
282 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ |
---|
283 | "URLInfoAbout" "${PRODUCT_WEB_SITE}" |
---|
284 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \ |
---|
285 | "Publisher" "${PRODUCT_PUBLISHER}" |
---|
286 | SectionEnd |
---|
287 | |
---|
288 | Function un.onInit |
---|
289 | MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \ |
---|
290 | "Are you sure you want to uninstall RTEMS Tools (${RTEMS_TARGET})?" IDYES +2 |
---|
291 | Abort |
---|
292 | FunctionEnd |
---|
293 | |
---|
294 | Section Uninstall |
---|
295 | SetDetailsView show |
---|
296 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" |
---|
297 | DetailPrint "Delete the installed files" |
---|
298 | !insertmacro RTEMS_DELETE_FILES |
---|
299 | !ifdef COMMON_FILES |
---|
300 | FindFirst $0 $1 "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-*-uninst.exe" |
---|
301 | Uninstall_Targets: |
---|
302 | StrCmp $1 "" Uninstall_Targets_Done |
---|
303 | DetailPrint "Uninstalling $1" |
---|
304 | ExecWait '"$INSTDIR\$1" /S' |
---|
305 | Delete $1 |
---|
306 | BringToFront |
---|
307 | FindNext $0 $1 |
---|
308 | Goto Uninstall_Targets |
---|
309 | Uninstall_Targets_Done: |
---|
310 | FindClose $0 |
---|
311 | Delete "$INSTDIR\AUTHORS" |
---|
312 | Delete "$INSTDIR\COPYING" |
---|
313 | Delete "$INSTDIR\README" |
---|
314 | Delete "$INSTDIR\rtems.bat" |
---|
315 | Delete "$INSTDIR\rtems-cmd.bat" |
---|
316 | Delete "$INSTDIR\sh-run.bat" |
---|
317 | Delete "$INSTDIR\vs-make.sh" |
---|
318 | Delete "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-uninst.exe" |
---|
319 | !else |
---|
320 | Delete "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-${RTEMS_TARGET}-uninst.exe" |
---|
321 | Delete "$INSTDIR\Packages" |
---|
322 | !endif |
---|
323 | RMDir "$INSTDIR" |
---|
324 | DetailPrint "All done." |
---|
325 | SetAutoClose false |
---|
326 | SectionEnd |
---|