[msitools] wixl: reorganize full_path, add the key element to the stable UUID



commit 6722623d62a9bb0e13c427fd677a79368aeefe9a
Author: Paolo Bonzini <pbonzini redhat com>
Date:   Fri Jan 25 09:33:25 2013 +0100

    wixl: reorganize full_path, add the key element to the stable UUID
    
    Call the resolver from the override of WixElementRef.
    Override in WixComponent, making it look at the key component.
    Add a new method to fetch the name part from a <File> or
    <RegistryValue> element.

 tests/wixl.at       |    6 +++---
 tools/wixl/wix.vala |   38 ++++++++++++++++++++++++++++----------
 2 files changed, 31 insertions(+), 13 deletions(-)
---
diff --git a/tests/wixl.at b/tests/wixl.at
index c28cc78..a773d13 100644
--- a/tests/wixl.at
+++ b/tests/wixl.at
@@ -35,9 +35,9 @@ AT_WIXLDATA([Manual.pdf])
 AT_CHECK_WIXL([-o out.msi ComponentGUID.wxs], [0], [ignore], [ignore])
 # FIXME: add tons of tests on out.msi
 AT_CHECK([msiinfo export -s out.msi Component | sort | grep INSERT], [0],
-[INSERT INTO `Component` (`Component`, `ComponentId`, `Directory_`, `Attributes`, `KeyPath`) VALUES ('MainExecutable', '{8C320F7C-C521-5B19-A3C5-AF2B2ECEE71E}', 'INSTALLDIR', 0, 'FoobarEXE')
-INSERT INTO `Component` (`Component`, `ComponentId`, `Directory_`, `Attributes`, `KeyPath`) VALUES ('Manual', '{BAEE488E-70FF-566B-8A74-FE3107FDBDE2}', 'INSTALLDIR', 0, 'Manual')
-INSERT INTO `Component` (`Component`, `ComponentId`, `Directory_`, `Attributes`, `KeyPath`) VALUES ('ProgramMenuDir', '{F9F7F81C-5E64-5B7C-8018-FAF096969B88}', 'ProgramMenuDir', 4, 'reg5453B5C95074EA6F633E6D36318AFBF7')
+[INSERT INTO `Component` (`Component`, `ComponentId`, `Directory_`, `Attributes`, `KeyPath`) VALUES ('MainExecutable', '{E92F36A4-7332-5803-B56D-B30AED211451}', 'INSTALLDIR', 0, 'FoobarEXE')
+INSERT INTO `Component` (`Component`, `ComponentId`, `Directory_`, `Attributes`, `KeyPath`) VALUES ('Manual', '{E44FE0D4-A612-50BF-B231-0662EB694E2F}', 'INSTALLDIR', 0, 'Manual')
+INSERT INTO `Component` (`Component`, `ComponentId`, `Directory_`, `Attributes`, `KeyPath`) VALUES ('ProgramMenuDir', '{6B979E1B-8F32-5150-AA04-6D7B8BCB1614}', 'ProgramMenuDir', 4, 'reg5453B5C95074EA6F633E6D36318AFBF7')
 ])
 AT_CLEANUP
 
diff --git a/tools/wixl/wix.vala b/tools/wixl/wix.vala
index a7cf3c9..a041996 100644
--- a/tools/wixl/wix.vala
+++ b/tools/wixl/wix.vala
@@ -149,16 +149,9 @@ namespace Wixl {
             return array;
         }
 
-        public string full_path (WixResolver r) throws GLib.Error {
-            WixDirectory dir = null;
-
-            if (parent != null && parent is WixDirectory)
-                dir = this.parent as WixDirectory;
-            else if (parent != null && parent is WixDirectoryRef)
-                dir = r.resolve<WixDirectory> (this.parent);
-
-            if (dir != null)
-                return dir.full_path (r) + "/" + this.Id;
+        public virtual string full_path (WixResolver r) throws GLib.Error {
+            if (parent != null && (parent is WixDirectory || parent is WixDirectoryRef))
+                return parent.full_path (r) + "/" + this.Id;
             else
                 return this.Id;
         }
@@ -398,6 +391,10 @@ namespace Wixl {
 
     public abstract class WixKeyElement: WixElement {
         public string KeyPath { get; set; }
+
+        public virtual string path_name () throws GLib.Error {
+            throw new Wixl.Error.FAILED("this key path does not support generating a component GUID");
+        }
     }
 
     public class WixFile: WixKeyElement {
@@ -413,6 +410,10 @@ namespace Wixl {
 
         public File file;
 
+        public override string path_name () throws GLib.Error {
+            return Name;
+        }
+
         public override void accept (WixNodeVisitor visitor) throws GLib.Error {
             base.accept (visitor);
             visitor.visit_file (this);
@@ -430,6 +431,10 @@ namespace Wixl {
         public string Value { get; set; }
         public string Name { get; set; }
 
+        public override string path_name () throws GLib.Error {
+            return Root + "/" + Key;
+        }
+
         public override void accept (WixNodeVisitor visitor) throws GLib.Error {
             visitor.visit_registry_value (this);
         }
@@ -999,6 +1004,14 @@ namespace Wixl {
             base.accept (visitor);
             visitor.visit_component (this, VisitState.LEAVE);
         }
+
+        public override string full_path (WixResolver r) throws GLib.Error {
+            if (key == null)
+                throw new Wixl.Error.FAILED("a child is needed to generate a component GUID");
+
+            return parent.full_path (r) + "/" + key.path_name ();
+        }
+
     }
 
     public class WixDirectory: WixElement {
@@ -1027,6 +1040,11 @@ namespace Wixl {
         //     // FIXME vala: class init/construct fails, construct fails...
         //     ref_type = typeof (G);
         // }
+
+        public override string full_path (WixResolver r) throws GLib.Error {
+            return (r.resolve<G> (this) as WixElement).full_path (r);
+        }
+
     }
 
     public class WixDirectoryRef: WixElementRef<WixDirectory> {



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