[msitools: 1/2] wixl: Properly handle empty GUID in Component nodes




commit f7e746effe6cdb1bd91d9db1d865bda12e2e17b3
Author: Hendrik Eckardt <hendrik eckardt gdata-adan de>
Date:   Thu Nov 19 17:27:53 2020 +0100

    wixl: Properly handle empty GUID in Component nodes
    
    It's permissible for a ComponentId to be null (by setting the GUID
    to an empty string). This results in Windows Installer ignoring the
    component in all future operations (patch/uninstall) after
    installing it once.
    
    Without this patch, wixl creates broken installer packages when
    specifying an empty GUID. This is because the string in the ComponentId
    column comes out as "{}". As a result, when attempting to uninstall
    the product, it is unregistered from the system but all its files
    (even those with normal GUIDs) are still there.

 tools/wixl/builder.vala | 2 ++
 tools/wixl/msi.vala     | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/tools/wixl/builder.vala b/tools/wixl/builder.vala
index 0a47101..55bb4b6 100644
--- a/tools/wixl/builder.vala
+++ b/tools/wixl/builder.vala
@@ -416,6 +416,8 @@ namespace Wixl {
 
             if (comp.Guid == "*")
                 uuid = uuid_from_name (comp.full_path (this));
+            else if (comp.Guid == "")
+                uuid = null; // unpatchable and not uninstallable component
             else
                 uuid = get_uuid (comp.Guid);
 
diff --git a/tools/wixl/msi.vala b/tools/wixl/msi.vala
index d3ba1a5..171272e 100644
--- a/tools/wixl/msi.vala
+++ b/tools/wixl/msi.vala
@@ -396,10 +396,10 @@ namespace Wixl {
             sql_insert = "INSERT INTO `Component` (`Component`, `ComponentId`, `Directory_`, `Attributes`, 
`KeyPath`) VALUES (?, ?, ?, ?, ?)";
         }
 
-        public void add (string Component, string ComponentId, string Directory, int Attributes, string? 
KeyPath = null) throws GLib.Error {
+        public void add (string Component, string? ComponentId, string Directory, int Attributes, string? 
KeyPath = null) throws GLib.Error {
             var rec = new Libmsi.Record (5);
             if (!rec.set_string (1, Component) ||
-                !rec.set_string (2, ComponentId) ||
+                (ComponentId != null && !rec.set_string (2, ComponentId)) ||
                 !rec.set_string (3, Directory) ||
                 !rec.set_int (4, Attributes) ||
                 !rec.set_string (5, KeyPath))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]