From 283a131f4a1bce6e826496ae3226e125fc73d2ce Mon Sep 17 00:00:00 2001 From: Dirk Voelzke Date: Thu, 3 Dec 2009 12:35:08 +0100 Subject: native273:#i106809# Use vcredist*.exe instead of merge modules --- desktop/win32/source/setup/setup.cpp | 114 ++++++++++++++++++++++++++++++ desktop/win32/source/setup/setup.hxx | 4 +- desktop/win32/source/setup/setup_main.cxx | 3 + desktop/win32/source/setup/setup_main.hxx | 1 + 4 files changed, 121 insertions(+), 1 deletion(-) (limited to 'desktop/win32') diff --git a/desktop/win32/source/setup/setup.cpp b/desktop/win32/source/setup/setup.cpp index af50d912ef..23ba22e049 100644 --- a/desktop/win32/source/setup/setup.cpp +++ b/desktop/win32/source/setup/setup.cpp @@ -76,6 +76,7 @@ #define PARAM_PATCH TEXT( " /update " ) #define PARAM_REG_ALL_MSO_TYPES TEXT( "REGISTER_ALL_MSO_TYPES=1 " ) #define PARAM_REG_NO_MSO_TYPES TEXT( "REGISTER_NO_MSO_TYPES=1 " ) +#define PARAM_SILENTINSTALL TEXT( " /QB" ) #define PARAM_RUNNING TEXT( "ignore_running" ) #define CMDLN_REG_ALL_MSO_TYPES TEXT( "msoreg=1" ) @@ -85,6 +86,11 @@ #define ADVAPI32_DLL TEXT( "advapi32.dll" ) #define PROFILE_NAME TEXT( "setup.ini" ) +#define RUNTIME_X64_NAME TEXT( "redist\\vcredist_x64.exe" ) +#define RUNTIME_X86_NAME TEXT( "redist\\vcredist_x86.exe" ) +#define PRODUCTCODE_X86 TEXT( "{E503B4BF-F7BB-3D5F-8BC8-F694B1CFF942}" ) +#define PRODUCTCODE_X64 TEXT( "{350AA351-21FA-3270-8B7A-835434E766AD}" ) + #define MSIAPI_DllGetVersion "DllGetVersion" #define ADVAPI32API_CheckTokenMembership "CheckTokenMembership" @@ -1896,6 +1902,114 @@ boolean SetupAppX::IsPatchInstalled( TCHAR* pBaseDir, TCHAR* pFileName ) return false; } +//-------------------------------------------------------------------------- +boolean SetupAppX::InstallRuntimes( TCHAR *sProductCode, TCHAR *sRuntimePath ) +{ + INSTALLSTATE nRet = MsiQueryProductState( sProductCode ); + OutputDebugStringFormat( TEXT( "MsiQueryProductState returned <%d>\r\n" ), nRet ); + if ( nRet == INSTALLSTATE_DEFAULT ) + return true; + + Log( TEXT( " Will install runtime <%s>\r\n" ), sRuntimePath ); + OutputDebugStringFormat( TEXT( " Will install runtime <%s>\r\n" ), sRuntimePath ); + + STARTUPINFO aSUI; + PROCESS_INFORMATION aPI; + + ZeroMemory( (void*)&aPI, sizeof( PROCESS_INFORMATION ) ); + ZeroMemory( (void*)&aSUI, sizeof( STARTUPINFO ) ); + + aSUI.cb = sizeof(STARTUPINFO); + aSUI.dwFlags = STARTF_USESHOWWINDOW; + aSUI.wShowWindow = SW_SHOW; + + DWORD nCmdLineLength = lstrlen( sRuntimePath ) + lstrlen( PARAM_SILENTINSTALL ) + 2; + TCHAR *sCmdLine = new TCHAR[ nCmdLineLength ]; + + if ( FAILED( StringCchCopy( sCmdLine, nCmdLineLength, sRuntimePath ) ) || + FAILED( StringCchCat( sCmdLine, nCmdLineLength, PARAM_SILENTINSTALL ) ) ) + { + delete [] sCmdLine; + SetError( ERROR_INSTALL_FAILURE ); + return false; + } + + if ( !WIN::CreateProcess( NULL, sCmdLine, NULL, NULL, FALSE, + CREATE_DEFAULT_ERROR_MODE, NULL, NULL, + &aSUI, &aPI ) ) + { + Log( TEXT( "ERROR: Could not create process %s.\r\n" ), sCmdLine ); + SetError( WIN::GetLastError() ); + delete [] sCmdLine; + return false; + } + + DWORD nResult = WaitForProcess( aPI.hProcess ); + bool bRet = true; + + if( ERROR_SUCCESS != nResult ) + { + Log( TEXT( "ERROR: While waiting for %s.\r\n" ), sCmdLine ); + SetError( nResult ); + bRet = false; + } + else + { + GetExitCodeProcess( aPI.hProcess, &nResult ); + SetError( nResult ); + + if ( nResult != ERROR_SUCCESS ) + { + TCHAR sBuf[80]; + StringCchPrintf( sBuf, 80, TEXT("Warning: install runtime returned %u.\r\n"), nResult ); + Log( sBuf ); + } + else + Log( TEXT( " Installation of runtime completed successfully.\r\n" ) ); + } + + CloseHandle( aPI.hProcess ); + + delete [] sCmdLine; + + return bRet; +} + +//-------------------------------------------------------------------------- +boolean SetupAppX::InstallRuntimes() +{ + TCHAR *sRuntimePath = 0; + SYSTEM_INFO siSysInfo; + + GetNativeSystemInfo(&siSysInfo); + + OutputDebugStringFormat( TEXT( "found architecture<%d>\r\n" ), siSysInfo.wProcessorArchitecture ); + + if ( siSysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ) + { + if ( GetPathToFile( RUNTIME_X64_NAME, &sRuntimePath ) ) + InstallRuntimes( PRODUCTCODE_X64, sRuntimePath ); + else + Log( TEXT( "ERROR: no installer for x64 runtime libraries found!" ) ); + + if ( sRuntimePath ) + { + delete [] sRuntimePath; + sRuntimePath = 0; + } + } + + if ( GetPathToFile( RUNTIME_X86_NAME, &sRuntimePath ) ) + InstallRuntimes( PRODUCTCODE_X86, sRuntimePath ); + else + Log( TEXT( "ERROR: no installer for x86 runtime libraries found!" ) ); + + if ( sRuntimePath ) + delete [] sRuntimePath; + + return true; +} + //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- LanguageDataX::LanguageDataX( LPTSTR pData ) diff --git a/desktop/win32/source/setup/setup.hxx b/desktop/win32/source/setup/setup.hxx index 1393fbd326..06caa87de6 100644 --- a/desktop/win32/source/setup/setup.hxx +++ b/desktop/win32/source/setup/setup.hxx @@ -119,12 +119,13 @@ private: LPTSTR *pNext, boolean bStripQuotes = false ); boolean IsAdmin(); - boolean GetCommandLine(); boolean IsTerminalServerInstalled() const; void AddFileToPatchList( TCHAR* pPath, TCHAR* pFile ); boolean IsPatchInstalled( TCHAR* pBaseDir, TCHAR* pFileName ); + boolean InstallRuntimes( TCHAR* pProductCode, TCHAR* pFileName ); + public: SetupAppX(); ~SetupAppX(); @@ -136,6 +137,7 @@ public: virtual boolean ChooseLanguage( long& rLanguage ); virtual boolean CheckVersion(); virtual boolean CheckForUpgrade(); + virtual boolean InstallRuntimes(); virtual boolean Install( long nLanguage ); virtual UINT GetError() const; diff --git a/desktop/win32/source/setup/setup_main.cxx b/desktop/win32/source/setup/setup_main.cxx index 28fc251ea7..37acc1e665 100644 --- a/desktop/win32/source/setup/setup_main.cxx +++ b/desktop/win32/source/setup/setup_main.cxx @@ -124,6 +124,9 @@ extern "C" int __stdcall WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, int ) if ( ! pSetup->ChooseLanguage( nLanguage ) ) throw pSetup->GetError(); + if ( ! pSetup->InstallRuntimes() ) + throw pSetup->GetError(); + if ( ! pSetup->Install( nLanguage ) ) throw pSetup->GetError(); } diff --git a/desktop/win32/source/setup/setup_main.hxx b/desktop/win32/source/setup/setup_main.hxx index 5366dcf825..4e016768ee 100644 --- a/desktop/win32/source/setup/setup_main.hxx +++ b/desktop/win32/source/setup/setup_main.hxx @@ -53,6 +53,7 @@ public: virtual boolean ChooseLanguage( long& rLanguage ) = 0; virtual boolean CheckVersion() = 0; virtual boolean CheckForUpgrade() = 0; + virtual boolean InstallRuntimes() = 0; virtual boolean Install( long nLanguage ) = 0; virtual UINT GetError() const = 0; -- cgit v1.2.3