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