mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
CPack/NSIS: Sign the uninstaller
This commit is contained in:
5
Help/release/dev/cpack-sign-uninstaller.rst
Normal file
5
Help/release/dev/cpack-sign-uninstaller.rst
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
cpack-sign_uninstaller
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
* The :module:`CPackNSIS` module learned to sign the uninstaller
|
||||||
|
when using :variable:`CPACK_NSIS_SIGN_UNINSTALLER` variable.
|
||||||
@@ -133,6 +133,10 @@
|
|||||||
# "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake.html"
|
# "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake.html"
|
||||||
# "CMake Help" "https://cmake.org" "CMake Web Site")
|
# "CMake Help" "https://cmake.org" "CMake Web Site")
|
||||||
#
|
#
|
||||||
|
# .. variable:: CPACK_NSIS_SIGN_UNINSTALLER
|
||||||
|
#
|
||||||
|
# Specify a command to use for signing the uninstaller. The command will
|
||||||
|
# be invoked a path to the uninstaller as its only argument.
|
||||||
|
|
||||||
#FIXME we should put NSIS specific code here
|
#FIXME we should put NSIS specific code here
|
||||||
#FIXME but I'm not doing it because I'm not able to test it...
|
#FIXME but I'm not doing it because I'm not able to test it...
|
||||||
|
|||||||
@@ -29,6 +29,33 @@
|
|||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
;General
|
;General
|
||||||
|
!ifdef INNER
|
||||||
|
OutFile "$%TEMP%\tempinstaller.exe"
|
||||||
|
SetCompress off ; for speed
|
||||||
|
!else
|
||||||
|
; Call makensis again, defining INNER. This writes an installer for us which, when
|
||||||
|
; it is invoked, will just write the uninstaller to some location, and then exit.
|
||||||
|
; Be sure to substitute the name of this script here.
|
||||||
|
|
||||||
|
!system "$\"${NSISDIR}\makensis$\" /DINNER $\"@CPACK_TEMPORARY_DIRECTORY@/../project.nsi$\"" = 0
|
||||||
|
|
||||||
|
; So now run that installer we just created as %TEMP%\tempinstaller.exe. Since it
|
||||||
|
; calls quit the return value isn't zero.
|
||||||
|
|
||||||
|
!system "$%TEMP%\tempinstaller.exe" = 2
|
||||||
|
|
||||||
|
; That will have written an uninstaller binary for us. Now we sign it with your
|
||||||
|
; favourite code signing tool.
|
||||||
|
|
||||||
|
!tempfile INCEXIST
|
||||||
|
!system 'if exist "@CPACK_NSIS_SIGN_UNINSTALLER@" echo !define HAVE_SIGN_UNINST > "${INCEXIST}"'
|
||||||
|
!include "${INCEXIST}"
|
||||||
|
!delfile "${INCEXIST}"
|
||||||
|
!ifdef HAVE_SIGN_UNINST
|
||||||
|
!system '"@CPACK_NSIS_SIGN_UNINSTALLER@" "$%TEMP%\Uninstall.exe"' = 0
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Good. Now we can carry on writing the real installer.
|
||||||
|
|
||||||
;Name and file
|
;Name and file
|
||||||
Name "@CPACK_NSIS_PACKAGE_NAME@"
|
Name "@CPACK_NSIS_PACKAGE_NAME@"
|
||||||
@@ -36,6 +63,7 @@
|
|||||||
|
|
||||||
;Set compression
|
;Set compression
|
||||||
SetCompressor @CPACK_NSIS_COMPRESSOR@
|
SetCompressor @CPACK_NSIS_COMPRESSOR@
|
||||||
|
!endif
|
||||||
|
|
||||||
;Require administrator access
|
;Require administrator access
|
||||||
RequestExecutionLevel admin
|
RequestExecutionLevel admin
|
||||||
@@ -559,8 +587,10 @@ FunctionEnd
|
|||||||
!insertmacro MUI_PAGE_INSTFILES
|
!insertmacro MUI_PAGE_INSTFILES
|
||||||
!insertmacro MUI_PAGE_FINISH
|
!insertmacro MUI_PAGE_FINISH
|
||||||
|
|
||||||
|
!ifdef INNER
|
||||||
!insertmacro MUI_UNPAGE_CONFIRM
|
!insertmacro MUI_UNPAGE_CONFIRM
|
||||||
!insertmacro MUI_UNPAGE_INSTFILES
|
!insertmacro MUI_UNPAGE_INSTFILES
|
||||||
|
!endif
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
;Languages
|
;Languages
|
||||||
@@ -642,7 +672,10 @@ Section "-Core installation"
|
|||||||
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"
|
!ifndef INNER
|
||||||
|
; this packages the signed uninstaller
|
||||||
|
File "$%TEMP%\Uninstall.exe"
|
||||||
|
!endif
|
||||||
Push "DisplayName"
|
Push "DisplayName"
|
||||||
Push "@CPACK_NSIS_DISPLAY_NAME@"
|
Push "@CPACK_NSIS_DISPLAY_NAME@"
|
||||||
Call ConditionalAddToRegisty
|
Call ConditionalAddToRegisty
|
||||||
@@ -801,6 +834,7 @@ FunctionEnd
|
|||||||
;--------------------------------
|
;--------------------------------
|
||||||
;Uninstaller Section
|
;Uninstaller Section
|
||||||
|
|
||||||
|
!ifdef INNER
|
||||||
Section "Uninstall"
|
Section "Uninstall"
|
||||||
ReadRegStr $START_MENU SHCTX \
|
ReadRegStr $START_MENU SHCTX \
|
||||||
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu"
|
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu"
|
||||||
@@ -886,6 +920,7 @@ Section "Uninstall"
|
|||||||
Call un.RemoveFromPath
|
Call un.RemoveFromPath
|
||||||
doNotRemoveFromPath:
|
doNotRemoveFromPath:
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
!endif
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
; determine admin versus local install
|
; determine admin versus local install
|
||||||
@@ -898,6 +933,14 @@ SectionEnd
|
|||||||
; "Program Files" for AllUsers, "My Documents" for JustMe...
|
; "Program Files" for AllUsers, "My Documents" for JustMe...
|
||||||
|
|
||||||
Function .onInit
|
Function .onInit
|
||||||
|
!ifdef INNER
|
||||||
|
; If INNER is defined, then we aren't supposed to do anything except write out
|
||||||
|
; the installer. This is better than processing a command line option as it means
|
||||||
|
; this entire code path is not present in the final (real) installer.
|
||||||
|
|
||||||
|
WriteUninstaller "$%TEMP%\Uninstall.exe"
|
||||||
|
Quit ; just bail out quickly when running the "inner" installer
|
||||||
|
!endif
|
||||||
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_INSTALL_REGISTRY_KEY@" "UninstallString"
|
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString"
|
||||||
|
|||||||
Reference in New Issue
Block a user