Merge pull request #11440 from pzbitskiy/nsis-vc-redist

Check for VC 2008 redist package in Windows installer
This commit is contained in:
Thomas S Hatch 2014-03-24 15:39:30 -06:00
commit 3cbf31bd80

View File

@ -13,6 +13,8 @@
!include "LogicLib.nsh"
!include "FileFunc.nsh"
!include x64.nsh
Var Dialog
Var Label
Var MasterHost
@ -115,6 +117,18 @@ Function updateMinionConfig
FunctionEnd
Function MsiQueryProductState
!define INSTALLSTATE_DEFAULT "5"
Var /GLOBAL NeedVcRedist ; used as a return value
Pop $R0
StrCpy $NeedVcRedist "False"
System::Call "msi::MsiQueryProductStateA(t '$R0') i.r0"
StrCmp $0 ${INSTALLSTATE_DEFAULT} +2 0
StrCpy $NeedVcRedist "True"
FunctionEnd
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
@ -124,6 +138,37 @@ InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
; Check and install Visual C++ 2008 SP1 redist packages
; See http://blogs.msdn.com/b/astebner/archive/2009/01/29/9384143.aspx for more info
Section -Prerequisites
!define VC_REDIST_X64_GUID "{8220EEFE-38CD-377E-8595-13398D740ACE}"
!define VC_REDIST_X86_GUID "{9A25302D-30C0-39D9-BD6F-21E6EC160475}"
!define VC_REDIST_X64_URI "http://download.microsoft.com/download/d/2/4/d242c3fb-da5a-4542-ad66-f9661d0a8d19/vcredist_x64.exe"
!define VC_REDIST_X86_URI "http://download.microsoft.com/download/d/d/9/dd9a82d0-52ef-40db-8dab-795376989c03/vcredist_x86.exe"
Var /GLOBAL VcRedistGuid
Var /GLOBAL VcRedistUri
${If} ${RunningX64}
StrCpy $VcRedistGuid ${VC_REDIST_X64_GUID}
StrCpy $VcRedistUri ${VC_REDIST_X64_URI}
${Else}
StrCpy $VcRedistGuid ${VC_REDIST_X86_GUID}
StrCpy $VcRedistUri ${VC_REDIST_X86_URI}
${EndIf}
Push $VcRedistGuid
Call MsiQueryProductState
${If} $NeedVcRedist == "True"
NSISdl::download /TIMEOUT=30000 $VcRedistUri $TEMP\vcredist.exe
Pop $R0
StrCmp $R0 "success" +2
MessageBox MB_OK "VC redist package download failed: $R0" ; just report, do not break installation
Execwait '"$TEMP\vcredist.exe" /q'
${EndIf}
SectionEnd
Section "MainSection" SEC01
ExecWait "net stop salt-minion" ;stopping service before upgrading