diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2009-04-02 13:31:45 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2009-04-02 13:31:45 +0000 |
commit | e0371a4c142ae69d5420c3eed6118db4f6c35734 (patch) | |
tree | ced9e3f107f9f38ce21a75703389fb5ab26d4de1 /desktop/win32/source | |
parent | 5116a6c26d520683987542c3e680bd4317ea7da2 (diff) |
CWS-TOOLING: integrate CWS dv10
2009-03-10 11:09:48 +0100 dv r269257 : #158915# Check msi version before checking patches, better logging
2009-02-27 14:48:58 +0100 dv r268594 : #i99154# Added missing string, removed wrong svn flags
2009-02-26 16:07:25 +0100 dv r268531 : Removed superfluous file
2009-02-26 13:49:01 +0100 dv r268514 : CWS-TOOLING: rebase CWS dv10 to trunk@268395 (milestone: DEV300:m42)
2009-02-26 08:13:32 +0100 dv r268479 : #i86963# Listen to dispose events for xPackages
2009-02-12 15:40:06 +0100 dv r267668 : #i99154# Added missing string
2009-02-03 11:47:11 +0100 dv r267308 : #i73966# Ask for confirmation when removing an extension
2009-01-30 09:27:52 +0100 dv r267175 : #158915# Check for already installed patches to allow launching the setup in maintainance mode
Diffstat (limited to 'desktop/win32/source')
-rw-r--r-- | desktop/win32/source/setup/makefile.mk | 2 | ||||
-rw-r--r-- | desktop/win32/source/setup/setup.cpp | 106 | ||||
-rw-r--r-- | desktop/win32/source/setup/setup.hxx | 4 | ||||
-rw-r--r-- | desktop/win32/source/setup/setup_main.cxx | 6 |
4 files changed, 103 insertions, 15 deletions
diff --git a/desktop/win32/source/setup/makefile.mk b/desktop/win32/source/setup/makefile.mk index 5c8f471f0938..1453e896679f 100644 --- a/desktop/win32/source/setup/makefile.mk +++ b/desktop/win32/source/setup/makefile.mk @@ -75,7 +75,7 @@ LIBSALCPPRT= $(0) APP1NOSAL= TRUE APP1TARGET= loader2 -APP1STDLIBS= $(GDI32LIB) $(ADVAPI32LIB) $(SHELL32LIB) +APP1STDLIBS= $(GDI32LIB) $(ADVAPI32LIB) $(SHELL32LIB) $(MSILIB) .IF "$(COM)"!="GCC" APP1STDLIBS+= libcmt.lib .ENDIF diff --git a/desktop/win32/source/setup/setup.cpp b/desktop/win32/source/setup/setup.cpp index 2782a8de3025..d0619ab11963 100644 --- a/desktop/win32/source/setup/setup.cpp +++ b/desktop/win32/source/setup/setup.cpp @@ -44,7 +44,8 @@ #include <time.h> #include <mbctype.h> #include <locale.h> - +#include <Msiquery.h> +#include <MsiDefs.h> #include "strsafe.h" #include "setup.hxx" @@ -147,6 +148,7 @@ SetupAppX::SetupAppX() m_bRegNoMsoTypes = false; m_bRegAllMsoTypes = false; m_bIsMinorUpgrade = false; + m_bSupportsPatch = false; m_bIgnoreAlreadyRunning = false; } @@ -447,6 +449,21 @@ boolean SetupAppX::ReadProfile() } //-------------------------------------------------------------------------- +void SetupAppX::AddFileToPatchList( TCHAR* pPath, TCHAR* pFile ) +{ + if ( m_pPatchFiles == NULL ) + { + m_pPatchFiles = new TCHAR[ MAX_STR_LENGTH ]; + StringCchCopy( m_pPatchFiles, MAX_STR_LENGTH, TEXT("\"") ); + } + else + StringCchCat( m_pPatchFiles, MAX_STR_LENGTH, TEXT(";") ); + + StringCchCat( m_pPatchFiles, MAX_STR_LENGTH, pPath ); + StringCchCat( m_pPatchFiles, MAX_STR_LENGTH, pFile ); +} + +//-------------------------------------------------------------------------- boolean SetupAppX::GetPatches() { boolean bRet = true; @@ -475,19 +492,18 @@ boolean SetupAppX::GetPatches() if ( hFindPatches != INVALID_HANDLE_VALUE ) { - bool fNextFile = false; - m_pPatchFiles = new TCHAR[ MAX_STR_LENGTH ]; - StringCchCopy( m_pPatchFiles, MAX_STR_LENGTH, TEXT("\"") ); - StringCchCat( m_pPatchFiles, MAX_STR_LENGTH, pBaseDir ); - StringCchCat( m_pPatchFiles, MAX_STR_LENGTH, aFindFileData.cFileName ); + if ( ! IsPatchInstalled( pBaseDir, aFindFileData.cFileName ) ) + AddFileToPatchList( pBaseDir, aFindFileData.cFileName ); while ( FindNextFile( hFindPatches, &aFindFileData ) ) { - StringCchCat( m_pPatchFiles, MAX_STR_LENGTH, TEXT(";") ); - StringCchCat( m_pPatchFiles, MAX_STR_LENGTH, pBaseDir ); - StringCchCat( m_pPatchFiles, MAX_STR_LENGTH, aFindFileData.cFileName ); + if ( ! IsPatchInstalled( pBaseDir, aFindFileData.cFileName ) ) + AddFileToPatchList( pBaseDir, aFindFileData.cFileName ); } - StringCchCat( m_pPatchFiles, MAX_STR_LENGTH, TEXT("\"") ); + + if ( m_pPatchFiles != NULL ) + StringCchCat( m_pPatchFiles, MAX_STR_LENGTH, TEXT("\"") ); + FindClose( hFindPatches ); } } @@ -1175,6 +1191,10 @@ boolean SetupAppX::CheckVersion() Log( TEXT( " Found MSI version <%s>, no update needed\r\n" ), pMsiVersion ); bNeedUpdate = false; } + if ( aInfo.dwMajorVersion >= 3 ) + m_bSupportsPatch = true; + else + Log( TEXT("Warning: Patching not supported! MSI-Version <%s>\r\n"), pMsiVersion ); } } @@ -1492,9 +1512,15 @@ void SetupAppX::Log( LPCTSTR pMessage, LPCTSTR pText ) const _tsetlocale( LC_ALL, NULL ), _getmbcp() ); } if ( pText ) + { _ftprintf( m_pLogFile, pMessage, pText ); + OutputDebugStringFormat( pMessage, pText ); + } else + { _ftprintf( m_pLogFile, pMessage ); + OutputDebugStringFormat( pMessage ); + } fflush( m_pLogFile ); } @@ -1924,6 +1950,66 @@ LPTSTR SetupAppX::SetProdToAppTitle( LPCTSTR pProdName ) return m_pAppTitle; } + +//-------------------------------------------------------------------------- +boolean SetupAppX::IsPatchInstalled( TCHAR* pBaseDir, TCHAR* pFileName ) +{ + if ( !m_bSupportsPatch ) + return false; + + PMSIHANDLE hSummaryInfo; + int nLen = lstrlen( pBaseDir ) + lstrlen( pFileName ) + 1; + TCHAR *szDatabasePath = new TCHAR [ nLen ]; + TCHAR sBuf[80]; + + StringCchCopy( szDatabasePath, nLen, pBaseDir ); + StringCchCat( szDatabasePath, nLen, pFileName ); + + UINT nRet = MsiGetSummaryInformation( NULL, szDatabasePath, 0, &hSummaryInfo ); + + if ( nRet != ERROR_SUCCESS ) + { + StringCchPrintf( sBuf, 80, TEXT("ERROR: IsPatchInstalled: MsiGetSummaryInformation returned %u.\r\n"), nRet ); + Log( sBuf ); + return false; + } + + UINT uiDataType; + LPTSTR szPatchID = new TCHAR[ 64 ]; + DWORD cchValueBuf = 64; + nRet = MsiSummaryInfoGetProperty( hSummaryInfo, PID_REVNUMBER, &uiDataType, NULL, NULL, szPatchID, &cchValueBuf ); + + if ( nRet != ERROR_SUCCESS ) + { + StringCchPrintf( sBuf, 80, TEXT("ERROR: IsPatchInstalled: MsiSummaryInfoGetProperty returned %u.\r\n"), nRet ); + Log( sBuf ); + return false; + } + + nRet = MsiGetPatchInfo( szPatchID, INSTALLPROPERTY_LOCALPACKAGE, NULL, NULL ); + + StringCchPrintf( sBuf, 80, TEXT(" GetPatchInfo for (%s) returned (%u)\r\n"), szPatchID, nRet ); + Log( sBuf ); + + delete []szPatchID; + + if ( nRet == ERROR_BAD_CONFIGURATION ) + return false; + else if ( nRet == ERROR_INVALID_PARAMETER ) + return false; + else if ( nRet == ERROR_MORE_DATA ) + return true; + else if ( nRet == ERROR_SUCCESS ) + return true; + else if ( nRet == ERROR_UNKNOWN_PRODUCT ) + return false; + else if ( nRet == ERROR_UNKNOWN_PROPERTY ) + return false; + else return false; + + return false; +} + //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- LanguageDataX::LanguageDataX( LPTSTR pData ) diff --git a/desktop/win32/source/setup/setup.hxx b/desktop/win32/source/setup/setup.hxx index 7e651df5dec7..d74947fa47f2 100644 --- a/desktop/win32/source/setup/setup.hxx +++ b/desktop/win32/source/setup/setup.hxx @@ -93,6 +93,7 @@ class SetupAppX : public SetupApp boolean m_bRegNoMsoTypes :1; boolean m_bRegAllMsoTypes :1; boolean m_bIsMinorUpgrade :1; + boolean m_bSupportsPatch :1; FILE *m_pLogFile; @@ -125,7 +126,8 @@ private: boolean InstallMsi( LPCTSTR pInstaller ); boolean IsTerminalServerInstalled() const; - + void AddFileToPatchList( TCHAR* pPath, TCHAR* pFile ); + boolean IsPatchInstalled( TCHAR* pBaseDir, TCHAR* pFileName ); public: SetupAppX(); ~SetupAppX(); diff --git a/desktop/win32/source/setup/setup_main.cxx b/desktop/win32/source/setup/setup_main.cxx index 24b542a17e8b..b8b54c8f7550 100644 --- a/desktop/win32/source/setup/setup_main.cxx +++ b/desktop/win32/source/setup/setup_main.cxx @@ -111,13 +111,13 @@ extern "C" int __stdcall WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, int ) if ( ! pSetup->ReadProfile() ) throw pSetup->GetError(); + if ( ! pSetup->CheckVersion() ) + throw pSetup->GetError(); + if ( ! pSetup->IsAdminInstall() ) if ( ! pSetup->GetPatches() ) throw pSetup->GetError(); - if ( ! pSetup->CheckVersion() ) - throw pSetup->GetError(); - // CheckForUpgrade() has to be called after calling GetPatches()! if ( ! pSetup->CheckForUpgrade() ) throw pSetup->GetError(); |