Sync NSIS template with the one from CPack.

This commit is contained in:
Sadie Powell 2022-05-01 09:54:57 +01:00
parent b36bfce84f
commit e985f7ecc3

View File

@ -37,7 +37,12 @@
;Set compression ;Set compression
SetCompressor @CPACK_NSIS_COMPRESSOR@ SetCompressor @CPACK_NSIS_COMPRESSOR@
@CPACK_NSIS_DEFINES@ ;Require administrator access
RequestExecutionLevel admin
@CPACK_NSIS_DEFINES@
@CPACK_NSIS_MANIFEST_DPI_AWARE_CODE@
@CPACK_NSIS_BRANDING_TEXT_CODE@
!include Sections.nsh !include Sections.nsh
@ -71,7 +76,7 @@ Var AR_RegFlags
; This macro reads component installed flag from the registry and ; This macro reads component installed flag from the registry and
;changes checked state of the section on the components page. ;changes checked state of the section on the components page.
;Input: section index constant name specified in Section command. ;Input: section index constant name specified in Section command.
ClearErrors ClearErrors
;Reading component status from registry ;Reading component status from registry
ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed" ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed"
@ -86,20 +91,20 @@ Var AR_RegFlags
; Note whether this component was installed before ; Note whether this component was installed before
!insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags
IntOp $R0 $AR_RegFlags & $AR_RegFlags IntOp $R0 $AR_RegFlags & $AR_RegFlags
;Writing modified flags ;Writing modified flags
SectionSetFlags ${${SecName}} $AR_SecFlags SectionSetFlags ${${SecName}} $AR_SecFlags
"default_${SecName}:" "default_${SecName}:"
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
!macroend !macroend
!macro FinishSection SecName !macro FinishSection SecName
; This macro reads section flag set by user and removes the section ; This macro reads section flag set by user and removes the section
;if it is not selected. ;if it is not selected.
;Then it writes component installed flag to registry ;Then it writes component installed flag to registry
;Input: section index constant name specified in Section command. ;Input: section index constant name specified in Section command.
SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags
;Checking lowest bit: ;Checking lowest bit:
IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED} IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED}
@ -110,20 +115,20 @@ Var AR_RegFlags
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \ WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
"Installed" 0 "Installed" 0
Goto "exit_${SecName}" Goto "exit_${SecName}"
"leave_${SecName}:" "leave_${SecName}:"
;Section is selected: ;Section is selected:
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \ WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
"Installed" 1 "Installed" 1
"exit_${SecName}:" "exit_${SecName}:"
!macroend !macroend
!macro RemoveSection_CPack SecName !macro RemoveSection_CPack SecName
; This macro is used to call section's Remove_... macro ; This macro is used to call section's Remove_... macro
;from the uninstaller. ;from the uninstaller.
;Input: section index constant name specified in Section command. ;Input: section index constant name specified in Section command.
!insertmacro "Remove_${${SecName}}" !insertmacro "Remove_${${SecName}}"
!macroend !macroend
@ -132,18 +137,18 @@ Var AR_RegFlags
!insertmacro LoadVar ${SecName}_selected !insertmacro LoadVar ${SecName}_selected
SectionGetFlags ${${SecName}} $R1 SectionGetFlags ${${SecName}} $R1
IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits
; See if the status has changed: ; See if the status has changed:
IntCmp $R0 $R1 "${SecName}_unchanged" IntCmp $R0 $R1 "${SecName}_unchanged"
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected" IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected"
!insertmacro "Deselect_required_by_${SecName}" !insertmacro "Deselect_required_by_${SecName}"
goto "${SecName}_unchanged" goto "${SecName}_unchanged"
"${SecName}_was_selected:" "${SecName}_was_selected:"
!insertmacro "Select_${SecName}_depends" !insertmacro "Select_${SecName}_depends"
"${SecName}_unchanged:" "${SecName}_unchanged:"
!macroend !macroend
;--- End of Add/Remove macros --- ;--- End of Add/Remove macros ---
@ -153,13 +158,6 @@ Var AR_RegFlags
!define MUI_HEADERIMAGE !define MUI_HEADERIMAGE
!define MUI_ABORTWARNING !define MUI_ABORTWARNING
;--------------------------------
; path functions
!verbose 3
!include "WinMessages.NSH"
!verbose 4
;---------------------------------------- ;----------------------------------------
; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02" ; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
@ -168,7 +166,7 @@ Var AR_RegFlags
!include "WinMessages.NSH" !include "WinMessages.NSH"
!verbose 4 !verbose 4
;==================================================== ;====================================================
; get_NT_environment ; get_NT_environment
; Returns: the selected environment ; Returns: the selected environment
; Output : head of the stack ; Output : head of the stack
;==================================================== ;====================================================
@ -198,22 +196,22 @@ FunctionEnd
!define WriteEnvStr_RegKey 'HKCU "Environment"' !define WriteEnvStr_RegKey 'HKCU "Environment"'
!endif !endif
!endif !endif
; AddToPath - Adds the given dir to the search path. ; AddToPath - Adds the given dir to the search path.
; Input - head of the stack ; Input - head of the stack
; Note - Win9x systems requires reboot ; Note - Win9x systems requires reboot
Function AddToPath Function AddToPath
Exch $0 Exch $0
Push $1 Push $1
Push $2 Push $2
Push $3 Push $3
# don't add if the path doesn't exist # don't add if the path doesn't exist
IfFileExists "$0\*.*" "" AddToPath_done IfFileExists "$0\*.*" "" AddToPath_done
ReadEnvStr $1 PATH ReadEnvStr $1 PATH
; if the path is too long for a NSIS variable NSIS will return a 0 ; if the path is too long for a NSIS variable NSIS will return a 0
; length string. If we find that, then warn and skip any path ; length string. If we find that, then warn and skip any path
; modification as it will trash the existing path. ; modification as it will trash the existing path.
StrLen $2 $1 StrLen $2 $1
@ -243,7 +241,7 @@ Function AddToPath
Call StrStr Call StrStr
Pop $2 Pop $2
StrCmp $2 "" "" AddToPath_done StrCmp $2 "" "" AddToPath_done
Call IsNT Call IsNT
Pop $1 Pop $1
StrCmp $1 1 AddToPath_NT StrCmp $1 1 AddToPath_NT
@ -258,7 +256,7 @@ Function AddToPath
FileClose $1 FileClose $1
SetRebootFlag true SetRebootFlag true
Goto AddToPath_done Goto AddToPath_done
AddToPath_NT: AddToPath_NT:
StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey
ReadRegStr $1 ${NT_current_env} "PATH" ReadRegStr $1 ${NT_current_env} "PATH"
@ -279,7 +277,7 @@ Function AddToPath
WriteRegExpandStr ${NT_all_env} "PATH" $0 WriteRegExpandStr ${NT_all_env} "PATH" $0
DoSend: DoSend:
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
AddToPath_done: AddToPath_done:
Pop $3 Pop $3
Pop $2 Pop $2
@ -287,10 +285,10 @@ Function AddToPath
Pop $0 Pop $0
FunctionEnd FunctionEnd
; RemoveFromPath - Remove a given dir from the path ; RemoveFromPath - Remove a given dir from the path
; Input: head of the stack ; Input: head of the stack
Function un.RemoveFromPath Function un.RemoveFromPath
Exch $0 Exch $0
Push $1 Push $1
@ -299,9 +297,9 @@ Function un.RemoveFromPath
Push $4 Push $4
Push $5 Push $5
Push $6 Push $6
IntFmt $6 "%c" 26 # DOS EOF IntFmt $6 "%c" 26 # DOS EOF
Call un.IsNT Call un.IsNT
Pop $1 Pop $1
StrCmp $1 1 unRemoveFromPath_NT StrCmp $1 1 unRemoveFromPath_NT
@ -313,7 +311,7 @@ Function un.RemoveFromPath
GetFullPathName /SHORT $0 $0 GetFullPathName /SHORT $0 $0
StrCpy $0 "SET PATH=%PATH%;$0" StrCpy $0 "SET PATH=%PATH%;$0"
Goto unRemoveFromPath_dosLoop Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoop: unRemoveFromPath_dosLoop:
FileRead $1 $3 FileRead $1 $3
StrCpy $5 $3 1 -1 # read last char StrCpy $5 $3 1 -1 # read last char
@ -328,7 +326,7 @@ Function un.RemoveFromPath
unRemoveFromPath_dosLoopRemoveLine: unRemoveFromPath_dosLoopRemoveLine:
SetRebootFlag true SetRebootFlag true
Goto unRemoveFromPath_dosLoop Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoopEnd: unRemoveFromPath_dosLoopEnd:
FileClose $2 FileClose $2
FileClose $1 FileClose $1
@ -337,7 +335,7 @@ Function un.RemoveFromPath
CopyFiles /SILENT $4 "$1\autoexec.bat" CopyFiles /SILENT $4 "$1\autoexec.bat"
Delete $4 Delete $4
Goto unRemoveFromPath_done Goto unRemoveFromPath_done
unRemoveFromPath_NT: unRemoveFromPath_NT:
StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey
ReadRegStr $1 ${NT_current_env} "PATH" ReadRegStr $1 ${NT_current_env} "PATH"
@ -361,11 +359,11 @@ Function un.RemoveFromPath
StrCpy $5 $1 -$4 # $5 is now the part before the path to remove StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
StrCpy $3 $5$6 StrCpy $3 $5$6
StrCpy $5 $3 1 -1 # copy last char StrCpy $5 $3 1 -1 # copy last char
StrCmp $5 ";" 0 +2 # if last char == ; StrCmp $5 ";" 0 +2 # if last char == ;
StrCpy $3 $3 -1 # remove last char StrCpy $3 $3 -1 # remove last char
StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey
WriteRegExpandStr ${NT_current_env} "PATH" $3 WriteRegExpandStr ${NT_current_env} "PATH" $3
Goto unDoSend Goto unDoSend
@ -373,7 +371,7 @@ Function un.RemoveFromPath
WriteRegExpandStr ${NT_all_env} "PATH" $3 WriteRegExpandStr ${NT_all_env} "PATH" $3
unDoSend: unDoSend:
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
unRemoveFromPath_done: unRemoveFromPath_done:
Pop $6 Pop $6
Pop $5 Pop $5
@ -383,7 +381,7 @@ Function un.RemoveFromPath
Pop $1 Pop $1
Pop $0 Pop $0
FunctionEnd FunctionEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Uninstall stuff ; Uninstall stuff
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -391,7 +389,7 @@ FunctionEnd
########################################### ###########################################
# Utility Functions # # Utility Functions #
########################################### ###########################################
;==================================================== ;====================================================
; IsNT - Returns 1 if the current system is NT, 0 ; IsNT - Returns 1 if the current system is NT, 0
; otherwise. ; otherwise.
@ -405,7 +403,7 @@ FunctionEnd
; Call IsNT ; Call IsNT
; Pop $R0 ; Pop $R0
; ($R0 at this point is 1 or 0) ; ($R0 at this point is 1 or 0)
!macro IsNT un !macro IsNT un
Function ${un}IsNT Function ${un}IsNT
Push $0 Push $0
@ -415,7 +413,7 @@ Function ${un}IsNT
Pop $0 Pop $0
Push 0 Push 0
Return Return
IsNT_yes: IsNT_yes:
; NT!!! ; NT!!!
Pop $0 Pop $0
@ -424,7 +422,7 @@ FunctionEnd
!macroend !macroend
!insertmacro IsNT "" !insertmacro IsNT ""
!insertmacro IsNT "un." !insertmacro IsNT "un."
; StrStr ; StrStr
; input, top of stack = string to search for ; input, top of stack = string to search for
; top of stack-1 = string to search in ; top of stack-1 = string to search in
@ -437,7 +435,7 @@ FunctionEnd
; Call StrStr ; Call StrStr
; Pop $R0 ; Pop $R0
; ($R0 at this point is "ass string") ; ($R0 at this point is "ass string")
!macro StrStr un !macro StrStr un
Function ${un}StrStr Function ${un}StrStr
Exch $R1 ; st=haystack,old$R1, $R1=needle Exch $R1 ; st=haystack,old$R1, $R1=needle
@ -472,21 +470,21 @@ FunctionEnd
!insertmacro StrStr "un." !insertmacro StrStr "un."
Function Trim ; Added by Pelaca Function Trim ; Added by Pelaca
Exch $R1 Exch $R1
Push $R2 Push $R2
Loop: Loop:
StrCpy $R2 "$R1" 1 -1 StrCpy $R2 "$R1" 1 -1
StrCmp "$R2" " " RTrim StrCmp "$R2" " " RTrim
StrCmp "$R2" "$\n" RTrim StrCmp "$R2" "$\n" RTrim
StrCmp "$R2" "$\r" RTrim StrCmp "$R2" "$\r" RTrim
StrCmp "$R2" ";" RTrim StrCmp "$R2" ";" RTrim
GoTo Done GoTo Done
RTrim: RTrim:
StrCpy $R1 "$R1" -1 StrCpy $R1 "$R1" -1
Goto Loop Goto Loop
Done: Done:
Pop $R2 Pop $R2
Exch $R1 Exch $R1
FunctionEnd FunctionEnd
Function ConditionalAddToRegistry Function ConditionalAddToRegistry
@ -516,7 +514,7 @@ Function DownloadFile
try_again: try_again:
NSISdl::download "$1/$0" "$INSTDIR\$0" NSISdl::download "$1/$0" "$INSTDIR\$0"
Pop $1 Pop $1
StrCmp $1 "success" success StrCmp $1 "success" success
StrCmp $1 "Cancelled" cancel StrCmp $1 "Cancelled" cancel
@ -527,38 +525,35 @@ Function DownloadFile
FunctionEnd FunctionEnd
!endif !endif
;--------------------------------
; Installation types
@CPACK_NSIS_INSTALLATION_TYPES@
;--------------------------------
; Component sections
@CPACK_NSIS_COMPONENT_SECTIONS@
;-------------------------------- ;--------------------------------
; Define some macro setting for the gui ; Define some macro setting for the gui
@CPACK_NSIS_INSTALLER_MUI_ICON_CODE@ @CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
@CPACK_NSIS_INSTALLER_ICON_CODE@ @CPACK_NSIS_INSTALLER_ICON_CODE@
@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@ @CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE@
@CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE@
@CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@ @CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@
;-------------------------------- ;--------------------------------
;Pages ;Pages
@CPACK_NSIS_INSTALLER_WELCOME_TITLE_CODE@
@CPACK_NSIS_INSTALLER_WELCOME_TITLE_3LINES_CODE@
!insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@" @CPACK_NSIS_LICENSE_PAGE@
Page custom InstallOptionsPage Page custom InstallOptionsPage
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
;Start Menu Folder Page Configuration ;Start Menu Folder Page Configuration
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
@CPACK_NSIS_PAGE_COMPONENTS@ @CPACK_NSIS_PAGE_COMPONENTS@
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
@CPACK_NSIS_INSTALLER_FINISH_TITLE_CODE@
@CPACK_NSIS_INSTALLER_FINISH_TITLE_3LINES_CODE@
!insertmacro MUI_PAGE_FINISH !insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_CONFIRM
@ -568,21 +563,27 @@ FunctionEnd
;Languages ;Languages
!insertmacro MUI_LANGUAGE "English" ;first language is the default language !insertmacro MUI_LANGUAGE "English" ;first language is the default language
!insertmacro MUI_LANGUAGE "Afrikaans"
!insertmacro MUI_LANGUAGE "Albanian" !insertmacro MUI_LANGUAGE "Albanian"
!insertmacro MUI_LANGUAGE "Arabic" !insertmacro MUI_LANGUAGE "Arabic"
!insertmacro MUI_LANGUAGE "Asturian"
!insertmacro MUI_LANGUAGE "Basque" !insertmacro MUI_LANGUAGE "Basque"
!insertmacro MUI_LANGUAGE "Belarusian" !insertmacro MUI_LANGUAGE "Belarusian"
!insertmacro MUI_LANGUAGE "Bosnian" !insertmacro MUI_LANGUAGE "Bosnian"
!insertmacro MUI_LANGUAGE "Breton" !insertmacro MUI_LANGUAGE "Breton"
!insertmacro MUI_LANGUAGE "Bulgarian" !insertmacro MUI_LANGUAGE "Bulgarian"
!insertmacro MUI_LANGUAGE "Catalan"
!insertmacro MUI_LANGUAGE "Corsican"
!insertmacro MUI_LANGUAGE "Croatian" !insertmacro MUI_LANGUAGE "Croatian"
!insertmacro MUI_LANGUAGE "Czech" !insertmacro MUI_LANGUAGE "Czech"
!insertmacro MUI_LANGUAGE "Danish" !insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "Dutch" !insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "Esperanto"
!insertmacro MUI_LANGUAGE "Estonian" !insertmacro MUI_LANGUAGE "Estonian"
!insertmacro MUI_LANGUAGE "Farsi" !insertmacro MUI_LANGUAGE "Farsi"
!insertmacro MUI_LANGUAGE "Finnish" !insertmacro MUI_LANGUAGE "Finnish"
!insertmacro MUI_LANGUAGE "French" !insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Galician"
!insertmacro MUI_LANGUAGE "German" !insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Greek" !insertmacro MUI_LANGUAGE "Greek"
!insertmacro MUI_LANGUAGE "Hebrew" !insertmacro MUI_LANGUAGE "Hebrew"
@ -601,25 +602,31 @@ FunctionEnd
!insertmacro MUI_LANGUAGE "Malay" !insertmacro MUI_LANGUAGE "Malay"
!insertmacro MUI_LANGUAGE "Mongolian" !insertmacro MUI_LANGUAGE "Mongolian"
!insertmacro MUI_LANGUAGE "Norwegian" !insertmacro MUI_LANGUAGE "Norwegian"
!insertmacro MUI_LANGUAGE "NorwegianNynorsk"
!insertmacro MUI_LANGUAGE "Pashto"
!insertmacro MUI_LANGUAGE "Polish" !insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Portuguese" !insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "PortugueseBR" !insertmacro MUI_LANGUAGE "PortugueseBR"
!insertmacro MUI_LANGUAGE "Romanian" !insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_LANGUAGE "Russian" !insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "ScotsGaelic"
!insertmacro MUI_LANGUAGE "Serbian" !insertmacro MUI_LANGUAGE "Serbian"
!insertmacro MUI_LANGUAGE "SerbianLatin" !insertmacro MUI_LANGUAGE "SerbianLatin"
!insertmacro MUI_LANGUAGE "SimpChinese" !insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "Slovak" !insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "Slovenian" !insertmacro MUI_LANGUAGE "Slovenian"
!insertmacro MUI_LANGUAGE "Spanish" !insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "SpanishInternational"
!insertmacro MUI_LANGUAGE "Swedish" !insertmacro MUI_LANGUAGE "Swedish"
!insertmacro MUI_LANGUAGE "Tatar"
!insertmacro MUI_LANGUAGE "Thai" !insertmacro MUI_LANGUAGE "Thai"
!insertmacro MUI_LANGUAGE "TradChinese" !insertmacro MUI_LANGUAGE "TradChinese"
!insertmacro MUI_LANGUAGE "Turkish" !insertmacro MUI_LANGUAGE "Turkish"
!insertmacro MUI_LANGUAGE "Ukrainian" !insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "Uzbek"
!insertmacro MUI_LANGUAGE "Vietnamese"
!insertmacro MUI_LANGUAGE "Welsh" !insertmacro MUI_LANGUAGE "Welsh"
;-------------------------------- ;--------------------------------
;Reserve Files ;Reserve Files
@ -630,6 +637,17 @@ FunctionEnd
ReserveFile "NSIS.InstallOptions.ini" ReserveFile "NSIS.InstallOptions.ini"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; for UserInfo::GetName and UserInfo::GetAccountType
ReserveFile /plugin 'UserInfo.dll'
;--------------------------------
; Installation types
@CPACK_NSIS_INSTALLATION_TYPES@
;--------------------------------
; Component sections
@CPACK_NSIS_COMPONENT_SECTIONS@
@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
;-------------------------------- ;--------------------------------
;Installer Sections ;Installer Sections
@ -639,12 +657,12 @@ Section "-Core installation"
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
@CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@ @CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@
@CPACK_NSIS_FULL_INSTALL@ @CPACK_NSIS_FULL_INSTALL@
;Store installation folder ;Store installation folder
WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
;Create uninstaller ;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe" WriteUninstaller "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe"
Push "DisplayName" Push "DisplayName"
Push "@CPACK_NSIS_DISPLAY_NAME@" Push "@CPACK_NSIS_DISPLAY_NAME@"
Call ConditionalAddToRegistry Call ConditionalAddToRegistry
@ -655,12 +673,12 @@ Section "-Core installation"
Push "@CPACK_PACKAGE_VENDOR@" Push "@CPACK_PACKAGE_VENDOR@"
Call ConditionalAddToRegistry Call ConditionalAddToRegistry
Push "UninstallString" Push "UninstallString"
Push "$INSTDIR\Uninstall.exe" Push "$\"$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe$\""
Call ConditionalAddToRegistry Call ConditionalAddToRegistry
Push "NoRepair" Push "NoRepair"
Push "1" Push "1"
Call ConditionalAddToRegistry Call ConditionalAddToRegistry
!ifdef CPACK_NSIS_ADD_REMOVE !ifdef CPACK_NSIS_ADD_REMOVE
;Create add/remove functionality ;Create add/remove functionality
Push "ModifyPath" Push "ModifyPath"
@ -671,7 +689,7 @@ Section "-Core installation"
Push "1" Push "1"
Call ConditionalAddToRegistry Call ConditionalAddToRegistry
!endif !endif
; Optional registration ; Optional registration
Push "DisplayIcon" Push "DisplayIcon"
Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@" Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
@ -687,12 +705,12 @@ Section "-Core installation"
Call ConditionalAddToRegistry Call ConditionalAddToRegistry
!insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State" !insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State"
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
;Create shortcuts ;Create shortcuts
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
@CPACK_NSIS_CREATE_ICONS@ @CPACK_NSIS_CREATE_ICONS@
@CPACK_NSIS_CREATE_ICONS_EXTRA@ @CPACK_NSIS_CREATE_ICONS_EXTRA@
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe"
;Read a value from an InstallOptions INI file ;Read a value from an InstallOptions INI file
!insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State" !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
@ -717,7 +735,7 @@ Section "-Core installation"
Call ConditionalAddToRegistry Call ConditionalAddToRegistry
!insertmacro MUI_STARTMENU_WRITE_END !insertmacro MUI_STARTMENU_WRITE_END
detailPrint "Installing InspIRCd service..." detailPrint "Installing InspIRCd service..."
nsExec::Exec /TIMEOUT=30000 '"$INSTDIR\inspircd.exe" --installservice' nsExec::Exec /TIMEOUT=30000 '"$INSTDIR\inspircd.exe" --installservice'
@ -728,7 +746,7 @@ SectionEnd
Section "-Add to path" Section "-Add to path"
Push $INSTDIR\bin Push $INSTDIR\bin
StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath
StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0 StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
Call AddToPath Call AddToPath
doNotAddToPath: doNotAddToPath:
SectionEnd SectionEnd
@ -759,12 +777,12 @@ Function un.onInit
SetShellVarContext all SetShellVarContext all
;MessageBox MB_OK 'User "$0" is in the Power Users group' ;MessageBox MB_OK 'User "$0" is in the Power Users group'
Goto done Goto done
noLM: noLM:
;Get installation folder from registry if available ;Get installation folder from registry if available
done: done:
FunctionEnd FunctionEnd
;--- Add/Remove callback functions: --- ;--- Add/Remove callback functions: ---
@ -773,25 +791,25 @@ FunctionEnd
;List all of your components in following manner here. ;List all of your components in following manner here.
@CPACK_NSIS_COMPONENT_SECTION_LIST@ @CPACK_NSIS_COMPONENT_SECTION_LIST@
!macroend !macroend
Section -FinishComponents Section -FinishComponents
;Removes unselected components and writes component status to registry ;Removes unselected components and writes component status to registry
!insertmacro SectionList "FinishSection" !insertmacro SectionList "FinishSection"
!ifdef CPACK_NSIS_ADD_REMOVE !ifdef CPACK_NSIS_ADD_REMOVE
; Get the name of the installer executable ; Get the name of the installer executable
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1' System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
StrCpy $R3 $R0 StrCpy $R3 $R0
; Strip off the last 13 characters, to see if we have AddRemove.exe ; Strip off the last 13 characters, to see if we have AddRemove.exe
StrLen $R1 $R0 StrLen $R1 $R0
IntOp $R1 $R0 - 13 IntOp $R1 $R0 - 13
StrCpy $R2 $R0 13 $R1 StrCpy $R2 $R0 13 $R1
StrCmp $R2 "AddRemove.exe" addremove_installed StrCmp $R2 "AddRemove.exe" addremove_installed
; We're not running AddRemove.exe, so install it ; We're not running AddRemove.exe, so install it
CopyFiles $R3 $INSTDIR\AddRemove.exe CopyFiles $R3 $INSTDIR\AddRemove.exe
addremove_installed: addremove_installed:
!endif !endif
SectionEnd SectionEnd
@ -831,13 +849,13 @@ Section "Uninstall"
@CPACK_NSIS_DELETE_FILES@ @CPACK_NSIS_DELETE_FILES@
@CPACK_NSIS_DELETE_DIRECTORIES@ @CPACK_NSIS_DELETE_DIRECTORIES@
!ifdef CPACK_NSIS_ADD_REMOVE !ifdef CPACK_NSIS_ADD_REMOVE
;Remove the add/remove program ;Remove the add/remove program
Delete "$INSTDIR\AddRemove.exe" Delete "$INSTDIR\AddRemove.exe"
!endif !endif
;Remove the uninstaller itself. ;Remove the uninstaller itself.
Delete "$INSTDIR\Uninstall.exe" Delete "$INSTDIR\@CPACK_NSIS_UNINSTALL_NAME@.exe"
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
;Remove the installation directory if it is empty. ;Remove the installation directory if it is empty.
@ -848,23 +866,23 @@ Section "Uninstall"
; Removes all optional components ; Removes all optional components
!insertmacro SectionList "RemoveSection_CPack" !insertmacro SectionList "RemoveSection_CPack"
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
@CPACK_NSIS_DELETE_ICONS@ @CPACK_NSIS_DELETE_ICONS@
@CPACK_NSIS_DELETE_ICONS_EXTRA@ @CPACK_NSIS_DELETE_ICONS_EXTRA@
;Delete empty start menu parent directories ;Delete empty start menu parent directories
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
startMenuDeleteLoop: startMenuDeleteLoop:
ClearErrors ClearErrors
RMDir $MUI_TEMP RMDir $MUI_TEMP
GetFullPathName $MUI_TEMP "$MUI_TEMP\.." GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
IfErrors startMenuDeleteLoopDone IfErrors startMenuDeleteLoopDone
StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
startMenuDeleteLoopDone: startMenuDeleteLoopDone:
@ -873,17 +891,17 @@ Section "Uninstall"
StrCpy $MUI_TEMP "$START_MENU" StrCpy $MUI_TEMP "$START_MENU"
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
@CPACK_NSIS_DELETE_ICONS_EXTRA@ @CPACK_NSIS_DELETE_ICONS_EXTRA@
;Delete empty start menu parent directories ;Delete empty start menu parent directories
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
secondStartMenuDeleteLoop: secondStartMenuDeleteLoop:
ClearErrors ClearErrors
RMDir $MUI_TEMP RMDir $MUI_TEMP
GetFullPathName $MUI_TEMP "$MUI_TEMP\.." GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
IfErrors secondStartMenuDeleteLoopDone IfErrors secondStartMenuDeleteLoopDone
StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
secondStartMenuDeleteLoopDone: secondStartMenuDeleteLoopDone:
@ -908,18 +926,22 @@ SectionEnd
Function .onInit Function .onInit
StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "UninstallString" ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString"
StrCmp $0 "" inst StrCmp $0 "" inst
MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \ MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
"@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \ "@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \
IDYES uninst IDNO inst /SD IDYES IDYES uninst IDNO inst
Abort Abort
;Run the uninstaller ;Run the uninstaller
uninst: uninst:
ClearErrors ClearErrors
ExecWait '$0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file StrCpy $2 $0 1
StrCmp '"' $2 0 +3 ; checks if string is quoted (CPack before v3.20.6 did not quote it)
ExecWait '$0 /S'
Goto +2
ExecWait '"$0" /S'
IfErrors uninst_failed inst IfErrors uninst_failed inst
uninst_failed: uninst_failed:
@ -931,14 +953,14 @@ inst:
; Reads components status for registry ; Reads components status for registry
!insertmacro SectionList "InitSection" !insertmacro SectionList "InitSection"
; check to see if /D has been used to change ; check to see if /D has been used to change
; the install directory by comparing it to the ; the install directory by comparing it to the
; install directory that is expected to be the ; install directory that is expected to be the
; default ; default
StrCpy $IS_DEFAULT_INSTALLDIR 0 StrCpy $IS_DEFAULT_INSTALLDIR 0
StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2 StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2
StrCpy $IS_DEFAULT_INSTALLDIR 1 StrCpy $IS_DEFAULT_INSTALLDIR 1
StrCpy $SV_ALLUSERS "JustMe" StrCpy $SV_ALLUSERS "JustMe"
; if default install dir then change the default ; if default install dir then change the default
; if it is installed for JustMe ; if it is installed for JustMe
@ -961,7 +983,7 @@ inst:
;MessageBox MB_OK 'User "$0" is in the Power Users group' ;MessageBox MB_OK 'User "$0" is in the Power Users group'
StrCpy $SV_ALLUSERS "AllUsers" StrCpy $SV_ALLUSERS "AllUsers"
Goto done Goto done
noLM: noLM:
StrCpy $SV_ALLUSERS "AllUsers" StrCpy $SV_ALLUSERS "AllUsers"
;Get installation folder from registry if available ;Get installation folder from registry if available