msi: Re-publish product if previous installation with different package is detected.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2018-06-19 12:02:48 +02:00 committed by Alexandre Julliard
parent 6dc49e4b68
commit 21836b79dd
3 changed files with 46 additions and 9 deletions

View File

@ -4473,6 +4473,7 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
UINT rc;
HKEY hukey = NULL, hudkey = NULL;
MSIRECORD *uirow;
BOOL republish = FALSE;
if (!list_empty(&package->patches))
{
@ -4481,14 +4482,49 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
goto end;
}
/* FIXME: also need to publish if the product is in advertise mode */
if (!msi_check_publish(package))
return ERROR_SUCCESS;
rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
&hukey, TRUE);
if (rc != ERROR_SUCCESS)
goto end;
&hukey, FALSE);
if (rc == ERROR_SUCCESS)
{
WCHAR *package_code;
package_code = msi_reg_get_val_str(hukey, INSTALLPROPERTY_PACKAGECODEW);
if (package_code)
{
WCHAR *guid;
guid = msi_get_package_code(package->db);
if (guid)
{
WCHAR packed[SQUASHED_GUID_SIZE];
squash_guid(guid, packed);
msi_free(guid);
if (!strcmpW(packed, package_code))
{
TRACE("re-publishing product - new package\n");
republish = TRUE;
}
}
msi_free(package_code);
}
}
/* FIXME: also need to publish if the product is in advertise mode */
if (!republish && !msi_check_publish(package))
{
if (hukey)
RegCloseKey(hukey);
return ERROR_SUCCESS;
}
if (!hukey)
{
rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
&hukey, TRUE);
if (rc != ERROR_SUCCESS)
goto end;
}
rc = MSIREG_OpenUserDataProductKey(package->ProductCode, package->Context,
NULL, &hudkey, TRUE);

View File

@ -1048,6 +1048,7 @@ extern UINT msi_set_original_database_property(MSIDATABASE *, const WCHAR *) DEC
extern WCHAR *msi_get_error_message(MSIDATABASE *, int) DECLSPEC_HIDDEN;
extern UINT msi_strncpyWtoA(const WCHAR *str, int len, char *buf, DWORD *sz, BOOL remote) DECLSPEC_HIDDEN;
extern UINT msi_strncpyW(const WCHAR *str, int len, WCHAR *buf, DWORD *sz) DECLSPEC_HIDDEN;
extern WCHAR *msi_get_package_code(MSIDATABASE *db) DECLSPEC_HIDDEN;
/* media */

View File

@ -1385,7 +1385,7 @@ done:
return r;
}
static WCHAR *get_package_code( MSIDATABASE *db )
WCHAR *msi_get_package_code( MSIDATABASE *db )
{
WCHAR *ret;
MSISUMMARYINFO *si;
@ -1423,7 +1423,7 @@ static UINT get_local_package( const WCHAR *filename, WCHAR *localfile )
msiobj_release( &db->hdr );
return ERROR_INSTALL_PACKAGE_INVALID;
}
if (!(package_code = get_package_code( db )))
if (!(package_code = msi_get_package_code( db )))
{
msi_free( product_code );
msiobj_release( &db->hdr );