diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-01-09 00:21:06 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-01-09 00:21:06 +0100 |
commit | 9342db278c92c5f234137663dfd7d837a8a60d2f (patch) | |
tree | d0a6356a2416f84db463ed5415bb973e889655f0 | |
parent | 238927266ee3996dd4f0b3c88b60c8173b90d421 (diff) | |
download | msitools-9342db278c92c5f234137663dfd7d837a8a60d2f.tar.gz msitools-9342db278c92c5f234137663dfd7d837a8a60d2f.tar.xz msitools-9342db278c92c5f234137663dfd7d837a8a60d2f.zip |
msi: populate Upgrade table
-rw-r--r-- | src/builder.vala | 20 | ||||
-rw-r--r-- | src/msi.vala | 24 | ||||
-rw-r--r-- | src/util.vala | 4 | ||||
-rw-r--r-- | src/wix.vala | 1 |
4 files changed, 47 insertions, 2 deletions
diff --git a/src/builder.vala b/src/builder.vala index 1606bb2..bc28c8f 100644 --- a/src/builder.vala +++ b/src/builder.vala @@ -502,10 +502,30 @@ namespace Wixl { public override void visit_condition (WixCondition condition) throws GLib.Error { } + [Flags] + enum UpgradeAttribute { + MIGRATE_FEATURES = 1 << 0, + ONLY_DETECT = 1 << 1, + IGNORE_REMOVE_FAILURE = 1 << 2, + VERSION_MIN_INCLUSIVE = 1 << 8, + VERSION_MAX_INCLUSIVE = 1 << 9, + LANGUAGES_EXCLUSIVE = 1 << 10 + } + public override void visit_upgrade (WixUpgrade upgrade) throws GLib.Error { } public override void visit_upgrade_version (WixUpgradeVersion version) throws GLib.Error { + var upgrade = version.parent as WixUpgrade; + UpgradeAttribute attributes = 0; + + if (parse_yesno (version.OnlyDetect)) + attributes |= UpgradeAttribute.ONLY_DETECT; + + if (parse_yesno (version.IncludeMinimum, true)) + attributes |= UpgradeAttribute.VERSION_MIN_INCLUSIVE; + + db.table_upgrade.add (get_uuid (upgrade.Id), version.Minimum, version.Maximum, attributes, version.Property); } public override void visit_remove_existing_products (WixRemoveExistingProducts remove) throws GLib.Error { diff --git a/src/msi.vala b/src/msi.vala index a73fd73..eab8dcd 100644 --- a/src/msi.vala +++ b/src/msi.vala @@ -188,6 +188,27 @@ namespace Wixl { } } + class MsiTableUpgrade: MsiTable { + static construct { + name = "Upgrade"; + sql_create = "CREATE TABLE `Upgrade` (`UpgradeCode` CHAR(38) NOT NULL, `VersionMin` CHAR(20), `VersionMax` CHAR(20), `Language` CHAR(255), `Attributes` LONG NOT NULL, `Remove` CHAR(255), `ActionProperty` CHAR(72) NOT NULL PRIMARY KEY `UpgradeCode`, `VersionMin`, `VersionMax`, `Language`, `Attributes`)"; + sql_insert = "INSERT INTO `Upgrade` (`UpgradeCode`, `VersionMin`, `VersionMax`, `Attributes`, `ActionProperty`) VALUES (?, ?, ?, ?, ?)"; + } + + public void add (string UpgradeCode, string VersionMin, string? VersionMax, int Attributes, string ActionProperty) throws GLib.Error { + var rec = new Libmsi.Record (5); + + if (!rec.set_string (1, UpgradeCode) || + !rec.set_string (2, VersionMin) || + (VersionMax != null && !rec.set_string (3, VersionMax)) || + !rec.set_int (4, Attributes) || + !rec.set_string (5, ActionProperty)) + throw new Wixl.Error.FAILED ("failed to add record"); + + records.append (rec); + } + } + class MsiTableProperty: MsiTable { static construct { name = "Property"; @@ -459,6 +480,7 @@ namespace Wixl { public MsiTableInstallUISequence table_install_ui_sequence; public MsiTableStreams table_streams; public MsiTableShortcut table_shortcut; + public MsiTableUpgrade table_upgrade; HashTable<string, MsiTable> tables; @@ -500,6 +522,7 @@ namespace Wixl { table_install_ui_sequence = new MsiTableInstallUISequence (); table_streams = new MsiTableStreams (); table_shortcut = new MsiTableShortcut (); + table_upgrade = new MsiTableUpgrade (); foreach (var t in new MsiTable[] { table_admin_execute_sequence, @@ -519,6 +542,7 @@ namespace Wixl { table_file, table_streams, table_shortcut, + table_upgrade, new MsiTableError (), new MsiTableValidation () }) { diff --git a/src/util.vala b/src/util.vala index f8952b2..11f1588 100644 --- a/src/util.vala +++ b/src/util.vala @@ -97,9 +97,9 @@ namespace Wixl { return str; } - bool parse_yesno (string? str) { + bool parse_yesno (string? str, bool default = false) { if (str == null) - return false; + return default; return (str[0] == 'Y' || str[0] == 'y'); } diff --git a/src/wix.vala b/src/wix.vala index 54d1a3d..4fe1df4 100644 --- a/src/wix.vala +++ b/src/wix.vala @@ -437,6 +437,7 @@ namespace Wixl { } public override void accept (WixNodeVisitor visitor) throws GLib.Error { + base.accept (visitor); visitor.visit_upgrade (this); } } |