summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-01-24 21:17:22 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2013-01-24 21:26:35 +0100
commit57007f5c1836aafdb51725e974c48e74551b93e7 (patch)
tree59be79afe0de8031fcf9788321748b2ef418a8cd /tools
parentac82ebd7518aab2ac905f5e1a2bedb9a43b830f6 (diff)
downloadmsitools-57007f5c1836aafdb51725e974c48e74551b93e7.tar.gz
msitools-57007f5c1836aafdb51725e974c48e74551b93e7.tar.xz
msitools-57007f5c1836aafdb51725e974c48e74551b93e7.zip
wixl: implement stable UUID generation
Note that the UUIDs are *not* compatible with WiX!
Diffstat (limited to 'tools')
-rw-r--r--tools/wixl/builder.vala28
-rw-r--r--tools/wixl/wix.vala14
2 files changed, 41 insertions, 1 deletions
diff --git a/tools/wixl/builder.vala b/tools/wixl/builder.vala
index bb5510b..fc511d9 100644
--- a/tools/wixl/builder.vala
+++ b/tools/wixl/builder.vala
@@ -324,6 +324,26 @@ namespace Wixl {
SHARED,
}
+ /* Namespace UUID: {de73ba5a-ed96-4a66-ba1b-fbb44e659ad7} */
+ private static string uuid_namespace =
+ "\xde\x73\xba\x5a\xed\x96\x4a\x66\xba\x1b\xfb\xb4\x4e\x65\x9a\xd7";
+
+ private static string uuid_from_name(string s) {
+ var cs = new Checksum (ChecksumType.SHA1);
+ uint8 buffer[20];
+ size_t buflen = buffer.length;
+
+ cs.update (uuid_namespace.data, 16);
+ cs.update (s.data, s.length);
+ cs.get_digest (buffer, ref buflen);
+
+ return "{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}".
+ printf(buffer[0], buffer[1], buffer[2], buffer[3],
+ buffer[4], buffer[5], (buffer[6] & 15) | 0x50, buffer[7],
+ (buffer[8] & 0x3F) | 0x80, buffer[9], buffer[10], buffer[11],
+ buffer[12], buffer[13], buffer[14], buffer[15]);
+ }
+
public override void visit_component (WixComponent comp) throws GLib.Error {
var attr = 0;
@@ -331,8 +351,14 @@ namespace Wixl {
attr |= ComponentAttribute.REGISTRY_KEY_PATH;
var parent = resolve<WixDirectory> (comp.parent);
+ string uuid;
+
// FIXME: stable uuid generation based on ns/dir/path
- var uuid = get_uuid (comp.Guid);
+ if (comp.Guid == "*")
+ uuid = uuid_from_name (comp.full_path (this));
+ else
+ uuid = get_uuid (comp.Guid);
+
db.table_component.add (comp.Id, uuid, parent.Id, attr,
comp.key != null ? comp.key.Id : null);
diff --git a/tools/wixl/wix.vala b/tools/wixl/wix.vala
index 205721b..c6897d8 100644
--- a/tools/wixl/wix.vala
+++ b/tools/wixl/wix.vala
@@ -147,6 +147,20 @@ 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;
+ else
+ return this.Id;
+ }
+
public G[] get_elements<G> () {
return add_elements<G> ({});
}