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

Alexandre Julliard julliard at winehq.org
Tue Jun 19 14:52:02 CDT 2018


Module: wine
Branch: master
Commit: 21836b79dd0acbd16f802f7364c070e1004e48ea
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=21836b79dd0acbd16f802f7364c070e1004e48ea

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Tue Jun 19 12:02:48 2018 +0200

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

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msi/action.c  | 46 +++++++++++++++++++++++++++++++++++++++++-----
 dlls/msi/msipriv.h |  1 +
 dlls/msi/package.c |  4 ++--
 3 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 74917af..9d216ab 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -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;
     }
 
+    rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
+                               &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 (!msi_check_publish(package))
+    if (!republish && !msi_check_publish(package))
+    {
+        if (hukey)
+            RegCloseKey(hukey);
         return ERROR_SUCCESS;
+    }
 
-    rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
-                               &hukey, TRUE);
-    if (rc != ERROR_SUCCESS)
-        goto end;
+    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);
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index c88f1d9..8043d0a 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -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 */
 
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index c50f9e3..c423bbf 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -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 );




More information about the wine-cvs mailing list