summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-03 17:58:06 +0100
committerMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-06 16:38:26 +0100
commit951c6b1bcfcc5ddc8575ffd32cb0ebed532a428b (patch)
treee70f63f512f32a97548a0dac52603759ea73396b
parentd43a0c5613c3c88a845fdf183ed403bd95072cf4 (diff)
downloadmsitools-951c6b1bcfcc5ddc8575ffd32cb0ebed532a428b.tar.gz
msitools-951c6b1bcfcc5ddc8575ffd32cb0ebed532a428b.tar.xz
msitools-951c6b1bcfcc5ddc8575ffd32cb0ebed532a428b.zip
Populate Registry table
-rw-r--r--src/builder.vala35
-rw-r--r--src/msi.vala29
-rw-r--r--src/util.vala18
-rw-r--r--src/wix.vala23
4 files changed, 105 insertions, 0 deletions
diff --git a/src/builder.vala b/src/builder.vala
index 6544d61..7587120 100644
--- a/src/builder.vala
+++ b/src/builder.vala
@@ -90,6 +90,41 @@ namespace Wixl {
db.table_remove_file.add (rm.Id, comp.Id, dir.Id, on);
}
+ enum RegistryValueType {
+ STRING,
+ INTEGER,
+ BINARY,
+ EXPANDABLE,
+ MULTI_STRING
+ }
+
+ enum RegistryRoot {
+ HKCR,
+ HKCU,
+ HKLM,
+ HKU,
+ HKMU
+ }
+
+ public override void visit_registry_value (WixRegistryValue reg) throws GLib.Error {
+ var comp = reg.parent as WixComponent;
+ var value = reg.Value;
+ var t = enum_from_string (typeof (RegistryValueType), reg.Type);
+ var r = enum_from_string (typeof (RegistryRoot), reg.Root.down ());
+ var id = generate_id ("reg", 4,
+ comp.Id,
+ reg.Root,
+ reg.Key != null ? reg.Key.down () : null,
+ reg.Name != null ? reg.Name.down () : null);
+
+ switch (t) {
+ case RegistryValueType.STRING:
+ value = value[0] == '#' ? "#" + value : value;
+ break;
+ }
+
+ db.table_registry.add (id, r, reg.Key, comp.Id);
+ }
}
} // Wixl
diff --git a/src/msi.vala b/src/msi.vala
index 56f4206..d45f810 100644
--- a/src/msi.vala
+++ b/src/msi.vala
@@ -363,6 +363,32 @@ namespace Wixl {
}
}
+ class MsiTableRegistry: MsiTable {
+ construct {
+ name = "Registry";
+ }
+
+ public void add (string Registry, int Root, string Key, string Component) throws GLib.Error {
+ var rec = new Libmsi.Record (4);
+ if (!rec.set_string (1, Registry) ||
+ !rec.set_int (2, Root) ||
+ !rec.set_string (3, Key) ||
+ !rec.set_string (4, Component))
+ throw new Wixl.Error.FAILED ("failed to add record");
+
+ records.append (rec);
+ }
+
+ public override void create (Libmsi.Database db) throws GLib.Error {
+ var query = new Libmsi.Query (db, "CREATE TABLE `Registry` (`Registry` CHAR(72) NOT NULL, `Root` INT NOT NULL, `Key` CHAR(255) NOT NULL LOCALIZABLE, `Name` CHAR(255) LOCALIZABLE, `Value` CHAR(0) LOCALIZABLE, `Component_` CHAR(72) NOT NULL PRIMARY KEY `Registry`)");
+ query.execute (null);
+
+ query = new Libmsi.Query (db, "INSERT INTO `Registry` (`Registry`, `Root`, `Key`, `Component_`) VALUES (?, ?, ?, ?)");
+ foreach (var r in records)
+ query.execute (r);
+ }
+ }
+
class MsiTableRemoveFile: MsiTable {
construct {
name = "RemoveFile";
@@ -485,6 +511,7 @@ namespace Wixl {
public MsiTableFeature table_feature;
public MsiTableFeatureComponents table_feature_components;
public MsiTableRemoveFile table_remove_file;
+ public MsiTableRegistry table_registry;
HashTable<string, MsiTable> tables;
@@ -515,6 +542,7 @@ namespace Wixl {
table_feature = new MsiTableFeature ();
table_feature_components = new MsiTableFeatureComponents ();
table_remove_file = new MsiTableRemoveFile ();
+ table_registry = new MsiTableRegistry ();
foreach (var t in new MsiTable[] {
new MsiTableAdminExecuteSequence (),
@@ -532,6 +560,7 @@ namespace Wixl {
table_feature,
table_feature_components,
table_remove_file,
+ table_registry,
new MsiTable_Validation ()
}) {
tables.insert (t.name, t);
diff --git a/src/util.vala b/src/util.vala
index 0dfdd36..9ad72e2 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -67,4 +67,22 @@ namespace Wixl {
return indented;
}
+ public string generate_id (string prefix, uint n, ...) {
+ var l = va_list ();
+ var args = new string[n];
+
+ for (var i = 0; n > 0; n--) {
+ string? val = l.arg ();
+ if (val == null)
+ continue;
+ args[i] = val; // FIXME: misc vala bug when +=
+ i += 1;
+ }
+ var data = string.joinv ("|", args);
+ var hash = Checksum.compute_for_string (ChecksumType.MD5, data);
+ var str = prefix + hash[0:32].up ();
+
+ return str;
+ }
+
} // Wixl
diff --git a/src/wix.vala b/src/wix.vala
index 97cc137..066795c 100644
--- a/src/wix.vala
+++ b/src/wix.vala
@@ -11,6 +11,7 @@ namespace Wixl {
public abstract void visit_feature (WixFeature feature) throws GLib.Error;
public abstract void visit_component_ref (WixComponentRef ref) throws GLib.Error;
public abstract void visit_remove_folder (WixRemoveFolder rm) throws GLib.Error;
+ public abstract void visit_registry_value (WixRegistryValue reg) throws GLib.Error;
}
public abstract class WixElement: Object {
@@ -130,6 +131,23 @@ namespace Wixl {
}
}
+ public class WixRegistryValue: WixElement {
+ static construct {
+ name = "RegistryValue";
+ }
+
+ public string Root { get; set; }
+ public string Key { get; set; }
+ public string Type { get; set; }
+ public string Value { get; set; }
+ public string KeyPath { get; set; }
+ public string Name { get; set; }
+
+ public override void accept (WixElementVisitor visitor) throws GLib.Error {
+ visitor.visit_registry_value (this);
+ }
+ }
+
public class WixRemoveFolder: WixElement {
static construct {
name = "RemoveFolder";
@@ -291,6 +309,11 @@ namespace Wixl {
rm.load (child);
add_child (rm);
continue;
+ case "RegistryValue":
+ var reg = new WixRegistryValue ();
+ reg.load (child);
+ add_child (reg);
+ continue;
}
break;
}