Skip to content

Commit 74196b8

Browse files
winesynclearn-more
authored andcommitted
[WINESYNC] msi: Re-publish product if previous installation with different package is detected.
Signed-off-by: Piotr Caban <[email protected]> Signed-off-by: Hans Leidekker <[email protected]> Signed-off-by: Alexandre Julliard <[email protected]> wine commit id 21836b79dd0acbd16f802f7364c070e1004e48ea by Piotr Caban <[email protected]>
1 parent da84836 commit 74196b8

File tree

3 files changed

+44
-7
lines changed

3 files changed

+44
-7
lines changed

dll/win32/msi/action.c

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4480,6 +4480,7 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
44804480
UINT rc;
44814481
HKEY hukey = NULL, hudkey = NULL;
44824482
MSIRECORD *uirow;
4483+
BOOL republish = FALSE;
44834484

44844485
if (!list_empty(&package->patches))
44854486
{
@@ -4488,14 +4489,49 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
44884489
goto end;
44894490
}
44904491

4492+
rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
4493+
&hukey, FALSE);
4494+
if (rc == ERROR_SUCCESS)
4495+
{
4496+
WCHAR *package_code;
4497+
4498+
package_code = msi_reg_get_val_str(hukey, INSTALLPROPERTY_PACKAGECODEW);
4499+
if (package_code)
4500+
{
4501+
WCHAR *guid;
4502+
4503+
guid = msi_get_package_code(package->db);
4504+
if (guid)
4505+
{
4506+
WCHAR packed[SQUASHED_GUID_SIZE];
4507+
4508+
squash_guid(guid, packed);
4509+
msi_free(guid);
4510+
if (!strcmpW(packed, package_code))
4511+
{
4512+
TRACE("re-publishing product - new package\n");
4513+
republish = TRUE;
4514+
}
4515+
}
4516+
msi_free(package_code);
4517+
}
4518+
}
4519+
44914520
/* FIXME: also need to publish if the product is in advertise mode */
4492-
if (!msi_check_publish(package))
4521+
if (!republish && !msi_check_publish(package))
4522+
{
4523+
if (hukey)
4524+
RegCloseKey(hukey);
44934525
return ERROR_SUCCESS;
4526+
}
44944527

4495-
rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
4496-
&hukey, TRUE);
4497-
if (rc != ERROR_SUCCESS)
4498-
goto end;
4528+
if (!hukey)
4529+
{
4530+
rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
4531+
&hukey, TRUE);
4532+
if (rc != ERROR_SUCCESS)
4533+
goto end;
4534+
}
44994535

45004536
rc = MSIREG_OpenUserDataProductKey(package->ProductCode, package->Context,
45014537
NULL, &hudkey, TRUE);

dll/win32/msi/msipriv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ extern UINT msi_set_original_database_property(MSIDATABASE *, const WCHAR *) DEC
10491049
extern WCHAR *msi_get_error_message(MSIDATABASE *, int) DECLSPEC_HIDDEN;
10501050
extern UINT msi_strncpyWtoA(const WCHAR *str, int len, char *buf, DWORD *sz, BOOL remote) DECLSPEC_HIDDEN;
10511051
extern UINT msi_strncpyW(const WCHAR *str, int len, WCHAR *buf, DWORD *sz) DECLSPEC_HIDDEN;
1052+
extern WCHAR *msi_get_package_code(MSIDATABASE *db) DECLSPEC_HIDDEN;
10521053

10531054
/* media */
10541055

dll/win32/msi/package.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ static UINT get_registered_local_package( const WCHAR *product, const WCHAR *pac
13851385
return r;
13861386
}
13871387

1388-
static WCHAR *get_package_code( MSIDATABASE *db )
1388+
WCHAR *msi_get_package_code( MSIDATABASE *db )
13891389
{
13901390
WCHAR *ret;
13911391
MSISUMMARYINFO *si;
@@ -1423,7 +1423,7 @@ static UINT get_local_package( const WCHAR *filename, WCHAR *localfile )
14231423
msiobj_release( &db->hdr );
14241424
return ERROR_INSTALL_PACKAGE_INVALID;
14251425
}
1426-
if (!(package_code = get_package_code( db )))
1426+
if (!(package_code = msi_get_package_code( db )))
14271427
{
14281428
msi_free( product_code );
14291429
msiobj_release( &db->hdr );

0 commit comments

Comments
 (0)