Commit 2d1f1500 authored by Ladislav Láska's avatar Ladislav Láska
Browse files

Implemented registry view setting in CPack NSIS template.

parent 6e7ff52a
Pipeline #221078 waiting for manual action with stages
in 3 minutes and 17 seconds
......@@ -580,6 +580,10 @@ if(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
endif()
if(CPACK_NSIS_ENABLE_UNINSTALL_DONT_CHECK_32BIT)
set(CPACK_NSIS_ENABLE_UNINSTALL_DONT_CHECK_32BIT ON)
endif()
if(CPACK_NSIS_MODIFY_PATH)
set(CPACK_NSIS_MODIFY_PATH ON)
endif()
......@@ -604,6 +608,15 @@ else()
endif()
_cpack_set_default(CPACK_NSIS_INSTALL_ROOT "${__cpack_root_default}")
# Set registry view to the proper 32bit or 64bit version. Project can override
# the default if necessary.
if("x${__cpack_system_name}" STREQUAL "xwin64")
set(__cpack_registry_view 64)
else()
set(__cpack_registry_view 32)
endif()
_cpack_set_default(CPACK_NSIS_REGISTRY_VIEW ${__cpack_registry_view})
# <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
_cpack_set_default(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
......
......@@ -79,6 +79,7 @@ Var AR_RegFlags
ClearErrors
;Reading component status from registry
SetRegView @CPACK_NSIS_REGISTRY_VIEW@
ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed"
IfErrors "default_${SecName}"
;Status will stay default if registry value not found
......@@ -490,6 +491,7 @@ FunctionEnd
Function ConditionalAddToRegisty
Pop $0
Pop $1
SetRegView @CPACK_NSIS_REGISTRY_VIEW@
StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" \
"$1" "$0"
......@@ -647,6 +649,7 @@ Section "-Core installation"
@CPACK_NSIS_FULL_INSTALL@
;Store installation folder
SetRegView @CPACK_NSIS_REGISTRY_VIEW@
WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
;Create uninstaller
......@@ -810,6 +813,7 @@ FunctionEnd
;Uninstaller Section
Section "Uninstall"
SetRegView @CPACK_NSIS_REGISTRY_VIEW@
ReadRegStr $START_MENU SHCTX \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu"
;MessageBox MB_OK "Start menu is in: $START_MENU"
......@@ -906,11 +910,25 @@ SectionEnd
; "Program Files" for AllUsers, "My Documents" for JustMe...
Function .onInit
; If we need to check for uninstaller, check the native key first. If that
; isn't present, optionally also check the 32bit key, due to a bug where previous
; versions of the NSIS script installed into the 32bit registry view on 64bit
; machines.
StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst
SetRegView @CPACK_NSIS_REGISTRY_VIEW@
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString"
StrCmp $0 "" inst
StrCmp $0 "" inst ask_uninstaller
check_32bit_uninstaller:
StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_DONT_CHECK_32BIT@" "ON" 0 inst
SetRegView 32
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString"
SetRegView @CPACK_NSIS_REGISTRY_VIEW@
StrCmp $0 "" inst ask_uninstaller
;Uninstaller was found. Ask the user to run it.
ask_uninstaller:
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?" \
/SD IDYES IDYES uninst IDNO inst
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment