]>
Commit | Line | Data |
---|---|---|
1 | ; Installer script for win32 Viking | |
2 | ; Based on Win32 Pidgin installer by Herman Bloggs <hermanator12002@yahoo.com> | |
3 | ; and Daniel Atallah <daniel_atallah@yahoo.com> | |
4 | ; Heavily modified for Viking by Mathieu Albinet <mathieu_a@users.sourceforge.net> | |
5 | ||
6 | ;-------------------------------- | |
7 | ;Global Variables | |
8 | Var name | |
9 | ||
10 | ;-------------------------------- | |
11 | ;Configuration | |
12 | ;Needs to be 4 numbers: W.X.Y.Z | |
13 | !define VIKING_VERSION "1.5.0.0" | |
14 | ||
15 | ;The name var is set in .onInit | |
16 | Name $name | |
17 | ||
18 | OutFile "viking-${VIKING_VERSION}.exe" | |
19 | ||
20 | SetCompressor /SOLID lzma | |
21 | ShowInstDetails show | |
22 | ShowUninstDetails show | |
23 | SetDateSave on | |
24 | ||
25 | ; $name and $INSTDIR are set in .onInit function.. | |
26 | ||
27 | !include "MUI.nsh" | |
28 | !include "Sections.nsh" | |
29 | !include "WinVer.nsh" | |
30 | !include "LogicLib.nsh" | |
31 | ;; http://nsis.sourceforge.net/File_Association | |
32 | !include "FileAssociation.nsh" | |
33 | ||
34 | !include "FileFunc.nsh" | |
35 | !insertmacro GetParameters | |
36 | !insertmacro GetOptions | |
37 | !insertmacro GetParent | |
38 | ||
39 | !include "WordFunc.nsh" | |
40 | ||
41 | ;-------------------------------- | |
42 | ;Defines | |
43 | ||
44 | !define VIKING_NSIS_INCLUDE_PATH "." | |
45 | ||
46 | ; Remove these and the stuff that uses them at some point | |
47 | !define VIKING_REG_KEY "SOFTWARE\viking" | |
48 | !define VIKING_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\viking" | |
49 | ||
50 | !define HKLM_APP_PATHS_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\viking.exe" | |
51 | !define VIKING_UNINST_EXE "viking-uninst.exe" | |
52 | ||
53 | ;-------------------------------- | |
54 | ;Version resource | |
55 | VIProductVersion "${VIKING_VERSION}" | |
56 | VIAddVersionKey "ProductName" "Viking" | |
57 | VIAddVersionKey "FileVersion" "${VIKING_VERSION}" | |
58 | VIAddVersionKey "ProductVersion" "${VIKING_VERSION}" | |
59 | VIAddVersionKey "LegalCopyright" "" | |
60 | VIAddVersionKey "FileDescription" "Viking Installer" | |
61 | ||
62 | ;-------------------------------- | |
63 | ;Modern UI Configuration | |
64 | ||
65 | !define MUI_ICON ".\pixmaps\viking_icon.ico" | |
66 | !define MUI_UNICON ".\pixmaps\viking_icon.ico" | |
67 | ; !define MUI_WELCOMEFINISHPAGE_BITMAP ".\pixmaps\viking-intro.bmp" | |
68 | ; !define MUI_HEADERIMAGE | |
69 | ; !define MUI_HEADERIMAGE_BITMAP ".\pixmaps\viking-header.bmp" | |
70 | ||
71 | ; Alter License section | |
72 | !define MUI_LICENSEPAGE_BUTTON $(VIKING_LICENSE_BUTTON) | |
73 | !define MUI_LICENSEPAGE_TEXT_BOTTOM $(VIKING_LICENSE_BOTTOM_TEXT) | |
74 | ||
75 | !define MUI_LANGDLL_REGISTRY_ROOT "HKCU" | |
76 | !define MUI_LANGDLL_REGISTRY_KEY ${VIKING_REG_KEY} | |
77 | !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" | |
78 | ||
79 | !define MUI_COMPONENTSPAGE_SMALLDESC | |
80 | !define MUI_ABORTWARNING | |
81 | ||
82 | ;Finish Page config | |
83 | !define MUI_FINISHPAGE_NOAUTOCLOSE | |
84 | !define MUI_FINISHPAGE_RUN "$INSTDIR\viking.exe" | |
85 | !define MUI_FINISHPAGE_RUN_NOTCHECKED | |
86 | !define MUI_FINISHPAGE_LINK $(VIKING_FINISH_VISIT_WEB_SITE) | |
87 | !define MUI_FINISHPAGE_LINK_LOCATION "http://viking.sourceforge.net" | |
88 | ||
89 | ;-------------------------------- | |
90 | ;Pages | |
91 | ||
92 | !insertmacro MUI_PAGE_WELCOME | |
93 | !insertmacro MUI_PAGE_LICENSE ".\bin\COPYING_GPL.txt" | |
94 | !insertmacro MUI_PAGE_COMPONENTS | |
95 | ||
96 | ; Viking install dir page | |
97 | !insertmacro MUI_PAGE_DIRECTORY | |
98 | ||
99 | !insertmacro MUI_PAGE_INSTFILES | |
100 | !insertmacro MUI_PAGE_FINISH | |
101 | ||
102 | !insertmacro MUI_UNPAGE_WELCOME | |
103 | !insertmacro MUI_UNPAGE_CONFIRM | |
104 | !insertmacro MUI_UNPAGE_INSTFILES | |
105 | !insertmacro MUI_UNPAGE_FINISH | |
106 | ||
107 | ;-------------------------------- | |
108 | ;Languages | |
109 | ||
110 | ;; English goes first because its the default. The rest are | |
111 | ;; in alphabetical order (at least the strings actually displayed | |
112 | ;; will be). | |
113 | ||
114 | !insertmacro MUI_LANGUAGE "English" | |
115 | !insertmacro MUI_LANGUAGE "French" | |
116 | !insertmacro MUI_LANGUAGE "Spanish" | |
117 | ||
118 | ;-------------------------------- | |
119 | ;Translations | |
120 | ||
121 | !define VIKING_DEFAULT_LANGFILE "${VIKING_NSIS_INCLUDE_PATH}\translations\english.nsh" | |
122 | ||
123 | !include "${VIKING_NSIS_INCLUDE_PATH}\langmacros.nsh" | |
124 | ||
125 | !insertmacro VIKING_MACRO_INCLUDE_LANGFILE "ENGLISH" "${VIKING_NSIS_INCLUDE_PATH}\translations\english.nsh" | |
126 | !insertmacro VIKING_MACRO_INCLUDE_LANGFILE "FRENCH" "${VIKING_NSIS_INCLUDE_PATH}\translations\french.nsh" | |
127 | !insertmacro VIKING_MACRO_INCLUDE_LANGFILE "SPANISH" "${VIKING_NSIS_INCLUDE_PATH}\translations\spanish.nsh" | |
128 | ||
129 | ;-------------------------------- | |
130 | ;Reserve Files | |
131 | ; Only need this if using bzip2 compression | |
132 | ||
133 | !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS | |
134 | !insertmacro MUI_RESERVEFILE_LANGDLL | |
135 | ReserveFile "${NSISDIR}\Plugins\UserInfo.dll" | |
136 | ||
137 | ||
138 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
139 | ;; Start Install Sections ;; | |
140 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
141 | ||
142 | LicenseData ".\bin\COPYING_GPL.txt" | |
143 | LicenseForceSelection checkbox | |
144 | ||
145 | ;-------------------------------- | |
146 | ;Uninstall any old version of Viking | |
147 | ||
148 | Section -SecUninstallOldViking | |
149 | ; Check install rights.. | |
150 | Call CheckUserInstallRights | |
151 | Pop $R0 | |
152 | ||
153 | ;First try to uninstall Viking | |
154 | StrCpy $R4 ${VIKING_REG_KEY} | |
155 | StrCpy $R5 ${VIKING_UNINSTALL_KEY} | |
156 | StrCpy $R6 ${VIKING_UNINST_EXE} | |
157 | StrCpy $R7 "Viking" | |
158 | ||
159 | ;Determine user install rights | |
160 | StrCmp $R0 "HKLM" compare_hklm | |
161 | StrCmp $R0 "HKCU" compare_hkcu done | |
162 | ||
163 | compare_hkcu: | |
164 | ReadRegStr $R1 HKCU $R4 "" | |
165 | ReadRegStr $R2 HKCU $R4 "Version" | |
166 | ReadRegStr $R3 HKCU "$R5" "UninstallString" | |
167 | Goto try_uninstall | |
168 | ||
169 | compare_hklm: | |
170 | ReadRegStr $R1 HKLM $R4 "" | |
171 | ReadRegStr $R2 HKLM $R4 "Version" | |
172 | ReadRegStr $R3 HKLM "$R5" "UninstallString" | |
173 | ||
174 | ; If a previous version exists, remove it | |
175 | try_uninstall: | |
176 | StrCmp $R1 "" done | |
177 | StrCmp $R2 "" uninstall_problem | |
178 | ; Check if we have uninstall string.. | |
179 | IfFileExists $R3 0 uninstall_problem | |
180 | ; Have uninstall string, go ahead and uninstall. | |
181 | SetOverwrite on | |
182 | ; Need to copy uninstaller outside of the install dir | |
183 | ClearErrors | |
184 | CopyFiles /SILENT $R3 "$TEMP\$R6" | |
185 | SetOverwrite off | |
186 | IfErrors uninstall_problem | |
187 | ; Ready to uninstall.. | |
188 | ClearErrors | |
189 | ExecWait '"$TEMP\$R6" /S _?=$R1' | |
190 | IfErrors exec_error | |
191 | Delete "$TEMP\$R6" | |
192 | Goto done | |
193 | ||
194 | exec_error: | |
195 | Delete "$TEMP\$R6" | |
196 | Goto uninstall_problem | |
197 | ||
198 | uninstall_problem: | |
199 | ; We can't uninstall. Either the user must manually uninstall or we ignore and reinstall over it. | |
200 | MessageBox MB_OKCANCEL $(VIKING_PROMPT_CONTINUE_WITHOUT_UNINSTALL) /SD IDOK IDOK done | |
201 | Quit | |
202 | done: | |
203 | SectionEnd | |
204 | ||
205 | ||
206 | ;-------------------------------- | |
207 | ;Viking Install Section | |
208 | ||
209 | Section $(VIKING_SECTION_TITLE) SecViking | |
210 | SectionIn 1 RO | |
211 | ||
212 | ; Check install rights.. | |
213 | Call CheckUserInstallRights | |
214 | Pop $R0 | |
215 | StrCmp $R0 "NONE" viking_none | |
216 | StrCmp $R0 "HKLM" viking_hklm viking_hkcu | |
217 | ||
218 | ;Install rights for Local Machine | |
219 | viking_hklm: | |
220 | WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "" "$INSTDIR\viking.exe" | |
221 | WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "Path" "$R1\bin" | |
222 | ; Sets scope of the desktop and Start Menu entries for all users. | |
223 | SetShellVarContext "all" | |
224 | Goto viking_install_files | |
225 | ||
226 | ;Install rights for Current User only | |
227 | viking_hkcu: | |
228 | Goto viking_install_files | |
229 | ||
230 | ;No install rights! | |
231 | viking_none: | |
232 | ||
233 | viking_install_files: | |
234 | SetOutPath "$INSTDIR" | |
235 | SetOverwrite on | |
236 | ||
237 | ; Common settings | |
238 | WriteRegStr SHCTX ${VIKING_REG_KEY} "" "$INSTDIR" | |
239 | WriteRegStr SHCTX ${VIKING_REG_KEY} "Version" "${VIKING_VERSION}" | |
240 | WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "DisplayName" "Viking" | |
241 | WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "DisplayVersion" "${VIKING_VERSION}" | |
242 | WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\viking_icon.ico" | |
243 | WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "HelpLink" "http://sourceforge.net/p/viking/wikiallura" | |
244 | WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "URLInfoAbout" "http://sourceforge.net/projects/viking/" | |
245 | WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "Publisher" "The Viking developer community" | |
246 | WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "Comments" "$(VIKING_UNINSTALL_COMMENTS)" | |
247 | WriteRegDWORD SHCTX "${VIKING_UNINSTALL_KEY}" "NoModify" 1 | |
248 | WriteRegDWORD SHCTX "${VIKING_UNINSTALL_KEY}" "NoRepair" 1 | |
249 | WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${VIKING_UNINST_EXE}" | |
250 | ||
251 | ; Copy only specific items as now some components (e.g. GPSBabel) are optional. | |
252 | ; This is mostly to get a more accurate install size value (especially as saved into the registry) | |
253 | File .\bin\viking* | |
254 | ; Not sure we really need any of the gtk executables but copy them anyway: | |
255 | File .\bin\*.exe | |
256 | File .\bin\*.dll | |
257 | File .\bin\*.txt | |
258 | File .\bin\magic.mgc | |
259 | File /r .\bin\data | |
260 | File /r .\bin\etc | |
261 | File /r .\bin\gtk2-runtime | |
262 | File /r .\bin\lib | |
263 | File /r .\bin\locale | |
264 | File /r .\bin\share | |
265 | ||
266 | ; Estimate install size based on files in $INSTDIR | |
267 | ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 | |
268 | IntFmt $0 "0x%08X" $0 | |
269 | WriteRegDWORD SHCTX "${VIKING_UNINSTALL_KEY}" "EstimatedSize" "$0" | |
270 | ||
271 | ; If we don't have install rights we're done | |
272 | StrCmp $R0 "NONE" done | |
273 | SetOverwrite off | |
274 | ||
275 | ; write out uninstaller | |
276 | SetOverwrite on | |
277 | WriteUninstaller "$INSTDIR\${VIKING_UNINST_EXE}" | |
278 | SetOverwrite off | |
279 | ||
280 | ; Always associate Viking file type | |
281 | ${registerExtension} "$INSTDIR\viking.exe" ".vik" "Viking File" | |
282 | done: | |
283 | SectionEnd ; end of default Viking section | |
284 | ||
285 | ;-------------------------------- | |
286 | ;Shortcuts | |
287 | ||
288 | SectionGroup /e $(VIKING_SHORTCUTS_SECTION_TITLE) SecShortcuts | |
289 | ;Desktop shortcuts | |
290 | Section /o $(VIKING_DESKTOP_SHORTCUT_SECTION_TITLE) SecDesktopShortcut | |
291 | SetOverwrite on | |
292 | CreateShortCut "$DESKTOP\Viking.lnk" "$INSTDIR\viking.exe" | |
293 | SetOverwrite off | |
294 | SectionEnd | |
295 | ;Start menu shortcuts | |
296 | Section $(VIKING_STARTMENU_SHORTCUT_SECTION_TITLE) SecStartMenuShortcut | |
297 | SetOverwrite on | |
298 | CreateDirectory "$SMPROGRAMS\Viking" | |
299 | CreateShortCut "$SMPROGRAMS\Viking\Viking.lnk" "$INSTDIR\viking.exe" | |
300 | CreateShortCut "$SMPROGRAMS\Viking\User Manual.lnk" "$INSTDIR\viking.pdf" | |
301 | CreateShortCut "$SMPROGRAMS\Viking\Uninstall.lnk" "$INSTDIR\viking-uninst.exe" | |
302 | SetOverwrite off | |
303 | SectionEnd | |
304 | SectionGroupEnd | |
305 | ||
306 | ;-------------------------------- | |
307 | ;File association | |
308 | ||
309 | Section $(VIKING_FILE_ASSOCIATION_SECTION_TITLE) SecFileAssociation | |
310 | ${registerExtension} "$INSTDIR\viking.exe" ".gpx" "GPX File" | |
311 | SectionEnd | |
312 | ||
313 | ;-------------------------------- | |
314 | ; GPSBabel Install Section | |
315 | ; | |
316 | Section $(VIKING_GPSBABEL_SECTION_TITLE) SecGPSBabel | |
317 | File "bin\Optional\GPSBabel-1.5.1-Setup.exe" | |
318 | ExecWait '"$INSTDIR\GPSBabel-1.5.1-Setup.exe" /SILENT' | |
319 | Delete "$INSTDIR\GPSBabel-1.5.1-Setup.exe" | |
320 | SectionEnd | |
321 | ||
322 | ;-------------------------------- | |
323 | ;Uninstaller Section | |
324 | ||
325 | ||
326 | Section Uninstall | |
327 | Call un.CheckUserInstallRights | |
328 | Pop $R0 | |
329 | StrCmp $R0 "NONE" no_rights | |
330 | StrCmp $R0 "HKCU" try_hkcu try_hklm | |
331 | ||
332 | try_hkcu: | |
333 | ReadRegStr $R0 HKCU ${VIKING_REG_KEY} "" | |
334 | StrCmp $R0 $INSTDIR 0 cant_uninstall | |
335 | ; HKCU install path matches our INSTDIR so uninstall | |
336 | DeleteRegKey HKCU ${VIKING_REG_KEY} | |
337 | DeleteRegKey HKCU "${VIKING_UNINSTALL_KEY}" | |
338 | Goto cont_uninstall | |
339 | ||
340 | try_hklm: | |
341 | ReadRegStr $R0 HKLM ${VIKING_REG_KEY} "" | |
342 | StrCmp $R0 $INSTDIR 0 try_hkcu | |
343 | ; HKLM install path matches our INSTDIR so uninstall | |
344 | DeleteRegKey HKLM ${VIKING_REG_KEY} | |
345 | DeleteRegKey HKLM "${VIKING_UNINSTALL_KEY}" | |
346 | DeleteRegKey HKLM "${HKLM_APP_PATHS_KEY}" | |
347 | ; Sets start menu and desktop scope to all users.. | |
348 | SetShellVarContext "all" | |
349 | ||
350 | cont_uninstall: | |
351 | ||
352 | ; http://nsis.sourceforge.net/Docs/Chapter4.html | |
353 | ; Don't use: | |
354 | ;RMDir /r "$INSTDIR" | |
355 | ; Warning: is not safe. Can delete entire Program Files directory! | |
356 | ||
357 | ; TODO try this method instead: | |
358 | ; http://nsis.sourceforge.net/Uninstall_only_installed_files | |
359 | ||
360 | ; Specific remove files | |
361 | ; Thus alsos leaves any files the user has saved (particularly .vik or .gpx) into the Viking directory | |
362 | Delete "$INSTDIR\viking-cache.py" | |
363 | Delete "$INSTDIR\viking.pdf" | |
364 | Delete "$INSTDIR\viking_icon.ico" | |
365 | Delete "$INSTDIR\*.exe" | |
366 | Delete "$INSTDIR\*.dll" | |
367 | Delete "$INSTDIR\*.txt" | |
368 | Delete "$INSTDIR\magic.mgc" | |
369 | Delete "$INSTDIR\data\*txt" | |
370 | Delete "$INSTDIR\data\*xml" | |
371 | RMDir "$INSTDIR\data" | |
372 | RMDir /r "$INSTDIR\etc" | |
373 | RMDir /r "$INSTDIR\gtk2-runtime" | |
374 | RMDir /r "$INSTDIR\lib" | |
375 | RMDir /r "$INSTDIR\locale" | |
376 | RMDir /r "$INSTDIR\share" | |
377 | RMDir "$INSTDIR" | |
378 | ||
379 | ; Shortcuts.. | |
380 | Delete "$DESKTOP\Viking.lnk" | |
381 | ||
382 | ; File association | |
383 | ${unregisterExtension} ".vik" "Viking File" | |
384 | ${unregisterExtension} ".gpx" "GPX File" | |
385 | ||
386 | Goto done | |
387 | ||
388 | cant_uninstall: | |
389 | MessageBox MB_OK $(un.VIKING_UNINSTALL_ERROR_1) /SD IDOK | |
390 | Quit | |
391 | ||
392 | no_rights: | |
393 | MessageBox MB_OK $(un.VIKING_UNINSTALL_ERROR_2) /SD IDOK | |
394 | Quit | |
395 | ||
396 | done: | |
397 | SectionEnd ; end of uninstall section | |
398 | ||
399 | ;-------------------------------- | |
400 | ;Descriptions | |
401 | !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN | |
402 | ||
403 | !insertmacro MUI_DESCRIPTION_TEXT ${SecViking} \ | |
404 | $(VIKING_SECTION_DESCRIPTION) | |
405 | !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} \ | |
406 | $(VIKING_SHORTCUTS_SECTION_DESCRIPTION) | |
407 | !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopShortcut} \ | |
408 | $(VIKING_DESKTOP_SHORTCUT_DESC) | |
409 | !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenuShortcut} \ | |
410 | $(VIKING_STARTMENU_SHORTCUT_DESC) | |
411 | !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssociation} \ | |
412 | $(VIKING_FILE_ASSOCIATION_DESC) | |
413 | !insertmacro MUI_DESCRIPTION_TEXT ${SecGPSBabel} \ | |
414 | $(VIKING_INSTALL_GPSBABEL_DESC) | |
415 | ||
416 | !insertmacro MUI_FUNCTION_DESCRIPTION_END | |
417 | ||
418 | ;-------------------------------- | |
419 | ;Functions | |
420 | ||
421 | ;Macro to determine user install rights | |
422 | ;Will be used to determine where to install the program, shortcuts, ... | |
423 | !macro CheckUserInstallRightsMacro UN | |
424 | Function ${UN}CheckUserInstallRights | |
425 | Push $0 | |
426 | Push $1 | |
427 | ClearErrors | |
428 | UserInfo::GetName | |
429 | IfErrors Win9x | |
430 | Pop $0 | |
431 | UserInfo::GetAccountType | |
432 | Pop $1 | |
433 | ||
434 | StrCmp $1 "Admin" 0 +3 | |
435 | StrCpy $1 "HKLM" | |
436 | Goto done | |
437 | StrCmp $1 "Power" 0 +3 | |
438 | StrCpy $1 "HKLM" | |
439 | Goto done | |
440 | StrCmp $1 "User" 0 +3 | |
441 | StrCpy $1 "HKCU" | |
442 | Goto done | |
443 | StrCmp $1 "Guest" 0 +3 | |
444 | StrCpy $1 "NONE" | |
445 | Goto done | |
446 | ; Unknown error | |
447 | StrCpy $1 "NONE" | |
448 | Goto done | |
449 | ||
450 | Win9x: | |
451 | StrCpy $1 "HKLM" | |
452 | ||
453 | done: | |
454 | Exch $1 | |
455 | Exch | |
456 | Pop $0 | |
457 | FunctionEnd | |
458 | !macroend | |
459 | !insertmacro CheckUserInstallRightsMacro "" | |
460 | !insertmacro CheckUserInstallRightsMacro "un." | |
461 | ||
462 | ;Macro to determine if Viking is running before installation/unistallation | |
463 | !macro RunCheckMacro UN | |
464 | Function ${UN}RunCheck | |
465 | FindProcDLL::FindProc "viking.exe" | |
466 | IntCmp $R0 1 0 notRunning | |
467 | MessageBox MB_OK|MB_ICONEXCLAMATION $(VIKING_IS_RUNNING) /SD IDOK | |
468 | Abort | |
469 | notRunning: | |
470 | FunctionEnd | |
471 | !macroend | |
472 | ||
473 | !insertmacro RunCheckMacro "" | |
474 | !insertmacro RunCheckMacro "un." | |
475 | ||
476 | ;Installer extra configuration at execution time: language, path, ... | |
477 | Function .onInit | |
478 | ;Check if viking installer is already running | |
479 | Push $R0 | |
480 | Push $R1 | |
481 | Push $R2 | |
482 | ||
483 | ;Check if viking is running | |
484 | Call RunCheck | |
485 | StrCpy $name "Viking ${VIKING_VERSION}" | |
486 | ||
487 | ClearErrors | |
488 | ;Make sure that there was a previous installation | |
489 | ReadRegStr $R0 HKCU "${VIKING_REG_KEY}" "Installer Language" | |
490 | ||
491 | ;Preselect the "shortcuts" checkboxes according to the previous installation | |
492 | !insertmacro SelectSection ${SecDesktopShortcut} | |
493 | !insertmacro selectSection ${SecStartMenuShortcut} | |
494 | ||
495 | ;Read command line parameters | |
496 | ||
497 | ;Read language command line parameters | |
498 | ${GetParameters} $R0 | |
499 | ClearErrors | |
500 | ${GetOptions} "$R0" "/L=" $R1 | |
501 | IfErrors +3 | |
502 | StrCpy $LANGUAGE $R1 | |
503 | Goto skip_lang | |
504 | ||
505 | ; Select Language | |
506 | ; Display Language selection dialog | |
507 | !insertmacro MUI_LANGDLL_DISPLAY | |
508 | skip_lang: | |
509 | ||
510 | ;Read desktop shortcut command line options | |
511 | ClearErrors | |
512 | ${GetOptions} "$R0" "/DS=" $R1 | |
513 | IfErrors +8 | |
514 | SectionGetFlags ${SecDesktopShortcut} $R2 | |
515 | StrCmp "1" $R1 0 +2 | |
516 | IntOp $R2 $R2 | ${SF_SELECTED} | |
517 | StrCmp "0" $R1 0 +3 | |
518 | IntOp $R1 ${SF_SELECTED} ~ | |
519 | IntOp $R2 $R2 & $R1 | |
520 | SectionSetFlags ${SecDesktopShortcut} $R2 | |
521 | ||
522 | ;Read start menu shortcuts command line options | |
523 | ClearErrors | |
524 | ${GetOptions} "$R0" "/SMS=" $R1 | |
525 | IfErrors +8 | |
526 | SectionGetFlags ${SecStartMenuShortcut} $R2 | |
527 | StrCmp "1" $R1 0 +2 | |
528 | IntOp $R2 $R2 | ${SF_SELECTED} | |
529 | StrCmp "0" $R1 0 +3 | |
530 | IntOp $R1 ${SF_SELECTED} ~ | |
531 | IntOp $R2 $R2 & $R1 | |
532 | SectionSetFlags ${SecStartMenuShortcut} $R2 | |
533 | ||
534 | ; If install path was set on the command, use it. | |
535 | StrCmp $INSTDIR "" 0 instdir_done | |
536 | ||
537 | ; If viking is currently installed, we should default to where it is currently installed | |
538 | ClearErrors | |
539 | ReadRegStr $INSTDIR HKCU "${VIKING_REG_KEY}" "" | |
540 | IfErrors +2 | |
541 | StrCmp $INSTDIR "" 0 instdir_done | |
542 | ClearErrors | |
543 | ReadRegStr $INSTDIR HKLM "${VIKING_REG_KEY}" "" | |
544 | IfErrors +2 | |
545 | StrCmp $INSTDIR "" 0 instdir_done | |
546 | ||
547 | Call CheckUserInstallRights | |
548 | Pop $R0 | |
549 | ||
550 | StrCmp $R0 "HKLM" 0 user_dir | |
551 | StrCpy $INSTDIR "$PROGRAMFILES\Viking" | |
552 | Goto instdir_done | |
553 | user_dir: | |
554 | Push $SMPROGRAMS | |
555 | ${GetParent} $SMPROGRAMS $R2 | |
556 | ${GetParent} $R2 $R2 | |
557 | StrCpy $INSTDIR "$R2\Viking" | |
558 | ||
559 | instdir_done: | |
560 | ;LogSet on | |
561 | Pop $R2 | |
562 | Pop $R1 | |
563 | Pop $R0 | |
564 | FunctionEnd | |
565 | ||
566 | Function un.onInit | |
567 | ;Check if viking is running | |
568 | Call un.RunCheck | |
569 | StrCpy $name "Viking ${VIKING_VERSION}" | |
570 | ||
571 | ; Get stored language preference | |
572 | !insertmacro MUI_UNGETLANGUAGE | |
573 | ||
574 | FunctionEnd |