1 ; CPack install script designed for a nmake build
\r
3 ;--------------------------------
\r
4 ; You must define these values
\r
6 !define VERSION "@CPACK_PACKAGE_VERSION@"
\r
7 !define PATCH "@CPACK_PACKAGE_VERSION_PATCH@"
\r
8 !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
\r
10 ;--------------------------------
\r
14 Var STARTMENU_FOLDER
\r
17 Var DO_NOT_ADD_TO_PATH
\r
18 Var ADD_TO_PATH_ALL_USERS
\r
19 Var ADD_TO_PATH_CURRENT_USER
\r
21 Var IS_DEFAULT_INSTALLDIR
\r
22 ;--------------------------------
\r
27 ;Default installation folder
\r
28 InstallDir "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
\r
30 ;--------------------------------
\r
34 Name "@CPACK_NSIS_PACKAGE_NAME@"
\r
35 OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
\r
38 SetCompressor @CPACK_NSIS_COMPRESSOR@
\r
40 @CPACK_NSIS_DEFINES@
\r
42 !include Sections.nsh
\r
44 ;--- Component support macros: ---
\r
45 ; The code for the add/remove functionality is from:
\r
46 ; http://nsis.sourceforge.net/Add/Remove_Functionality
\r
47 ; It has been modified slightly and extended to provide
\r
48 ; inter-component dependencies.
\r
51 @CPACK_NSIS_SECTION_SELECTED_VARS@
\r
53 ; Loads the "selected" flag for the section named SecName into the
\r
55 !macro LoadSectionSelectedIntoVar SecName VarName
\r
56 SectionGetFlags ${${SecName}} $${VarName}
\r
57 IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits
\r
60 ; Loads the value of a variable... can we get around this?
\r
61 !macro LoadVar VarName
\r
62 IntOp $R0 0 + $${VarName}
\r
65 ; Sets the value of a variable
\r
66 !macro StoreVar VarName IntValue
\r
67 IntOp $${VarName} 0 + ${IntValue}
\r
70 !macro InitSection SecName
\r
71 ; This macro reads component installed flag from the registry and
\r
72 ;changes checked state of the section on the components page.
\r
73 ;Input: section index constant name specified in Section command.
\r
76 ;Reading component status from registry
\r
77 ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed"
\r
78 IfErrors "default_${SecName}"
\r
79 ;Status will stay default if registry value not found
\r
80 ;(component was never installed)
\r
81 IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits
\r
82 SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags
\r
83 IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off
\r
84 IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit
\r
86 ; Note whether this component was installed before
\r
87 !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags
\r
88 IntOp $R0 $AR_RegFlags & $AR_RegFlags
\r
90 ;Writing modified flags
\r
91 SectionSetFlags ${${SecName}} $AR_SecFlags
\r
93 "default_${SecName}:"
\r
94 !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
\r
97 !macro FinishSection SecName
\r
98 ; This macro reads section flag set by user and removes the section
\r
99 ;if it is not selected.
\r
100 ;Then it writes component installed flag to registry
\r
101 ;Input: section index constant name specified in Section command.
\r
103 SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags
\r
104 ;Checking lowest bit:
\r
105 IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED}
\r
106 IntCmp $AR_SecFlags 1 "leave_${SecName}"
\r
107 ;Section is not selected:
\r
108 ;Calling Section uninstall macro and writing zero installed flag
\r
109 !insertmacro "Remove_${${SecName}}"
\r
110 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
\r
112 Goto "exit_${SecName}"
\r
114 "leave_${SecName}:"
\r
115 ;Section is selected:
\r
116 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
\r
122 !macro RemoveSection SecName
\r
123 ; This macro is used to call section's Remove_... macro
\r
124 ;from the uninstaller.
\r
125 ;Input: section index constant name specified in Section command.
\r
127 !insertmacro "Remove_${${SecName}}"
\r
130 ; Determine whether the selection of SecName changed
\r
131 !macro MaybeSelectionChanged SecName
\r
132 !insertmacro LoadVar ${SecName}_selected
\r
133 SectionGetFlags ${${SecName}} $R1
\r
134 IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits
\r
136 ; See if the status has changed:
\r
137 IntCmp $R0 $R1 "${SecName}_unchanged"
\r
138 !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
\r
140 IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected"
\r
141 !insertmacro "Deselect_required_by_${SecName}"
\r
142 goto "${SecName}_unchanged"
\r
144 "${SecName}_was_selected:"
\r
145 !insertmacro "Select_${SecName}_depends"
\r
147 "${SecName}_unchanged:"
\r
149 ;--- End of Add/Remove macros ---
\r
151 ;--------------------------------
\r
152 ;Interface Settings
\r
154 !define MUI_HEADERIMAGE
\r
155 !define MUI_ABORTWARNING
\r
157 ;--------------------------------
\r
161 !include "WinMessages.NSH"
\r
164 ;----------------------------------------
\r
165 ; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
\r
166 ;----------------------------------------
\r
168 !include "WinMessages.NSH"
\r
170 ;====================================================
\r
171 ; get_NT_environment
\r
172 ; Returns: the selected environment
\r
173 ; Output : head of the stack
\r
174 ;====================================================
\r
175 !macro select_NT_profile UN
\r
176 Function ${UN}select_NT_profile
\r
177 StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single
\r
178 DetailPrint "Selected environment for all users"
\r
181 environment_single:
\r
182 DetailPrint "Selected environment for current user only."
\r
187 !insertmacro select_NT_profile ""
\r
188 !insertmacro select_NT_profile "un."
\r
189 ;----------------------------------------------------
\r
190 !define NT_current_env 'HKCU "Environment"'
\r
191 !define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
\r
193 !ifndef WriteEnvStr_RegKey
\r
195 !define WriteEnvStr_RegKey \
\r
196 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
\r
198 !define WriteEnvStr_RegKey 'HKCU "Environment"'
\r
202 ; AddToPath - Adds the given dir to the search path.
\r
203 ; Input - head of the stack
\r
204 ; Note - Win9x systems requires reboot
\r
212 # don't add if the path doesn't exist
\r
213 IfFileExists "$0\*.*" "" AddToPath_done
\r
216 ; if the path is too long for a NSIS variable NSIS will return a 0
\r
217 ; length string. If we find that, then warn and skip any path
\r
218 ; modification as it will trash the existing path.
\r
220 IntCmp $2 0 CheckPathLength_ShowPathWarning CheckPathLength_Done CheckPathLength_Done
\r
221 CheckPathLength_ShowPathWarning:
\r
222 Messagebox MB_OK|MB_ICONEXCLAMATION "Warning! PATH too long installer unable to modify PATH!"
\r
223 Goto AddToPath_done
\r
224 CheckPathLength_Done:
\r
229 StrCmp $2 "" "" AddToPath_done
\r
234 StrCmp $2 "" "" AddToPath_done
\r
235 GetFullPathName /SHORT $3 $0
\r
240 StrCmp $2 "" "" AddToPath_done
\r
245 StrCmp $2 "" "" AddToPath_done
\r
249 StrCmp $1 1 AddToPath_NT
\r
251 StrCpy $1 $WINDIR 2
\r
252 FileOpen $1 "$1\autoexec.bat" a
\r
255 IntCmp $2 26 0 +2 +2 # DOS EOF
\r
256 FileSeek $1 -1 END # write over EOF
\r
257 FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
\r
260 Goto AddToPath_done
\r
263 StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey
\r
264 ReadRegStr $1 ${NT_current_env} "PATH"
\r
267 ReadRegStr $1 ${NT_all_env} "PATH"
\r
269 StrCmp $1 "" AddToPath_NTdoIt
\r
275 StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey
\r
276 WriteRegExpandStr ${NT_current_env} "PATH" $0
\r
279 WriteRegExpandStr ${NT_all_env} "PATH" $0
\r
281 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
\r
291 ; RemoveFromPath - Remove a given dir from the path
\r
292 ; Input: head of the stack
\r
294 Function un.RemoveFromPath
\r
303 IntFmt $6 "%c" 26 # DOS EOF
\r
307 StrCmp $1 1 unRemoveFromPath_NT
\r
309 StrCpy $1 $WINDIR 2
\r
310 FileOpen $1 "$1\autoexec.bat" r
\r
313 GetFullPathName /SHORT $0 $0
\r
314 StrCpy $0 "SET PATH=%PATH%;$0"
\r
315 Goto unRemoveFromPath_dosLoop
\r
317 unRemoveFromPath_dosLoop:
\r
319 StrCpy $5 $3 1 -1 # read last char
\r
320 StrCmp $5 $6 0 +2 # if DOS EOF
\r
321 StrCpy $3 $3 -1 # remove DOS EOF so we can compare
\r
322 StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
\r
323 StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
\r
324 StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
\r
325 StrCmp $3 "" unRemoveFromPath_dosLoopEnd
\r
327 Goto unRemoveFromPath_dosLoop
\r
328 unRemoveFromPath_dosLoopRemoveLine:
\r
330 Goto unRemoveFromPath_dosLoop
\r
332 unRemoveFromPath_dosLoopEnd:
\r
335 StrCpy $1 $WINDIR 2
\r
336 Delete "$1\autoexec.bat"
\r
337 CopyFiles /SILENT $4 "$1\autoexec.bat"
\r
339 Goto unRemoveFromPath_done
\r
341 unRemoveFromPath_NT:
\r
342 StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey
\r
343 ReadRegStr $1 ${NT_current_env} "PATH"
\r
346 ReadRegStr $1 ${NT_all_env} "PATH"
\r
348 StrCpy $5 $1 1 -1 # copy last char
\r
349 StrCmp $5 ";" +2 # if last char != ;
\r
350 StrCpy $1 "$1;" # append ;
\r
353 Call un.StrStr ; Find `$0;` in $1
\r
354 Pop $2 ; pos of our dir
\r
355 StrCmp $2 "" unRemoveFromPath_done
\r
356 ; else, it is in path
\r
361 StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
\r
362 StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
\r
365 StrCpy $5 $3 1 -1 # copy last char
\r
366 StrCmp $5 ";" 0 +2 # if last char == ;
\r
367 StrCpy $3 $3 -1 # remove last char
\r
369 StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey
\r
370 WriteRegExpandStr ${NT_current_env} "PATH" $3
\r
373 WriteRegExpandStr ${NT_all_env} "PATH" $3
\r
375 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
\r
377 unRemoveFromPath_done:
\r
387 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
389 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
391 ###########################################
\r
392 # Utility Functions #
\r
393 ###########################################
\r
395 ;====================================================
\r
396 ; IsNT - Returns 1 if the current system is NT, 0
\r
398 ; Output: head of the stack
\r
399 ;====================================================
\r
402 ; output, top of the stack = 1 if NT or 0 if not
\r
407 ; ($R0 at this point is 1 or 0)
\r
412 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
\r
413 StrCmp $0 "" 0 IsNT_yes
\r
425 !insertmacro IsNT ""
\r
426 !insertmacro IsNT "un."
\r
429 ; input, top of stack = string to search for
\r
430 ; top of stack-1 = string to search in
\r
431 ; output, top of stack (replaces with the portion of the string remaining)
\r
432 ; modifies no other variables.
\r
435 ; Push "this is a long ass string"
\r
439 ; ($R0 at this point is "ass string")
\r
442 Function ${un}StrStr
\r
443 Exch $R1 ; st=haystack,old$R1, $R1=needle
\r
444 Exch ; st=old$R1,haystack
\r
445 Exch $R2 ; st=old$R1,old$R2, $R2=haystack
\r
457 StrCpy $R5 $R2 $R3 $R4
\r
458 StrCmp $R5 $R1 done
\r
463 StrCpy $R1 $R2 "" $R4
\r
471 !insertmacro StrStr ""
\r
472 !insertmacro StrStr "un."
\r
474 Function Trim ; Added by Pelaca
\r
478 StrCpy $R2 "$R1" 1 -1
\r
479 StrCmp "$R2" " " RTrim
\r
480 StrCmp "$R2" "$\n" RTrim
\r
481 StrCmp "$R2" "$\r" RTrim
\r
482 StrCmp "$R2" ";" RTrim
\r
485 StrCpy $R1 "$R1" -1
\r
492 Function ConditionalAddToRegisty
\r
495 StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
\r
496 WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" \
\r
498 ;MessageBox MB_OK "Set Registry: '$1' to '$0'"
\r
499 DetailPrint "Set install registry entry: '$1' to '$0'"
\r
500 ConditionalAddToRegisty_EmptyString:
\r
503 ;--------------------------------
\r
505 !ifdef CPACK_USES_DOWNLOAD
\r
506 Function DownloadFile
\r
507 IfFileExists $INSTDIR\* +2
\r
508 CreateDirectory $INSTDIR
\r
511 ; Skip if already downloaded
\r
512 IfFileExists $INSTDIR\$0 0 +2
\r
515 StrCpy $1 "@CPACK_DOWNLOAD_SITE@"
\r
518 NSISdl::download "$1/$0" "$INSTDIR\$0"
\r
521 StrCmp $1 "success" success
\r
522 StrCmp $1 "Cancelled" cancel
\r
523 MessageBox MB_OK "Download failed: $1"
\r
530 ;--------------------------------
\r
531 ; Installation types
\r
532 @CPACK_NSIS_INSTALLATION_TYPES@
\r
534 ;--------------------------------
\r
535 ; Component sections
\r
536 @CPACK_NSIS_COMPONENT_SECTIONS@
\r
538 ;--------------------------------
\r
539 ; Define some macro setting for the gui
\r
540 @CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
\r
541 @CPACK_NSIS_INSTALLER_ICON_CODE@
\r
542 @CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
\r
543 @CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@
\r
545 ;--------------------------------
\r
547 !insertmacro MUI_PAGE_WELCOME
\r
549 !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
\r
550 Page custom InstallOptionsPage
\r
551 !insertmacro MUI_PAGE_DIRECTORY
\r
553 ;Start Menu Folder Page Configuration
\r
554 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
\r
555 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
\r
556 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
\r
557 !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
\r
559 @CPACK_NSIS_PAGE_COMPONENTS@
\r
561 !insertmacro MUI_PAGE_INSTFILES
\r
562 !insertmacro MUI_PAGE_FINISH
\r
564 !insertmacro MUI_UNPAGE_CONFIRM
\r
565 !insertmacro MUI_UNPAGE_INSTFILES
\r
567 ;--------------------------------
\r
570 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
\r
571 !insertmacro MUI_LANGUAGE "Albanian"
\r
572 !insertmacro MUI_LANGUAGE "Arabic"
\r
573 !insertmacro MUI_LANGUAGE "Basque"
\r
574 !insertmacro MUI_LANGUAGE "Belarusian"
\r
575 !insertmacro MUI_LANGUAGE "Bosnian"
\r
576 !insertmacro MUI_LANGUAGE "Breton"
\r
577 !insertmacro MUI_LANGUAGE "Bulgarian"
\r
578 !insertmacro MUI_LANGUAGE "Croatian"
\r
579 !insertmacro MUI_LANGUAGE "Czech"
\r
580 !insertmacro MUI_LANGUAGE "Danish"
\r
581 !insertmacro MUI_LANGUAGE "Dutch"
\r
582 !insertmacro MUI_LANGUAGE "Estonian"
\r
583 !insertmacro MUI_LANGUAGE "Farsi"
\r
584 !insertmacro MUI_LANGUAGE "Finnish"
\r
585 !insertmacro MUI_LANGUAGE "French"
\r
586 !insertmacro MUI_LANGUAGE "German"
\r
587 !insertmacro MUI_LANGUAGE "Greek"
\r
588 !insertmacro MUI_LANGUAGE "Hebrew"
\r
589 !insertmacro MUI_LANGUAGE "Hungarian"
\r
590 !insertmacro MUI_LANGUAGE "Icelandic"
\r
591 !insertmacro MUI_LANGUAGE "Indonesian"
\r
592 !insertmacro MUI_LANGUAGE "Irish"
\r
593 !insertmacro MUI_LANGUAGE "Italian"
\r
594 !insertmacro MUI_LANGUAGE "Japanese"
\r
595 !insertmacro MUI_LANGUAGE "Korean"
\r
596 !insertmacro MUI_LANGUAGE "Kurdish"
\r
597 !insertmacro MUI_LANGUAGE "Latvian"
\r
598 !insertmacro MUI_LANGUAGE "Lithuanian"
\r
599 !insertmacro MUI_LANGUAGE "Luxembourgish"
\r
600 !insertmacro MUI_LANGUAGE "Macedonian"
\r
601 !insertmacro MUI_LANGUAGE "Malay"
\r
602 !insertmacro MUI_LANGUAGE "Mongolian"
\r
603 !insertmacro MUI_LANGUAGE "Norwegian"
\r
604 !insertmacro MUI_LANGUAGE "Polish"
\r
605 !insertmacro MUI_LANGUAGE "Portuguese"
\r
606 !insertmacro MUI_LANGUAGE "PortugueseBR"
\r
607 !insertmacro MUI_LANGUAGE "Romanian"
\r
608 !insertmacro MUI_LANGUAGE "Russian"
\r
609 !insertmacro MUI_LANGUAGE "Serbian"
\r
610 !insertmacro MUI_LANGUAGE "SerbianLatin"
\r
611 !insertmacro MUI_LANGUAGE "SimpChinese"
\r
612 !insertmacro MUI_LANGUAGE "Slovak"
\r
613 !insertmacro MUI_LANGUAGE "Slovenian"
\r
614 !insertmacro MUI_LANGUAGE "Spanish"
\r
615 !insertmacro MUI_LANGUAGE "Swedish"
\r
616 !insertmacro MUI_LANGUAGE "Thai"
\r
617 !insertmacro MUI_LANGUAGE "TradChinese"
\r
618 !insertmacro MUI_LANGUAGE "Turkish"
\r
619 !insertmacro MUI_LANGUAGE "Ukrainian"
\r
620 !insertmacro MUI_LANGUAGE "Welsh"
\r
623 ;--------------------------------
\r
626 ;These files should be inserted before other files in the data block
\r
627 ;Keep these lines before any File command
\r
628 ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
\r
630 ReserveFile "NSIS.InstallOptions.ini"
\r
631 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
\r
633 ;--------------------------------
\r
634 ;Installer Sections
\r
636 Section "-Core installation"
\r
637 ;Use the entire tree produced by the INSTALL target. Keep the
\r
638 ;list of directories here in sync with the RMDir commands below.
\r
639 SetOutPath "$INSTDIR"
\r
640 @CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@
\r
641 @CPACK_NSIS_FULL_INSTALL@
\r
643 ;Store installation folder
\r
644 WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
\r
646 ;Create uninstaller
\r
647 WriteUninstaller "$INSTDIR\Uninstall.exe"
\r
649 Push "@CPACK_NSIS_DISPLAY_NAME@"
\r
650 Call ConditionalAddToRegisty
\r
651 Push "DisplayVersion"
\r
652 Push "@CPACK_PACKAGE_VERSION@"
\r
653 Call ConditionalAddToRegisty
\r
655 Push "@CPACK_PACKAGE_VENDOR@"
\r
656 Call ConditionalAddToRegisty
\r
657 Push "UninstallString"
\r
658 Push "$INSTDIR\Uninstall.exe"
\r
659 Call ConditionalAddToRegisty
\r
662 Call ConditionalAddToRegisty
\r
664 !ifdef CPACK_NSIS_ADD_REMOVE
\r
665 ;Create add/remove functionality
\r
667 Push "$INSTDIR\AddRemove.exe"
\r
668 Call ConditionalAddToRegisty
\r
672 Call ConditionalAddToRegisty
\r
675 ; Optional registration
\r
677 Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
\r
678 Call ConditionalAddToRegisty
\r
680 Push "@CPACK_NSIS_HELP_LINK@"
\r
681 Call ConditionalAddToRegisty
\r
682 Push "URLInfoAbout"
\r
683 Push "@CPACK_NSIS_URL_INFO_ABOUT@"
\r
684 Call ConditionalAddToRegisty
\r
686 Push "@CPACK_NSIS_CONTACT@"
\r
687 Call ConditionalAddToRegisty
\r
688 !insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State"
\r
689 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
\r
692 CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
\r
693 @CPACK_NSIS_CREATE_ICONS@
\r
694 @CPACK_NSIS_CREATE_ICONS_EXTRA@
\r
695 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
\r
697 ;Read a value from an InstallOptions INI file
\r
698 !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
\r
699 !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
\r
700 !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State"
\r
702 ; Write special uninstall registry entries
\r
704 Push "$STARTMENU_FOLDER"
\r
705 Call ConditionalAddToRegisty
\r
706 Push "DoNotAddToPath"
\r
707 Push "$DO_NOT_ADD_TO_PATH"
\r
708 Call ConditionalAddToRegisty
\r
709 Push "AddToPathAllUsers"
\r
710 Push "$ADD_TO_PATH_ALL_USERS"
\r
711 Call ConditionalAddToRegisty
\r
712 Push "AddToPathCurrentUser"
\r
713 Push "$ADD_TO_PATH_CURRENT_USER"
\r
714 Call ConditionalAddToRegisty
\r
715 Push "InstallToDesktop"
\r
716 Push "$INSTALL_DESKTOP"
\r
717 Call ConditionalAddToRegisty
\r
719 !insertmacro MUI_STARTMENU_WRITE_END
\r
721 detailPrint "Installing InspIRCd service..."
\r
722 nsExec::Exec /TIMEOUT=30000 '"$INSTDIR\inspircd.exe" --installservice'
\r
724 @CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
\r
728 Section "-Add to path"
\r
730 StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath
\r
731 StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
\r
736 ;--------------------------------
\r
737 ; Create custom pages
\r
738 Function InstallOptionsPage
\r
739 !insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@"
\r
740 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
\r
744 ;--------------------------------
\r
745 ; determine admin versus local install
\r
752 UserInfo::GetAccountType
\r
754 StrCmp $1 "Admin" 0 +3
\r
755 SetShellVarContext all
\r
756 ;MessageBox MB_OK 'User "$0" is in the Admin group'
\r
758 StrCmp $1 "Power" 0 +3
\r
759 SetShellVarContext all
\r
760 ;MessageBox MB_OK 'User "$0" is in the Power Users group'
\r
764 ;Get installation folder from registry if available
\r
770 ;--- Add/Remove callback functions: ---
\r
771 !macro SectionList MacroName
\r
772 ;This macro used to perform operation on multiple sections.
\r
773 ;List all of your components in following manner here.
\r
774 @CPACK_NSIS_COMPONENT_SECTION_LIST@
\r
777 Section -FinishComponents
\r
778 ;Removes unselected components and writes component status to registry
\r
779 !insertmacro SectionList "FinishSection"
\r
781 !ifdef CPACK_NSIS_ADD_REMOVE
\r
782 ; Get the name of the installer executable
\r
783 System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
\r
786 ; Strip off the last 13 characters, to see if we have AddRemove.exe
\r
789 StrCpy $R2 $R0 13 $R1
\r
790 StrCmp $R2 "AddRemove.exe" addremove_installed
\r
792 ; We're not running AddRemove.exe, so install it
\r
793 CopyFiles $R3 $INSTDIR\AddRemove.exe
\r
795 addremove_installed:
\r
798 ;--- End of Add/Remove callback functions ---
\r
800 ;--------------------------------
\r
801 ; Component dependencies
\r
802 Function .onSelChange
\r
803 !insertmacro SectionList MaybeSelectionChanged
\r
806 ;--------------------------------
\r
807 ;Uninstaller Section
\r
809 Section "Uninstall"
\r
810 DetailPrint "Uninstalling InspIRCd service..."
\r
811 nsExec::Exec /TIMEOUT=30000 '"$INSTDIR\inspircd.exe" --removeservice'
\r
813 ReadRegStr $START_MENU SHCTX \
\r
814 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu"
\r
815 ;MessageBox MB_OK "Start menu is in: $START_MENU"
\r
816 ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \
\r
817 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "DoNotAddToPath"
\r
818 ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \
\r
819 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathAllUsers"
\r
820 ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \
\r
821 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathCurrentUser"
\r
822 ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
\r
823 ReadRegStr $INSTALL_DESKTOP SHCTX \
\r
824 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "InstallToDesktop"
\r
825 ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
\r
827 @CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
\r
829 ;Remove files we installed.
\r
830 ;Keep the list of directories here in sync with the File commands above.
\r
831 @CPACK_NSIS_DELETE_FILES@
\r
832 @CPACK_NSIS_DELETE_DIRECTORIES@
\r
834 !ifdef CPACK_NSIS_ADD_REMOVE
\r
835 ;Remove the add/remove program
\r
836 Delete "$INSTDIR\AddRemove.exe"
\r
839 ;Remove the uninstaller itself.
\r
840 Delete "$INSTDIR\Uninstall.exe"
\r
841 DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
\r
843 ;Remove the installation directory if it is empty.
\r
846 ; Remove the registry entries.
\r
847 DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
\r
849 ; Removes all optional components
\r
850 !insertmacro SectionList "RemoveSection"
\r
852 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
\r
854 Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
\r
855 @CPACK_NSIS_DELETE_ICONS@
\r
856 @CPACK_NSIS_DELETE_ICONS_EXTRA@
\r
858 ;Delete empty start menu parent diretories
\r
859 StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
\r
861 startMenuDeleteLoop:
\r
864 GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
\r
866 IfErrors startMenuDeleteLoopDone
\r
868 StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
\r
869 startMenuDeleteLoopDone:
\r
871 ; If the user changed the shortcut, then untinstall may not work. This should
\r
873 StrCpy $MUI_TEMP "$START_MENU"
\r
874 Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
\r
875 @CPACK_NSIS_DELETE_ICONS_EXTRA@
\r
877 ;Delete empty start menu parent diretories
\r
878 StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
\r
880 secondStartMenuDeleteLoop:
\r
883 GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
\r
885 IfErrors secondStartMenuDeleteLoopDone
\r
887 StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
\r
888 secondStartMenuDeleteLoopDone:
\r
890 DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
\r
893 StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
\r
894 Call un.RemoveFromPath
\r
895 doNotRemoveFromPath:
\r
898 ;--------------------------------
\r
899 ; determine admin versus local install
\r
900 ; Is install for "AllUsers" or "JustMe"?
\r
901 ; Default to "JustMe" - set to "AllUsers" if admin or on Win9x
\r
902 ; This function is used for the very first "custom page" of the installer.
\r
903 ; This custom page does not show up visibly, but it executes prior to the
\r
904 ; first visible page and sets up $INSTDIR properly...
\r
905 ; Choose different default installation folder based on SV_ALLUSERS...
\r
906 ; "Program Files" for AllUsers, "My Documents" for JustMe...
\r
909 StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst
\r
911 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "UninstallString"
\r
914 MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
\r
915 "@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \
\r
916 IDYES uninst IDNO inst
\r
919 ;Run the uninstaller
\r
922 ExecWait '$0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
\r
924 IfErrors uninst_failed inst
\r
926 MessageBox MB_OK|MB_ICONSTOP "Uninstall failed."
\r
931 ; Reads components status for registry
\r
932 !insertmacro SectionList "InitSection"
\r
934 ; check to see if /D has been used to change
\r
935 ; the install directory by comparing it to the
\r
936 ; install directory that is expected to be the
\r
938 StrCpy $IS_DEFAULT_INSTALLDIR 0
\r
939 StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2
\r
940 StrCpy $IS_DEFAULT_INSTALLDIR 1
\r
942 StrCpy $SV_ALLUSERS "JustMe"
\r
943 ; if default install dir then change the default
\r
944 ; if it is installed for JustMe
\r
945 StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
\r
946 StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
\r
952 UserInfo::GetAccountType
\r
954 StrCmp $1 "Admin" 0 +4
\r
955 SetShellVarContext all
\r
956 ;MessageBox MB_OK 'User "$0" is in the Admin group'
\r
957 StrCpy $SV_ALLUSERS "AllUsers"
\r
959 StrCmp $1 "Power" 0 +4
\r
960 SetShellVarContext all
\r
961 ;MessageBox MB_OK 'User "$0" is in the Power Users group'
\r
962 StrCpy $SV_ALLUSERS "AllUsers"
\r
966 StrCpy $SV_ALLUSERS "AllUsers"
\r
967 ;Get installation folder from registry if available
\r
970 StrCmp $SV_ALLUSERS "AllUsers" 0 +3
\r
971 StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
\r
972 StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
\r
974 StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage
\r
975 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
\r