1
0
Fork 0

move ConditionalAddToRegistry into macro to make the source more compact.

This commit is contained in:
Wilfried Goesgens 2017-05-23 11:59:40 +02:00
parent ca16705097
commit 8afdf85d0a
2 changed files with 33 additions and 80 deletions

View File

@ -0,0 +1,16 @@
Function ConditionalAddToRegistry
Pop $0
Pop $1
StrCmp "$0" "" ConditionalAddToRegistry_EmptyString
WriteRegStr SHCTX "${TRI_UNINSTALL_REG_PATH}" "$1" "$0"
;MessageBox MB_OK "Set Registry: '$1' to '$0'"
DetailPrint "Set install registry entry: '$1' to '$0'"
ConditionalAddToRegistry_EmptyString:
FunctionEnd
!Macro AddToRegistry Name Value
push "${Name}"
push "${Value}"
call ConditionalAddToRegistry
!macroend

View File

@ -85,6 +85,7 @@ SetCompressor @CPACK_NSIS_COMPRESSOR@
RequestExecutionLevel highest RequestExecutionLevel highest
!include "AddToPath.nsh" !include "AddToPath.nsh"
!include "AddToRegistry.nsh"
!include "WaitForService.nsh" !include "WaitForService.nsh"
@ -310,16 +311,6 @@ FunctionEnd
;# Utility Functions # ;# Utility Functions #
;########################################### ;###########################################
Function ConditionalAddToRegistry
Pop $0
Pop $1
StrCmp "$0" "" ConditionalAddToRegistry_EmptyString
WriteRegStr SHCTX "${TRI_UNINSTALL_REG_PATH}" "$1" "$0"
;MessageBox MB_OK "Set Registry: '$1' to '$0'"
DetailPrint "Set install registry entry: '$1' to '$0'"
ConditionalAddToRegistry_EmptyString:
FunctionEnd
;-------------------------------- ;--------------------------------
; Installation types ; Installation types
@CPACK_NSIS_INSTALLATION_TYPES@ @CPACK_NSIS_INSTALLATION_TYPES@
@ -457,46 +448,24 @@ noServiceToStop:
;Create uninstaller ;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe" WriteUninstaller "$INSTDIR\Uninstall.exe"
Push "DisplayName" !insertmacro AddToRegistry "DisplayName" "@CPACK_NSIS_DISPLAY_NAME@"
Push "@CPACK_NSIS_DISPLAY_NAME@" !insertmacro AddToRegistry "DisplayVersion" "@CPACK_PACKAGE_VERSION@"
Call ConditionalAddToRegistry !insertmacro AddToRegistry "Publisher" "@CPACK_PACKAGE_VENDOR@"
Push "DisplayVersion" !insertmacro AddToRegistry "UninstallString" "$INSTDIR\Uninstall.exe"
Push "@CPACK_PACKAGE_VERSION@" !insertmacro AddToRegistry "NoRepair" "1"
Call ConditionalAddToRegistry
Push "Publisher"
Push "@CPACK_PACKAGE_VENDOR@"
Call ConditionalAddToRegistry
Push "UninstallString"
Push "$INSTDIR\Uninstall.exe"
Call ConditionalAddToRegistry
Push "NoRepair"
Push "1"
Call ConditionalAddToRegistry
!ifdef CPACK_NSIS_ADD_REMOVE !ifdef CPACK_NSIS_ADD_REMOVE
;Create add/remove functionality ;Create add/remove functionality
Push "ModifyPath" !insertmacro AddToRegistry "ModifyPath" "$INSTDIR\AddRemove.exe"
Push "$INSTDIR\AddRemove.exe"
Call ConditionalAddToRegistry
!else !else
Push "NoModify" !insertmacro AddToRegistry "NoModify" "1"
Push "1"
Call ConditionalAddToRegistry
!endif !endif
; Optional registration ; Optional registration
Push "DisplayIcon" !insertmacro AddToRegistry "DisplayIcon" "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@" !insertmacro AddToRegistry "HelpLink" "@CPACK_NSIS_HELP_LINK@"
Call ConditionalAddToRegistry !insertmacro AddToRegistry "URLInfoAbout" "@CPACK_NSIS_URL_INFO_ABOUT@"
Push "HelpLink" !insertmacro AddToRegistry "Contact" "@CPACK_NSIS_CONTACT@"
Push "@CPACK_NSIS_HELP_LINK@"
Call ConditionalAddToRegistry
Push "URLInfoAbout"
Push "@CPACK_NSIS_URL_INFO_ABOUT@"
Call ConditionalAddToRegistry
Push "Contact"
Push "@CPACK_NSIS_CONTACT@"
Call ConditionalAddToRegistry
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
@ -514,21 +483,11 @@ noServiceToStop:
noDesktopIcon: noDesktopIcon:
; Write special uninstall registry entries ; Write special uninstall registry entries
Push "StartMenu" !insertmacro AddToRegistry "StartMenu" "$STARTMENU_FOLDER"
Push "$STARTMENU_FOLDER" !insertmacro AddToRegistry "DoNotAddToPath" "$DO_NOT_ADD_TO_PATH"
Call ConditionalAddToRegistry !insertmacro AddToRegistry "AddToPathAllUsers" "$ADD_TO_PATH_ALL_USERS"
Push "DoNotAddToPath" !insertmacro AddToRegistry "AddToPathCurrentUser" "$ADD_TO_PATH_CURRENT_USER"
Push "$DO_NOT_ADD_TO_PATH" !insertmacro AddToRegistry "InstallToDesktop" "$INSTALL_DESKTOP"
Call ConditionalAddToRegistry
Push "AddToPathAllUsers"
Push "$ADD_TO_PATH_ALL_USERS"
Call ConditionalAddToRegistry
Push "AddToPathCurrentUser"
Push "$ADD_TO_PATH_CURRENT_USER"
Call ConditionalAddToRegistry
Push "InstallToDesktop"
Push "$INSTALL_DESKTOP"
Call ConditionalAddToRegistry
!insertmacro MUI_STARTMENU_WRITE_END !insertmacro MUI_STARTMENU_WRITE_END
@ -781,28 +740,6 @@ SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Hallo"
;-------------------------------- ;--------------------------------
; determine admin versus local install ; determine admin versus local install
Function un.onInit Function un.onInit
; ClearErrors
; UserInfo::GetName
; IfErrors noLM
; Pop $0
; UserInfo::GetAccountType
; Pop $1
; StrCmp $1 "Admin" 0 +3
; SetShellVarContext all
; MessageBox MB_OK 'User "$0" is in the Admin group'
; Goto done
; StrCmp $1 "Power" 0 +3
; SetShellVarContext all
; MessageBox MB_OK 'User "$0" is in the Power Users group'
; Goto done
;
; noLM:
; ;Get installation folder from registry if available
;
; done:
; determine admin versus local install
; arango may be installed on diferent places ; arango may be installed on diferent places
; determine if the arango was installed for a local user ; determine if the arango was installed for a local user
${GetParameters} $R0 ${GetParameters} $R0