Debian Codegraph @

cmake/ModulesOverride/NSIS.template.in

raw
1 ; CPack install script designed for a nmake build
2
3 ;--------------------------------
4 ; You must define these values
5
6 !define VERSION "@CPACK_PACKAGE_VERSION@"
7 !define PATCH "@CPACK_PACKAGE_VERSION_PATCH@"
8 !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
9
10 ;--------------------------------
11 ;Variables
12
13 Var MUI_TEMP
14 Var STARTMENU_FOLDER
15 Var SV_ALLUSERS
16 Var START_MENU
17 Var DO_NOT_ADD_TO_PATH
18 Var ADD_TO_PATH_ALL_USERS
19 Var ADD_TO_PATH_CURRENT_USER
20 Var INSTALL_DESKTOP
21 Var IS_DEFAULT_INSTALLDIR
22 ;--------------------------------
23 ;Include Modern UI
24
25 !include "MUI.nsh"
26
27 ;Default installation folder
28 InstallDir "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
29
30 ;--------------------------------
31 ;General
32
33 ;Name and file
34 Name "@CPACK_NSIS_PACKAGE_NAME@"
35 OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
36
37 ;Set compression
38 SetCompressor @CPACK_NSIS_COMPRESSOR@
39
40 ;Require administrator access
41 RequestExecutionLevel admin
42
43 @CPACK_NSIS_DEFINES@
44 @CPACK_NSIS_MANIFEST_DPI_AWARE_CODE@
45 @CPACK_NSIS_BRANDING_TEXT_CODE@
46
47 !include Sections.nsh
48
49 ;--- Component support macros: ---
50 ; The code for the add/remove functionality is from:
51 ; http://nsis.sourceforge.net/Add/Remove_Functionality
52 ; It has been modified slightly and extended to provide
53 ; inter-component dependencies.
54 Var AR_SecFlags
55 Var AR_RegFlags
56 @CPACK_NSIS_SECTION_SELECTED_VARS@
57
58 ; Loads the "selected" flag for the section named SecName into the
59 ; variable VarName.
60 !macro LoadSectionSelectedIntoVar SecName VarName
61 SectionGetFlags ${${SecName}} $${VarName}
62 IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits
63 !macroend
64
65 ; Loads the value of a variable... can we get around this?
66 !macro LoadVar VarName
67 IntOp $R0 0 + $${VarName}
68 !macroend
69
70 ; Sets the value of a variable
71 !macro StoreVar VarName IntValue
72 IntOp $${VarName} 0 + ${IntValue}
73 !macroend
74
75 !macro InitSection SecName
76 ; This macro reads component installed flag from the registry and
77 ;changes checked state of the section on the components page.
78 ;Input: section index constant name specified in Section command.
79
80 ClearErrors
81 ;Reading component status from registry
82 SetRegView @CPACK_NSIS_REGISTRY_VIEW@
83 ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed"
84 IfErrors "default_${SecName}"
85 ;Status will stay default if registry value not found
86 ;(component was never installed)
87 IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits
88 SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags
89 IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off
90 IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit
91
92 ; Note whether this component was installed before
93 !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags
94 IntOp $R0 $AR_RegFlags & $AR_RegFlags
95
96 ;Writing modified flags
97 SectionSetFlags ${${SecName}} $AR_SecFlags
98
99 "default_${SecName}:"
100 !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
101 !macroend
102
103 !macro FinishSection SecName
104 ; This macro reads section flag set by user and removes the section
105 ;if it is not selected.
106 ;Then it writes component installed flag to registry
107 ;Input: section index constant name specified in Section command.
108
109 SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags
110 ;Checking lowest bit:
111 IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED}
112 IntCmp $AR_SecFlags 1 "leave_${SecName}"
113 ;Section is not selected:
114 ;Calling Section uninstall macro and writing zero installed flag
115 !insertmacro "Remove_${${SecName}}"
116 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
117 "Installed" 0
118 Goto "exit_${SecName}"
119
120 "leave_${SecName}:"
121 ;Section is selected:
122 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
123 "Installed" 1
124
125 "exit_${SecName}:"
126 !macroend
127
128 !macro RemoveSection_CPack SecName
129 ; This macro is used to call section's Remove_... macro
130 ;from the uninstaller.
131 ;Input: section index constant name specified in Section command.
132
133 !insertmacro "Remove_${${SecName}}"
134 !macroend
135
136 ; Determine whether the selection of SecName changed
137 !macro MaybeSelectionChanged SecName
138 !insertmacro LoadVar ${SecName}_selected
139 SectionGetFlags ${${SecName}} $R1
140 IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits
141
142 ; See if the status has changed:
143 IntCmp $R0 $R1 "${SecName}_unchanged"
144 !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
145
146 IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected"
147 !insertmacro "Deselect_required_by_${SecName}"
148 goto "${SecName}_unchanged"
149
150 "${SecName}_was_selected:"
151 !insertmacro "Select_${SecName}_depends"
152
153 "${SecName}_unchanged:"
154 !macroend
155 ;--- End of Add/Remove macros ---
156
157 ;--------------------------------
158 ;Interface Settings
159
160 !define MUI_HEADERIMAGE
161 !define MUI_ABORTWARNING
162
163 ;----------------------------------------
164 ; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
165 ;----------------------------------------
166 !verbose 3
167 !include "WinMessages.NSH"
168 !verbose 4
169 ;====================================================
170 ; get_NT_environment
171 ; Returns: the selected environment
172 ; Output : head of the stack
173 ;====================================================
174 !macro select_NT_profile UN
175 Function ${UN}select_NT_profile
176 StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single
177 DetailPrint "Selected environment for all users"
178 Push "all"
179 Return
180 environment_single:
181 DetailPrint "Selected environment for current user only."
182 Push "current"
183 Return
184 FunctionEnd
185 !macroend
186 !insertmacro select_NT_profile ""
187 !insertmacro select_NT_profile "un."
188 ;----------------------------------------------------
189 !define NT_current_env 'HKCU "Environment"'
190 !define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
191
192 !ifndef WriteEnvStr_RegKey
193 !ifdef ALL_USERS
194 !define WriteEnvStr_RegKey \
195 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
196 !else
197 !define WriteEnvStr_RegKey 'HKCU "Environment"'
198 !endif
199 !endif
200
201 ; AddToPath - Adds the given dir to the search path.
202 ; Input - head of the stack
203 ; Note - Win9x systems requires reboot
204
205 Function AddToPath
206 Exch $0
207 Push $1
208 Push $2
209 Push $3
210
211 # don't add if the path doesn't exist
212 IfFileExists "$0\*.*" "" AddToPath_done
213
214 ReadEnvStr $1 PATH
215 ; if the path is too long for a NSIS variable NSIS will return a 0
216 ; length string. If we find that, then warn and skip any path
217 ; modification as it will trash the existing path.
218 StrLen $2 $1
219 IntCmp $2 0 CheckPathLength_ShowPathWarning CheckPathLength_Done CheckPathLength_Done
220 CheckPathLength_ShowPathWarning:
221 Messagebox MB_OK|MB_ICONEXCLAMATION "Warning! PATH too long installer unable to modify PATH!"
222 Goto AddToPath_done
223 CheckPathLength_Done:
224 Push "$1;"
225 Push "$0;"
226 Call StrStr
227 Pop $2
228 StrCmp $2 "" "" AddToPath_done
229 Push "$1;"
230 Push "$0\;"
231 Call StrStr
232 Pop $2
233 StrCmp $2 "" "" AddToPath_done
234 GetFullPathName /SHORT $3 $0
235 Push "$1;"
236 Push "$3;"
237 Call StrStr
238 Pop $2
239 StrCmp $2 "" "" AddToPath_done
240 Push "$1;"
241 Push "$3\;"
242 Call StrStr
243 Pop $2
244 StrCmp $2 "" "" AddToPath_done
245
246 Call IsNT
247 Pop $1
248 StrCmp $1 1 AddToPath_NT
249 ; Not on NT
250 StrCpy $1 $WINDIR 2
251 FileOpen $1 "$1\autoexec.bat" a
252 FileSeek $1 -1 END
253 FileReadByte $1 $2
254 IntCmp $2 26 0 +2 +2 # DOS EOF
255 FileSeek $1 -1 END # write over EOF
256 FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
257 FileClose $1
258 SetRebootFlag true
259 Goto AddToPath_done
260
261 AddToPath_NT:
262 StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey
263 ReadRegStr $1 ${NT_current_env} "PATH"
264 Goto DoTrim
265 ReadAllKey:
266 ReadRegStr $1 ${NT_all_env} "PATH"
267 DoTrim:
268 StrCmp $1 "" AddToPath_NTdoIt
269 Push $1
270 Call Trim
271 Pop $1
272 StrCpy $0 "$1;$0"
273 AddToPath_NTdoIt:
274 StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey
275 WriteRegExpandStr ${NT_current_env} "PATH" $0
276 Goto DoSend
277 WriteAllKey:
278 WriteRegExpandStr ${NT_all_env} "PATH" $0
279 DoSend:
280 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
281
282 AddToPath_done:
283 Pop $3
284 Pop $2
285 Pop $1
286 Pop $0
287 FunctionEnd
288
289
290 ; RemoveFromPath - Remove a given dir from the path
291 ; Input: head of the stack
292
293 Function un.RemoveFromPath
294 Exch $0
295 Push $1
296 Push $2
297 Push $3
298 Push $4
299 Push $5
300 Push $6
301
302 IntFmt $6 "%c" 26 # DOS EOF
303
304 Call un.IsNT
305 Pop $1
306 StrCmp $1 1 unRemoveFromPath_NT
307 ; Not on NT
308 StrCpy $1 $WINDIR 2
309 FileOpen $1 "$1\autoexec.bat" r
310 GetTempFileName $4
311 FileOpen $2 $4 w
312 GetFullPathName /SHORT $0 $0
313 StrCpy $0 "SET PATH=%PATH%;$0"
314 Goto unRemoveFromPath_dosLoop
315
316 unRemoveFromPath_dosLoop:
317 FileRead $1 $3
318 StrCpy $5 $3 1 -1 # read last char
319 StrCmp $5 $6 0 +2 # if DOS EOF
320 StrCpy $3 $3 -1 # remove DOS EOF so we can compare
321 StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
322 StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
323 StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
324 StrCmp $3 "" unRemoveFromPath_dosLoopEnd
325 FileWrite $2 $3
326 Goto unRemoveFromPath_dosLoop
327 unRemoveFromPath_dosLoopRemoveLine:
328 SetRebootFlag true
329 Goto unRemoveFromPath_dosLoop
330
331 unRemoveFromPath_dosLoopEnd:
332 FileClose $2
333 FileClose $1
334 StrCpy $1 $WINDIR 2
335 Delete "$1\autoexec.bat"
336 CopyFiles /SILENT $4 "$1\autoexec.bat"
337 Delete $4
338 Goto unRemoveFromPath_done
339
340 unRemoveFromPath_NT:
341 StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey
342 ReadRegStr $1 ${NT_current_env} "PATH"
343 Goto unDoTrim
344 unReadAllKey:
345 ReadRegStr $1 ${NT_all_env} "PATH"
346 unDoTrim:
347 StrCpy $5 $1 1 -1 # copy last char
348 StrCmp $5 ";" +2 # if last char != ;
349 StrCpy $1 "$1;" # append ;
350 Push $1
351 Push "$0;"
352 Call un.StrStr ; Find `$0;` in $1
353 Pop $2 ; pos of our dir
354 StrCmp $2 "" unRemoveFromPath_done
355 ; else, it is in path
356 # $0 - path to add
357 # $1 - path var
358 StrLen $3 "$0;"
359 StrLen $4 $2
360 StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
361 StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
362 StrCpy $3 $5$6
363
364 StrCpy $5 $3 1 -1 # copy last char
365 StrCmp $5 ";" 0 +2 # if last char == ;
366 StrCpy $3 $3 -1 # remove last char
367
368 StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey
369 WriteRegExpandStr ${NT_current_env} "PATH" $3
370 Goto unDoSend
371 unWriteAllKey:
372 WriteRegExpandStr ${NT_all_env} "PATH" $3
373 unDoSend:
374 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
375
376 unRemoveFromPath_done:
377 Pop $6
378 Pop $5
379 Pop $4
380 Pop $3
381 Pop $2
382 Pop $1
383 Pop $0
384 FunctionEnd
385
386 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
387 ; Uninstall sutff
388 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
389
390 ###########################################
391 # Utility Functions #
392 ###########################################
393
394 ;====================================================
395 ; IsNT - Returns 1 if the current system is NT, 0
396 ; otherwise.
397 ; Output: head of the stack
398 ;====================================================
399 ; IsNT
400 ; no input
401 ; output, top of the stack = 1 if NT or 0 if not
402 ;
403 ; Usage:
404 ; Call IsNT
405 ; Pop $R0
406 ; ($R0 at this point is 1 or 0)
407
408 !macro IsNT un
409 Function ${un}IsNT
410 Push $0
411 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
412 StrCmp $0 "" 0 IsNT_yes
413 ; we are not NT.
414 Pop $0
415 Push 0
416 Return
417
418 IsNT_yes:
419 ; NT!!!
420 Pop $0
421 Push 1
422 FunctionEnd
423 !macroend
424 !insertmacro IsNT ""
425 !insertmacro IsNT "un."
426
427 ; StrStr
428 ; input, top of stack = string to search for
429 ; top of stack-1 = string to search in
430 ; output, top of stack (replaces with the portion of the string remaining)
431 ; modifies no other variables.
432 ;
433 ; Usage:
434 ; Push "this is a long ass string"
435 ; Push "ass"
436 ; Call StrStr
437 ; Pop $R0
438 ; ($R0 at this point is "ass string")
439
440 !macro StrStr un
441 Function ${un}StrStr
442 Exch $R1 ; st=haystack,old$R1, $R1=needle
443 Exch ; st=old$R1,haystack
444 Exch $R2 ; st=old$R1,old$R2, $R2=haystack
445 Push $R3
446 Push $R4
447 Push $R5
448 StrLen $R3 $R1
449 StrCpy $R4 0
450 ; $R1=needle
451 ; $R2=haystack
452 ; $R3=len(needle)
453 ; $R4=cnt
454 ; $R5=tmp
455 loop:
456 StrCpy $R5 $R2 $R3 $R4
457 StrCmp $R5 $R1 done
458 StrCmp $R5 "" done
459 IntOp $R4 $R4 + 1
460 Goto loop
461 done:
462 StrCpy $R1 $R2 "" $R4
463 Pop $R5
464 Pop $R4
465 Pop $R3
466 Pop $R2
467 Exch $R1
468 FunctionEnd
469 !macroend
470 !insertmacro StrStr ""
471 !insertmacro StrStr "un."
472
473 Function Trim ; Added by Pelaca
474 Exch $R1
475 Push $R2
476 Loop:
477 StrCpy $R2 "$R1" 1 -1
478 StrCmp "$R2" " " RTrim
479 StrCmp "$R2" "$\n" RTrim
480 StrCmp "$R2" "$\r" RTrim
481 StrCmp "$R2" ";" RTrim
482 GoTo Done
483 RTrim:
484 StrCpy $R1 "$R1" -1
485 Goto Loop
486 Done:
487 Pop $R2
488 Exch $R1
489 FunctionEnd
490
491 Function ConditionalAddToRegisty
492 Pop $0
493 Pop $1
494 SetRegView @CPACK_NSIS_REGISTRY_VIEW@
495 StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
496 WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" \
497 "$1" "$0"
498 ;MessageBox MB_OK "Set Registry: '$1' to '$0'"
499 DetailPrint "Set install registry entry: '$1' to '$0'"
500 ConditionalAddToRegisty_EmptyString:
501 FunctionEnd
502
503 ;--------------------------------
504
505 !ifdef CPACK_USES_DOWNLOAD
506 Function DownloadFile
507 IfFileExists $INSTDIR\* +2
508 CreateDirectory $INSTDIR
509 Pop $0
510
511 ; Skip if already downloaded
512 IfFileExists $INSTDIR\$0 0 +2
513 Return
514
515 StrCpy $1 "@CPACK_DOWNLOAD_SITE@"
516
517 try_again:
518 NSISdl::download "$1/$0" "$INSTDIR\$0"
519
520 Pop $1
521 StrCmp $1 "success" success
522 StrCmp $1 "Cancelled" cancel
523 MessageBox MB_OK "Download failed: $1"
524 cancel:
525 Return
526 success:
527 FunctionEnd
528 !endif
529
530 ;--------------------------------
531 ; Define some macro setting for the gui
532 @CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
533 @CPACK_NSIS_INSTALLER_ICON_CODE@
534 @CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE@
535 @CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE@
536 @CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
537 @CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@
538
539 ;--------------------------------
540 ;Pages
541 @CPACK_NSIS_INSTALLER_WELCOME_TITLE_CODE@
542 @CPACK_NSIS_INSTALLER_WELCOME_TITLE_3LINES_CODE@
543 !insertmacro MUI_PAGE_WELCOME
544
545 !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
546 Page custom InstallOptionsPage
547 !insertmacro MUI_PAGE_DIRECTORY
548
549 ;Start Menu Folder Page Configuration
550 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
551 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
552 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
553 !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
554
555 @CPACK_NSIS_PAGE_COMPONENTS@
556
557 !insertmacro MUI_PAGE_INSTFILES
558 @CPACK_NSIS_INSTALLER_FINISH_TITLE_CODE@
559 @CPACK_NSIS_INSTALLER_FINISH_TITLE_3LINES_CODE@
560 !insertmacro MUI_PAGE_FINISH
561
562 !insertmacro MUI_UNPAGE_CONFIRM
563 !insertmacro MUI_UNPAGE_INSTFILES
564
565 ;--------------------------------
566 ;Languages
567
568 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
569 !insertmacro MUI_LANGUAGE "Albanian"
570 !insertmacro MUI_LANGUAGE "Arabic"
571 !insertmacro MUI_LANGUAGE "Basque"
572 !insertmacro MUI_LANGUAGE "Belarusian"
573 !insertmacro MUI_LANGUAGE "Bosnian"
574 !insertmacro MUI_LANGUAGE "Breton"
575 !insertmacro MUI_LANGUAGE "Bulgarian"
576 !insertmacro MUI_LANGUAGE "Croatian"
577 !insertmacro MUI_LANGUAGE "Czech"
578 !insertmacro MUI_LANGUAGE "Danish"
579 !insertmacro MUI_LANGUAGE "Dutch"
580 !insertmacro MUI_LANGUAGE "Estonian"
581 !insertmacro MUI_LANGUAGE "Farsi"
582 !insertmacro MUI_LANGUAGE "Finnish"
583 !insertmacro MUI_LANGUAGE "French"
584 !insertmacro MUI_LANGUAGE "German"
585 !insertmacro MUI_LANGUAGE "Greek"
586 !insertmacro MUI_LANGUAGE "Hebrew"
587 !insertmacro MUI_LANGUAGE "Hungarian"
588 !insertmacro MUI_LANGUAGE "Icelandic"
589 !insertmacro MUI_LANGUAGE "Indonesian"
590 !insertmacro MUI_LANGUAGE "Irish"
591 !insertmacro MUI_LANGUAGE "Italian"
592 !insertmacro MUI_LANGUAGE "Japanese"
593 !insertmacro MUI_LANGUAGE "Korean"
594 !insertmacro MUI_LANGUAGE "Kurdish"
595 !insertmacro MUI_LANGUAGE "Latvian"
596 !insertmacro MUI_LANGUAGE "Lithuanian"
597 !insertmacro MUI_LANGUAGE "Luxembourgish"
598 !insertmacro MUI_LANGUAGE "Macedonian"
599 !insertmacro MUI_LANGUAGE "Malay"
600 !insertmacro MUI_LANGUAGE "Mongolian"
601 !insertmacro MUI_LANGUAGE "Norwegian"
602 !insertmacro MUI_LANGUAGE "Polish"
603 !insertmacro MUI_LANGUAGE "Portuguese"
604 !insertmacro MUI_LANGUAGE "PortugueseBR"
605 !insertmacro MUI_LANGUAGE "Romanian"
606 !insertmacro MUI_LANGUAGE "Russian"
607 !insertmacro MUI_LANGUAGE "Serbian"
608 !insertmacro MUI_LANGUAGE "SerbianLatin"
609 !insertmacro MUI_LANGUAGE "SimpChinese"
610 !insertmacro MUI_LANGUAGE "Slovak"
611 !insertmacro MUI_LANGUAGE "Slovenian"
612 !insertmacro MUI_LANGUAGE "Spanish"
613 !insertmacro MUI_LANGUAGE "Swedish"
614 !insertmacro MUI_LANGUAGE "Thai"
615 !insertmacro MUI_LANGUAGE "TradChinese"
616 !insertmacro MUI_LANGUAGE "Turkish"
617 !insertmacro MUI_LANGUAGE "Ukrainian"
618 !insertmacro MUI_LANGUAGE "Welsh"
619
620 ;--------------------------------
621 ;Reserve Files
622
623 ;These files should be inserted before other files in the data block
624 ;Keep these lines before any File command
625 ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
626
627 ReserveFile "NSIS.InstallOptions.ini"
628 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
629
630 ; for UserInfo::GetName and UserInfo::GetAccountType
631 ReserveFile /plugin 'UserInfo.dll'
632
633 ;--------------------------------
634 ; Installation types
635 @CPACK_NSIS_INSTALLATION_TYPES@
636
637 ;--------------------------------
638 ; Component sections
639 @CPACK_NSIS_COMPONENT_SECTIONS@
640
641 ;--------------------------------
642 ;Installer Sections
643
644 Section "-Core installation"
645 ;Use the entire tree produced by the INSTALL target. Keep the
646 ;list of directories here in sync with the RMDir commands below.
647 SetOutPath "$INSTDIR"
648 @CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@
649 @CPACK_NSIS_FULL_INSTALL@
650
651 ;Store installation folder
652 SetRegView @CPACK_NSIS_REGISTRY_VIEW@
653 WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
654
655 ;Create uninstaller
656 WriteUninstaller "$INSTDIR\@[email protected]"
657 Push "DisplayName"
658 Push "@CPACK_NSIS_DISPLAY_NAME@"
659 Call ConditionalAddToRegisty
660 Push "DisplayVersion"
661 Push "@CPACK_PACKAGE_VERSION@"
662 Call ConditionalAddToRegisty
663 Push "Publisher"
664 Push "@CPACK_PACKAGE_VENDOR@"
665 Call ConditionalAddToRegisty
666 Push "UninstallString"
667 Push "$INSTDIR\@[email protected]"
668 Call ConditionalAddToRegisty
669 Push "NoRepair"
670 Push "1"
671 Call ConditionalAddToRegisty
672
673 !ifdef CPACK_NSIS_ADD_REMOVE
674 ;Create add/remove functionality
675 Push "ModifyPath"
676 Push "$INSTDIR\AddRemove.exe"
677 Call ConditionalAddToRegisty
678 !else
679 Push "NoModify"
680 Push "1"
681 Call ConditionalAddToRegisty
682 !endif
683
684 ; Optional registration
685 Push "DisplayIcon"
686 Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
687 Call ConditionalAddToRegisty
688 Push "HelpLink"
689 Push "@CPACK_NSIS_HELP_LINK@"
690 Call ConditionalAddToRegisty
691 Push "URLInfoAbout"
692 Push "@CPACK_NSIS_URL_INFO_ABOUT@"
693 Call ConditionalAddToRegisty
694 Push "Contact"
695 Push "@CPACK_NSIS_CONTACT@"
696 Call ConditionalAddToRegisty
697 !insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State"
698 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
699
700 ;Create shortcuts
701 CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
702 @CPACK_NSIS_CREATE_ICONS@
703 @CPACK_NSIS_CREATE_ICONS_EXTRA@
704 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\@[email protected]"
705
706 ;Read a value from an InstallOptions INI file
707 !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
708 !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
709 !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State"
710
711 ; Write special uninstall registry entries
712 Push "StartMenu"
713 Push "$STARTMENU_FOLDER"
714 Call ConditionalAddToRegisty
715 Push "DoNotAddToPath"
716 Push "$DO_NOT_ADD_TO_PATH"
717 Call ConditionalAddToRegisty
718 Push "AddToPathAllUsers"
719 Push "$ADD_TO_PATH_ALL_USERS"
720 Call ConditionalAddToRegisty
721 Push "AddToPathCurrentUser"
722 Push "$ADD_TO_PATH_CURRENT_USER"
723 Call ConditionalAddToRegisty
724 Push "InstallToDesktop"
725 Push "$INSTALL_DESKTOP"
726 Call ConditionalAddToRegisty
727
728 !insertmacro MUI_STARTMENU_WRITE_END
729
730 @CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
731
732 SectionEnd
733
734 Section "-Add to path"
735 Push $INSTDIR\bin
736 StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath
737 StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
738 Call AddToPath
739 doNotAddToPath:
740 SectionEnd
741
742 ;--------------------------------
743 ; Create custom pages
744 Function InstallOptionsPage
745 !insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@"
746 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
747
748 FunctionEnd
749
750 ;--------------------------------
751 ; determine admin versus local install
752 Function un.onInit
753
754 ClearErrors
755 UserInfo::GetName
756 IfErrors noLM
757 Pop $0
758 UserInfo::GetAccountType
759 Pop $1
760 StrCmp $1 "Admin" 0 +3
761 SetShellVarContext all
762 ;MessageBox MB_OK 'User "$0" is in the Admin group'
763 Goto done
764 StrCmp $1 "Power" 0 +3
765 SetShellVarContext all
766 ;MessageBox MB_OK 'User "$0" is in the Power Users group'
767 Goto done
768
769 noLM:
770 ;Get installation folder from registry if available
771
772 done:
773
774 FunctionEnd
775
776 ;--- Add/Remove callback functions: ---
777 !macro SectionList MacroName
778 ;This macro used to perform operation on multiple sections.
779 ;List all of your components in following manner here.
780 @CPACK_NSIS_COMPONENT_SECTION_LIST@
781 !macroend
782
783 Section -FinishComponents
784 ;Removes unselected components and writes component status to registry
785 !insertmacro SectionList "FinishSection"
786
787 !ifdef CPACK_NSIS_ADD_REMOVE
788 ; Get the name of the installer executable
789 System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
790 StrCpy $R3 $R0
791
792 ; Strip off the last 13 characters, to see if we have AddRemove.exe
793 StrLen $R1 $R0
794 IntOp $R1 $R0 - 13
795 StrCpy $R2 $R0 13 $R1
796 StrCmp $R2 "AddRemove.exe" addremove_installed
797
798 ; We're not running AddRemove.exe, so install it
799 CopyFiles $R3 $INSTDIR\AddRemove.exe
800
801 addremove_installed:
802 !endif
803 SectionEnd
804 ;--- End of Add/Remove callback functions ---
805
806 ;--------------------------------
807 ; Component dependencies
808 Function .onSelChange
809 !insertmacro SectionList MaybeSelectionChanged
810 FunctionEnd
811
812 ;--------------------------------
813 ;Uninstaller Section
814
815 Section "Uninstall"
816 SetRegView @CPACK_NSIS_REGISTRY_VIEW@
817 ReadRegStr $START_MENU SHCTX \
818 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu"
819 ;MessageBox MB_OK "Start menu is in: $START_MENU"
820 ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \
821 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "DoNotAddToPath"
822 ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \
823 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathAllUsers"
824 ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \
825 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathCurrentUser"
826 ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
827 ReadRegStr $INSTALL_DESKTOP SHCTX \
828 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "InstallToDesktop"
829 ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
830
831 @CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
832
833 ;Remove files we installed.
834 ;Keep the list of directories here in sync with the File commands above.
835 @CPACK_NSIS_DELETE_FILES@
836 @CPACK_NSIS_DELETE_DIRECTORIES@
837
838 !ifdef CPACK_NSIS_ADD_REMOVE
839 ;Remove the add/remove program
840 Delete "$INSTDIR\AddRemove.exe"
841 !endif
842
843 ;Remove the uninstaller itself.
844 Delete "$INSTDIR\@[email protected]"
845 DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
846
847 ;Remove the installation directory if it is empty.
848 RMDir "$INSTDIR"
849
850 ; Remove the registry entries.
851 DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
852
853 ; Removes all optional components
854 !insertmacro SectionList "RemoveSection_CPack"
855
856 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
857
858 Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
859 @CPACK_NSIS_DELETE_ICONS@
860 @CPACK_NSIS_DELETE_ICONS_EXTRA@
861
862 ;Delete empty start menu parent directories
863 StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
864
865 startMenuDeleteLoop:
866 ClearErrors
867 RMDir $MUI_TEMP
868 GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
869
870 IfErrors startMenuDeleteLoopDone
871
872 StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
873 startMenuDeleteLoopDone:
874
875 ; If the user changed the shortcut, then untinstall may not work. This should
876 ; try to fix it.
877 StrCpy $MUI_TEMP "$START_MENU"
878 Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
879 @CPACK_NSIS_DELETE_ICONS_EXTRA@
880
881 ;Delete empty start menu parent directories
882 StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
883
884 secondStartMenuDeleteLoop:
885 ClearErrors
886 RMDir $MUI_TEMP
887 GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
888
889 IfErrors secondStartMenuDeleteLoopDone
890
891 StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
892 secondStartMenuDeleteLoopDone:
893
894 DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
895
896 Push $INSTDIR\bin
897 StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
898 Call un.RemoveFromPath
899 doNotRemoveFromPath:
900 SectionEnd
901
902 ;--------------------------------
903 ; determine admin versus local install
904 ; Is install for "AllUsers" or "JustMe"?
905 ; Default to "JustMe" - set to "AllUsers" if admin or on Win9x
906 ; This function is used for the very first "custom page" of the installer.
907 ; This custom page does not show up visibly, but it executes prior to the
908 ; first visible page and sets up $INSTDIR properly...
909 ; Choose different default installation folder based on SV_ALLUSERS...
910 ; "Program Files" for AllUsers, "My Documents" for JustMe...
911
912 Function .onInit
913 ; If we need to check for uninstaller, check the native key first. If that
914 ; isn't present, optionally also check the 32bit key, due to a bug where previous
915 ; versions of the NSIS script installed into the 32bit registry view on 64bit
916 ; machines.
917 StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst
918
919 SetRegView @CPACK_NSIS_REGISTRY_VIEW@
920 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString"
921 StrCmp $0 "" inst ask_uninstaller
922
923 check_32bit_uninstaller:
924 StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_DONT_CHECK_32BIT@" "ON" 0 inst
925 SetRegView 32
926 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString"
927 SetRegView @CPACK_NSIS_REGISTRY_VIEW@
928 StrCmp $0 "" inst ask_uninstaller
929
930 ;Uninstaller was found. Ask the user to run it.
931 ask_uninstaller:
932 MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
933 "@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \
934 /SD IDYES IDYES uninst IDNO inst
935 Abort
936
937 ;Run the uninstaller
938 uninst:
939 ClearErrors
940 StrLen $2 "\Uninstall.exe"
941 StrCpy $3 $0 -$2 # remove "\Uninstall.exe" from UninstallString to get path
942 ExecWait '"$0" /S _?=$3' ;Do not copy the uninstaller to a temp file
943
944 IfErrors uninst_failed inst
945 uninst_failed:
946 MessageBox MB_OK|MB_ICONSTOP "Uninstall failed."
947 Abort
948
949
950 inst:
951 ; Reads components status for registry
952 !insertmacro SectionList "InitSection"
953
954 ; check to see if /D has been used to change
955 ; the install directory by comparing it to the
956 ; install directory that is expected to be the
957 ; default
958 StrCpy $IS_DEFAULT_INSTALLDIR 0
959 StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2
960 StrCpy $IS_DEFAULT_INSTALLDIR 1
961
962 StrCpy $SV_ALLUSERS "JustMe"
963 ; if default install dir then change the default
964 ; if it is installed for JustMe
965 StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
966 StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
967
968 ClearErrors
969 UserInfo::GetName
970 IfErrors noLM
971 Pop $0
972 UserInfo::GetAccountType
973 Pop $1
974 StrCmp $1 "Admin" 0 +4
975 SetShellVarContext all
976 ;MessageBox MB_OK 'User "$0" is in the Admin group'
977 StrCpy $SV_ALLUSERS "AllUsers"
978 Goto done
979 StrCmp $1 "Power" 0 +4
980 SetShellVarContext all
981 ;MessageBox MB_OK 'User "$0" is in the Power Users group'
982 StrCpy $SV_ALLUSERS "AllUsers"
983 Goto done
984
985 noLM:
986 StrCpy $SV_ALLUSERS "AllUsers"
987 ;Get installation folder from registry if available
988
989 done:
990 StrCmp $SV_ALLUSERS "AllUsers" 0 +3
991 StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
992 StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
993
994 StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage
995 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
996
997 noOptionsPage:
998 FunctionEnd