Debian Codegraph @

Modules/Internal/CPack/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 @CPACK_NSIS_CRC_CHECK_CODE@
47
48 !include Sections.nsh
49
50 ;--- Component support macros: ---
51 ; The code for the add/remove functionality is from:
52 ; https://nsis.sourceforge.io/Add/Remove_Functionality
53 ; It has been modified slightly and extended to provide
54 ; inter-component dependencies.
55 Var AR_SecFlags
56 Var AR_RegFlags
57 @CPACK_NSIS_SECTION_SELECTED_VARS@
58
59 ; Loads the "selected" flag for the section named SecName into the
60 ; variable VarName.
61 !macro LoadSectionSelectedIntoVar SecName VarName
62 SectionGetFlags ${${SecName}} $${VarName}
63 IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits
64 !macroend
65
66 ; Loads the value of a variable... can we get around this?
67 !macro LoadVar VarName
68 IntOp $R0 0 + $${VarName}
69 !macroend
70
71 ; Sets the value of a variable
72 !macro StoreVar VarName IntValue
73 IntOp $${VarName} 0 + ${IntValue}
74 !macroend
75
76 !macro InitSection SecName
77 ; This macro reads component installed flag from the registry and
78 ;changes checked state of the section on the components page.
79 ;Input: section index constant name specified in Section command.
80
81 ClearErrors
82 ;Reading component status from registry
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 stuff
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 ConditionalAddToRegistry
492 Pop $0
493 Pop $1
494 StrCmp "$0" "" ConditionalAddToRegistry_EmptyString
495 WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" \
496 "$1" "$0"
497 ;MessageBox MB_OK "Set Registry: '$1' to '$0'"
498 DetailPrint "Set install registry entry: '$1' to '$0'"
499 ConditionalAddToRegistry_EmptyString:
500 FunctionEnd
501
502 ;--------------------------------
503
504 !ifdef CPACK_USES_DOWNLOAD
505 Function DownloadFile
506 IfFileExists $INSTDIR\* +2
507 CreateDirectory $INSTDIR
508 Pop $0
509
510 ; Skip if already downloaded
511 IfFileExists $INSTDIR\$0 0 +2
512 Return
513
514 StrCpy $1 "@CPACK_DOWNLOAD_SITE@"
515
516 try_again:
517 NSISdl::download "$1/$0" "$INSTDIR\$0"
518
519 Pop $1
520 StrCmp $1 "success" success
521 StrCmp $1 "Cancelled" cancel
522 MessageBox MB_OK "Download failed: $1"
523 cancel:
524 Return
525 success:
526 FunctionEnd
527 !endif
528
529 ;--------------------------------
530 ; Define some macro setting for the gui
531 @CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
532 @CPACK_NSIS_INSTALLER_ICON_CODE@
533 @CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE@
534 @CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE@
535 @CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@
536
537 ;--------------------------------
538 ;Pages
539 @CPACK_NSIS_INSTALLER_WELCOME_TITLE_CODE@
540 @CPACK_NSIS_INSTALLER_WELCOME_TITLE_3LINES_CODE@
541 !insertmacro MUI_PAGE_WELCOME
542
543 @CPACK_NSIS_LICENSE_PAGE@
544 Page custom InstallOptionsPage
545 !insertmacro MUI_PAGE_DIRECTORY
546
547 ;Start Menu Folder Page Configuration
548 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
549 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
550 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
551 !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
552
553 @CPACK_NSIS_PAGE_COMPONENTS@
554
555 !insertmacro MUI_PAGE_INSTFILES
556 @CPACK_NSIS_INSTALLER_FINISH_TITLE_CODE@
557 @CPACK_NSIS_INSTALLER_FINISH_TITLE_3LINES_CODE@
558 !insertmacro MUI_PAGE_FINISH
559
560 !insertmacro MUI_UNPAGE_CONFIRM
561 !insertmacro MUI_UNPAGE_INSTFILES
562
563 ;--------------------------------
564 ;Languages
565
566 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
567 !insertmacro MUI_LANGUAGE "Afrikaans"
568 !insertmacro MUI_LANGUAGE "Albanian"
569 !insertmacro MUI_LANGUAGE "Arabic"
570 !insertmacro MUI_LANGUAGE "Asturian"
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 "Catalan"
577 !insertmacro MUI_LANGUAGE "Corsican"
578 !insertmacro MUI_LANGUAGE "Croatian"
579 !insertmacro MUI_LANGUAGE "Czech"
580 !insertmacro MUI_LANGUAGE "Danish"
581 !insertmacro MUI_LANGUAGE "Dutch"
582 !insertmacro MUI_LANGUAGE "Esperanto"
583 !insertmacro MUI_LANGUAGE "Estonian"
584 !insertmacro MUI_LANGUAGE "Farsi"
585 !insertmacro MUI_LANGUAGE "Finnish"
586 !insertmacro MUI_LANGUAGE "French"
587 !insertmacro MUI_LANGUAGE "Galician"
588 !insertmacro MUI_LANGUAGE "German"
589 !insertmacro MUI_LANGUAGE "Greek"
590 !insertmacro MUI_LANGUAGE "Hebrew"
591 !insertmacro MUI_LANGUAGE "Hungarian"
592 !insertmacro MUI_LANGUAGE "Icelandic"
593 !insertmacro MUI_LANGUAGE "Indonesian"
594 !insertmacro MUI_LANGUAGE "Irish"
595 !insertmacro MUI_LANGUAGE "Italian"
596 !insertmacro MUI_LANGUAGE "Japanese"
597 !insertmacro MUI_LANGUAGE "Korean"
598 !insertmacro MUI_LANGUAGE "Kurdish"
599 !insertmacro MUI_LANGUAGE "Latvian"
600 !insertmacro MUI_LANGUAGE "Lithuanian"
601 !insertmacro MUI_LANGUAGE "Luxembourgish"
602 !insertmacro MUI_LANGUAGE "Macedonian"
603 !insertmacro MUI_LANGUAGE "Malay"
604 !insertmacro MUI_LANGUAGE "Mongolian"
605 !insertmacro MUI_LANGUAGE "Norwegian"
606 !insertmacro MUI_LANGUAGE "NorwegianNynorsk"
607 !insertmacro MUI_LANGUAGE "Pashto"
608 !insertmacro MUI_LANGUAGE "Polish"
609 !insertmacro MUI_LANGUAGE "Portuguese"
610 !insertmacro MUI_LANGUAGE "PortugueseBR"
611 !insertmacro MUI_LANGUAGE "Romanian"
612 !insertmacro MUI_LANGUAGE "Russian"
613 !insertmacro MUI_LANGUAGE "ScotsGaelic"
614 !insertmacro MUI_LANGUAGE "Serbian"
615 !insertmacro MUI_LANGUAGE "SerbianLatin"
616 !insertmacro MUI_LANGUAGE "SimpChinese"
617 !insertmacro MUI_LANGUAGE "Slovak"
618 !insertmacro MUI_LANGUAGE "Slovenian"
619 !insertmacro MUI_LANGUAGE "Spanish"
620 !insertmacro MUI_LANGUAGE "SpanishInternational"
621 !insertmacro MUI_LANGUAGE "Swedish"
622 !insertmacro MUI_LANGUAGE "Tatar"
623 !insertmacro MUI_LANGUAGE "Thai"
624 !insertmacro MUI_LANGUAGE "TradChinese"
625 !insertmacro MUI_LANGUAGE "Turkish"
626 !insertmacro MUI_LANGUAGE "Ukrainian"
627 !insertmacro MUI_LANGUAGE "Uzbek"
628 !insertmacro MUI_LANGUAGE "Vietnamese"
629 !insertmacro MUI_LANGUAGE "Welsh"
630
631 ;--------------------------------
632 ;Reserve Files
633
634 ;These files should be inserted before other files in the data block
635 ;Keep these lines before any File command
636 ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
637
638 ReserveFile "NSIS.InstallOptions.ini"
639 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
640
641 ; for UserInfo::GetName and UserInfo::GetAccountType
642 ReserveFile /plugin 'UserInfo.dll'
643
644 ;--------------------------------
645 ; Installation types
646 @CPACK_NSIS_INSTALLATION_TYPES@
647
648 ;--------------------------------
649 ; Component sections
650 @CPACK_NSIS_COMPONENT_SECTIONS@
651 @CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
652 ;--------------------------------
653 ;Installer Sections
654
655 Section "-Core installation"
656 ;Use the entire tree produced by the INSTALL target. Keep the
657 ;list of directories here in sync with the RMDir commands below.
658 SetOutPath "$INSTDIR"
659 @CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@
660 @CPACK_NSIS_FULL_INSTALL@
661
662 ;Store installation folder
663 WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
664
665 ;Create uninstaller
666 WriteUninstaller "$INSTDIR\@[email protected]"
667 Push "DisplayName"
668 Push "@CPACK_NSIS_DISPLAY_NAME@"
669 Call ConditionalAddToRegistry
670 Push "DisplayVersion"
671 Push "@CPACK_PACKAGE_VERSION@"
672 Call ConditionalAddToRegistry
673 Push "Publisher"
674 Push "@CPACK_PACKAGE_VENDOR@"
675 Call ConditionalAddToRegistry
676 Push "UninstallString"
677 Push "$\"$INSTDIR\@[email protected]$\""
678 Call ConditionalAddToRegistry
679 Push "NoRepair"
680 Push "1"
681 Call ConditionalAddToRegistry
682
683 !ifdef CPACK_NSIS_ADD_REMOVE
684 ;Create add/remove functionality
685 Push "ModifyPath"
686 Push "$INSTDIR\AddRemove.exe"
687 Call ConditionalAddToRegistry
688 !else
689 Push "NoModify"
690 Push "1"
691 Call ConditionalAddToRegistry
692 !endif
693
694 ; Optional registration
695 Push "DisplayIcon"
696 Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
697 Call ConditionalAddToRegistry
698 Push "HelpLink"
699 Push "@CPACK_NSIS_HELP_LINK@"
700 Call ConditionalAddToRegistry
701 Push "URLInfoAbout"
702 Push "@CPACK_NSIS_URL_INFO_ABOUT@"
703 Call ConditionalAddToRegistry
704 Push "Contact"
705 Push "@CPACK_NSIS_CONTACT@"
706 Call ConditionalAddToRegistry
707 !insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State"
708 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
709
710 ;Create shortcuts
711 CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
712 @CPACK_NSIS_CREATE_ICONS@
713 @CPACK_NSIS_CREATE_ICONS_EXTRA@
714 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\@[email protected]"
715
716 ;Read a value from an InstallOptions INI file
717 !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
718 !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
719 !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State"
720
721 ; Write special uninstall registry entries
722 Push "StartMenu"
723 Push "$STARTMENU_FOLDER"
724 Call ConditionalAddToRegistry
725 Push "DoNotAddToPath"
726 Push "$DO_NOT_ADD_TO_PATH"
727 Call ConditionalAddToRegistry
728 Push "AddToPathAllUsers"
729 Push "$ADD_TO_PATH_ALL_USERS"
730 Call ConditionalAddToRegistry
731 Push "AddToPathCurrentUser"
732 Push "$ADD_TO_PATH_CURRENT_USER"
733 Call ConditionalAddToRegistry
734 Push "InstallToDesktop"
735 Push "$INSTALL_DESKTOP"
736 Call ConditionalAddToRegistry
737
738 !insertmacro MUI_STARTMENU_WRITE_END
739
740 @CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
741
742 SectionEnd
743
744 Section "-Add to path"
745 Push $INSTDIR\bin
746 StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath
747 StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
748 Call AddToPath
749 doNotAddToPath:
750 SectionEnd
751
752 ;--------------------------------
753 ; Create custom pages
754 Function InstallOptionsPage
755 !insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@"
756 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
757
758 FunctionEnd
759
760 ;--------------------------------
761 ; determine admin versus local install
762 Function un.onInit
763
764 ClearErrors
765 UserInfo::GetName
766 IfErrors noLM
767 Pop $0
768 UserInfo::GetAccountType
769 Pop $1
770 StrCmp $1 "Admin" 0 +3
771 SetShellVarContext all
772 ;MessageBox MB_OK 'User "$0" is in the Admin group'
773 Goto done
774 StrCmp $1 "Power" 0 +3
775 SetShellVarContext all
776 ;MessageBox MB_OK 'User "$0" is in the Power Users group'
777 Goto done
778
779 noLM:
780 ;Get installation folder from registry if available
781
782 done:
783
784 FunctionEnd
785
786 ;--- Add/Remove callback functions: ---
787 !macro SectionList MacroName
788 ;This macro used to perform operation on multiple sections.
789 ;List all of your components in following manner here.
790 @CPACK_NSIS_COMPONENT_SECTION_LIST@
791 !macroend
792
793 Section -FinishComponents
794 ;Removes unselected components and writes component status to registry
795 !insertmacro SectionList "FinishSection"
796
797 !ifdef CPACK_NSIS_ADD_REMOVE
798 ; Get the name of the installer executable
799 System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
800 StrCpy $R3 $R0
801
802 ; Strip off the last 13 characters, to see if we have AddRemove.exe
803 StrLen $R1 $R0
804 IntOp $R1 $R0 - 13
805 StrCpy $R2 $R0 13 $R1
806 StrCmp $R2 "AddRemove.exe" addremove_installed
807
808 ; We're not running AddRemove.exe, so install it
809 CopyFiles $R3 $INSTDIR\AddRemove.exe
810
811 addremove_installed:
812 !endif
813 SectionEnd
814 ;--- End of Add/Remove callback functions ---
815
816 ;--------------------------------
817 ; Component dependencies
818 Function .onSelChange
819 !insertmacro SectionList MaybeSelectionChanged
820 FunctionEnd
821
822 ;--------------------------------
823 ;Uninstaller Section
824
825 Section "Uninstall"
826 ReadRegStr $START_MENU SHCTX \
827 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu"
828 ;MessageBox MB_OK "Start menu is in: $START_MENU"
829 ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \
830 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "DoNotAddToPath"
831 ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \
832 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathAllUsers"
833 ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \
834 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathCurrentUser"
835 ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
836 ReadRegStr $INSTALL_DESKTOP SHCTX \
837 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "InstallToDesktop"
838 ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
839
840 @CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
841
842 ;Remove files we installed.
843 ;Keep the list of directories here in sync with the File commands above.
844 @CPACK_NSIS_DELETE_FILES@
845 @CPACK_NSIS_DELETE_DIRECTORIES@
846
847 !ifdef CPACK_NSIS_ADD_REMOVE
848 ;Remove the add/remove program
849 Delete "$INSTDIR\AddRemove.exe"
850 !endif
851
852 ;Remove the uninstaller itself.
853 Delete "$INSTDIR\@[email protected]"
854 DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
855
856 ;Remove the installation directory if it is empty.
857 RMDir "$INSTDIR"
858
859 ; Remove the registry entries.
860 DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
861
862 ; Removes all optional components
863 !insertmacro SectionList "RemoveSection_CPack"
864
865 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
866
867 Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
868 @CPACK_NSIS_DELETE_ICONS@
869 @CPACK_NSIS_DELETE_ICONS_EXTRA@
870
871 ;Delete empty start menu parent directories
872 StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
873
874 startMenuDeleteLoop:
875 ClearErrors
876 RMDir $MUI_TEMP
877 GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
878
879 IfErrors startMenuDeleteLoopDone
880
881 StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
882 startMenuDeleteLoopDone:
883
884 ; If the user changed the shortcut, then uninstall may not work. This should
885 ; try to fix it.
886 StrCpy $MUI_TEMP "$START_MENU"
887 Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
888 @CPACK_NSIS_DELETE_ICONS_EXTRA@
889
890 ;Delete empty start menu parent directories
891 StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
892
893 secondStartMenuDeleteLoop:
894 ClearErrors
895 RMDir $MUI_TEMP
896 GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
897
898 IfErrors secondStartMenuDeleteLoopDone
899
900 StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
901 secondStartMenuDeleteLoopDone:
902
903 DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
904
905 Push $INSTDIR\bin
906 StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
907 Call un.RemoveFromPath
908 doNotRemoveFromPath:
909 SectionEnd
910
911 ;--------------------------------
912 ; determine admin versus local install
913 ; Is install for "AllUsers" or "JustMe"?
914 ; Default to "JustMe" - set to "AllUsers" if admin or on Win9x
915 ; This function is used for the very first "custom page" of the installer.
916 ; This custom page does not show up visibly, but it executes prior to the
917 ; first visible page and sets up $INSTDIR properly...
918 ; Choose different default installation folder based on SV_ALLUSERS...
919 ; "Program Files" for AllUsers, "My Documents" for JustMe...
920
921 Function .onInit
922 StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst
923
924 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString"
925 StrCmp $0 "" inst
926
927 ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "DisplayName"
928 MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
929 "$1 is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \
930 /SD IDYES IDYES uninst IDNO inst
931 Abort
932
933 ;Run the uninstaller
934 uninst:
935 ClearErrors
936 # $0 should _always_ be quoted, however older versions of CMake did not
937 # do this. We'll conditionally remove the begin/end quotes.
938 # Remove first char if quote
939 StrCpy $2 $0 1 0 # copy first char
940 StrCmp $2 "$\"" 0 +2 # if char is quote
941 StrCpy $0 $0 "" 1 # remove first char
942 # Remove last char if quote
943 StrCpy $2 $0 1 -1 # copy last char
944 StrCmp $2 "$\"" 0 +2 # if char is quote
945 StrCpy $0 $0 -1 # remove last char
946
947 StrLen $2 "\@[email protected]"
948 StrCpy $3 $0 -$2 # remove "\@[email protected]" from UninstallString to get path
949 ExecWait '"$0" /S _?=$3' ;Do not copy the uninstaller to a temp file
950
951 IfErrors uninst_failed inst
952 uninst_failed:
953 MessageBox MB_OK|MB_ICONSTOP "Uninstall failed."
954 Abort
955
956
957 inst:
958 ; Reads components status for registry
959 !insertmacro SectionList "InitSection"
960
961 ; check to see if /D has been used to change
962 ; the install directory by comparing it to the
963 ; install directory that is expected to be the
964 ; default
965 StrCpy $IS_DEFAULT_INSTALLDIR 0
966 StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2
967 StrCpy $IS_DEFAULT_INSTALLDIR 1
968
969 StrCpy $SV_ALLUSERS "JustMe"
970 ; if default install dir then change the default
971 ; if it is installed for JustMe
972 StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
973 StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
974
975 ClearErrors
976 UserInfo::GetName
977 IfErrors noLM
978 Pop $0
979 UserInfo::GetAccountType
980 Pop $1
981 StrCmp $1 "Admin" 0 +4
982 SetShellVarContext all
983 ;MessageBox MB_OK 'User "$0" is in the Admin group'
984 StrCpy $SV_ALLUSERS "AllUsers"
985 Goto done
986 StrCmp $1 "Power" 0 +3
987 SetShellVarContext all
988 ;MessageBox MB_OK 'User "$0" is in the Power Users group'
989 StrCpy $SV_ALLUSERS "AllUsers"
990 Goto done
991
992 noLM:
993 StrCpy $SV_ALLUSERS "AllUsers"
994 ;Get installation folder from registry if available
995
996 done:
997 StrCmp $SV_ALLUSERS "AllUsers" 0 +3
998 StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
999 StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
1000
1001 StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage
1002 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
1003
1004 noOptionsPage:
1005 FunctionEnd