[8/9] msi: Also roll back changes made in PublishProduct.

Hans Leidekker hans at codeweavers.com
Fri Nov 4 07:28:10 CDT 2016


Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/msi/action.c | 57 +++++++++++++++++++++++++++++++------------------------
 1 file changed, 32 insertions(+), 25 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 34d1a25..751462b 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -145,6 +145,8 @@ static const WCHAR szUnpublishComponents[] =
     {'U','n','p','u','b','l','i','s','h', 'C','o','m','p','o','n','e','n','t','s',0};
 static const WCHAR szUnpublishFeatures[] =
     {'U','n','p','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
+static const WCHAR szUnpublishProduct[] =
+    {'U','n','p','u','b','l','i','s','h','P','r','o','d','u','c','t',0};
 static const WCHAR szUnregisterComPlus[] =
     {'U','n','r','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
 static const WCHAR szUnregisterTypeLibraries[] =
@@ -5283,28 +5285,10 @@ static UINT msi_unpublish_icons( MSIPACKAGE *package )
     return ERROR_SUCCESS;
 }
 
-static UINT msi_unpublish_product( MSIPACKAGE *package, const WCHAR *remove )
+static UINT ACTION_UnpublishProduct(MSIPACKAGE *package)
 {
-    static const WCHAR szUpgradeCode[] = {'U','p','g','r','a','d','e','C','o','d','e',0};
-    WCHAR *upgrade, **features;
-    BOOL full_uninstall = TRUE;
-    MSIFEATURE *feature;
+    WCHAR *upgrade;
     MSIPATCHINFO *patch;
-    UINT i;
-
-    LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
-    {
-        if (feature->Action == INSTALLSTATE_LOCAL) full_uninstall = FALSE;
-    }
-    features = msi_split_string( remove, ',' );
-    for (i = 0; features && features[i]; i++)
-    {
-        if (!strcmpW( features[i], szAll )) full_uninstall = TRUE;
-    }
-    msi_free(features);
-
-    if (!full_uninstall)
-        return ERROR_SUCCESS;
 
     MSIREG_DeleteProductKey(package->ProductCode);
     MSIREG_DeleteUserDataProductKey(package->ProductCode, package->Context);
@@ -5340,10 +5324,32 @@ static UINT msi_unpublish_product( MSIPACKAGE *package, const WCHAR *remove )
     return ERROR_SUCCESS;
 }
 
+static BOOL is_full_uninstall( MSIPACKAGE *package )
+{
+    WCHAR **features, *remove = msi_dup_property( package->db, szRemove );
+    MSIFEATURE *feature;
+    BOOL ret = TRUE;
+    UINT i;
+
+    LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
+    {
+        if (feature->Action == INSTALLSTATE_LOCAL) ret = FALSE;
+    }
+
+    features = msi_split_string( remove, ',' );
+    for (i = 0; features && features[i]; i++)
+    {
+        if (!strcmpW( features[i], szAll )) ret = TRUE;
+    }
+
+    msi_free(features);
+    msi_free(remove);
+    return ret;
+}
+
 static UINT ACTION_InstallFinalize(MSIPACKAGE *package)
 {
     UINT rc;
-    WCHAR *remove;
 
     /* first do the same as an InstallExecute */
     rc = execute_script(package, SCRIPT_INSTALL);
@@ -5355,9 +5361,9 @@ static UINT ACTION_InstallFinalize(MSIPACKAGE *package)
     if (rc != ERROR_SUCCESS)
         return rc;
 
-    remove = msi_dup_property(package->db, szRemove);
-    rc = msi_unpublish_product(package, remove);
-    msi_free(remove);
+    if (is_full_uninstall(package))
+        rc = ACTION_UnpublishProduct(package);
+
     return rc;
 }
 
@@ -7673,7 +7679,7 @@ StandardActions[] =
     { szProcessComponents, ACTION_ProcessComponents, szProcessComponents },
     { szPublishComponents, ACTION_PublishComponents, szUnpublishComponents },
     { szPublishFeatures, ACTION_PublishFeatures, szUnpublishFeatures },
-    { szPublishProduct, ACTION_PublishProduct, NULL },
+    { szPublishProduct, ACTION_PublishProduct, szUnpublishProduct },
     { szRegisterClassInfo, ACTION_RegisterClassInfo, szUnregisterClassInfo },
     { szRegisterComPlus, ACTION_RegisterComPlus, szUnregisterComPlus },
     { szRegisterExtensionInfo, ACTION_RegisterExtensionInfo, szUnregisterExtensionInfo },
@@ -7702,6 +7708,7 @@ StandardActions[] =
     { szStopServices, ACTION_StopServices, szStartServices },
     { szUnpublishComponents, ACTION_UnpublishComponents, szPublishComponents },
     { szUnpublishFeatures, ACTION_UnpublishFeatures, szPublishFeatures },
+    { szUnpublishProduct, ACTION_UnpublishProduct, NULL }, /* for rollback only */
     { szUnregisterClassInfo, ACTION_UnregisterClassInfo, szRegisterClassInfo },
     { szUnregisterComPlus, ACTION_UnregisterComPlus, szRegisterComPlus },
     { szUnregisterExtensionInfo, ACTION_UnregisterExtensionInfo, szRegisterExtensionInfo },
-- 
2.1.4




More information about the wine-patches mailing list