summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Voelzke <dv@openoffice.org>2009-12-03 12:35:08 +0100
committerDirk Voelzke <dv@openoffice.org>2009-12-03 12:35:08 +0100
commit283a131f4a1bce6e826496ae3226e125fc73d2ce (patch)
tree499cc1a6ea954760937e88d0d0e688f299267d5f
parentd81fd860bdde52c728b481759e07f84d249f6d84 (diff)
native273:#i106809# Use vcredist*.exe instead of merge modules
-rw-r--r--desktop/win32/source/setup/setup.cpp114
-rw-r--r--desktop/win32/source/setup/setup.hxx4
-rw-r--r--desktop/win32/source/setup/setup_main.cxx3
-rw-r--r--desktop/win32/source/setup/setup_main.hxx1
4 files changed, 121 insertions, 1 deletions
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"
@@ -1897,6 +1903,114 @@ boolean SetupAppX::IsPatchInstalled( TCHAR* pBaseDir, TCHAR* pFileName )
}
//--------------------------------------------------------------------------
+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;