diff options
-rw-r--r-- | tests/data/_SummaryInformation.idt | 17 | ||||
-rw-r--r-- | tests/testsuite.at | 20 | ||||
-rw-r--r-- | tools/msibuild.c | 63 |
3 files changed, 75 insertions, 25 deletions
diff --git a/tests/data/_SummaryInformation.idt b/tests/data/_SummaryInformation.idt new file mode 100644 index 0000000..fe17436 --- /dev/null +++ b/tests/data/_SummaryInformation.idt @@ -0,0 +1,17 @@ +PropertyId Value
+i2 l255
+_SummaryInformation PropertyId
+1 1252
+2 Installation Database
+3 Acme's Foobar 1.0 Installer
+4 Acme Ltd.
+5 Installer
+6 Foobar is a registered trademark of Acme Ltd.
+7 Intel;1033
+9 {D045A303-F114-4A3B-A01D-24FC2D2A67D7}
+12 2012/12/18 15:12:50
+13 2012/12/18 15:12:50
+14 100
+15 2
+18 Windows Installer XML (3.7.1119.0)
+19 2
diff --git a/tests/testsuite.at b/tests/testsuite.at index 9a9d226..01ac62b 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -211,3 +211,23 @@ Binary ]) AT_CLEANUP +AT_SETUP([Update _SummaryInformation table]) +AT_MSIDATA([_SummaryInformation.idt]) +AT_CHECK_MSIBUILD([-i out.msi _SummaryInformation.idt]) +AT_CHECK_MSIINFO([suminfo out.msi], [0], +[Title: Installation Database +Subject: Acme's Foobar 1.0 Installer +Author: Acme Ltd. +Keywords: Installer +Comments: Foobar is a registered trademark of Acme Ltd. +Template: Intel;1033 +Revision number (UUID): {D045A303-F114-4A3B-A01D-24FC2D2A67D7} +Created: Wed Dec 18 15:12:50 3912 +Last saved: Wed Dec 18 15:12:50 3912 +Version: 100 (64) +Source: 2 (2) +Restrict: 0 (0) +Application: Windows Installer XML (3.7.1119.0) +Security: 2 (2) +]) +AT_CLEANUP diff --git a/tools/msibuild.c b/tools/msibuild.c index 4ba00e1..bebef7d 100644 --- a/tools/msibuild.c +++ b/tools/msibuild.c @@ -80,9 +80,10 @@ static gboolean init_suminfo(LibmsiSummaryInfo *si, GError **error) } static LibmsiResult open_database(const char *msifile, LibmsiDatabase **db, - LibmsiSummaryInfo **si, GError **error) + GError **error) { - LibmsiResult r = LIBMSI_RESULT_SUCCESS; + LibmsiSummaryInfo *si = NULL; + LibmsiResult r = LIBMSI_RESULT_FUNCTION_FAILED; struct stat st; if (stat(msifile, &st) == -1) @@ -91,15 +92,18 @@ static LibmsiResult open_database(const char *msifile, LibmsiDatabase **db, if (!*db) return LIBMSI_RESULT_FUNCTION_FAILED; - *si = libmsi_summary_info_new(*db, INT_MAX, error); - if (!*si) + si = libmsi_summary_info_new(*db, INT_MAX, error); + if (!si) { fprintf(stderr, "failed to open summary info\n"); return LIBMSI_RESULT_FUNCTION_FAILED; } - if (!init_suminfo(*si, error)) - return LIBMSI_RESULT_FUNCTION_FAILED; + if (!init_suminfo(si, error)) + goto end; + + if (!libmsi_summary_info_persist(si, error)) + goto end; if (!libmsi_database_commit(*db, error)) { @@ -113,20 +117,18 @@ static LibmsiResult open_database(const char *msifile, LibmsiDatabase **db, *db = libmsi_database_new(msifile, LIBMSI_DB_OPEN_TRANSACT, error); if (!*db) return LIBMSI_RESULT_FUNCTION_FAILED; - - *si = libmsi_summary_info_new(*db, INT_MAX, error); - if (!*si) - { - fprintf(stderr, "failed to open summary info\n"); - return LIBMSI_RESULT_FUNCTION_FAILED; - } } + r = LIBMSI_RESULT_SUCCESS; + +end: + if (si) + g_object_unref(si); + return r; } static LibmsiDatabase *db; -static LibmsiSummaryInfo *si; static gboolean import_table(char *table, GError **error) { @@ -146,22 +148,37 @@ static gboolean add_summary_info(const char *name, const char *author, const char *template, const char *uuid, GError **error) { - if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_SUBJECT, name, error)) + LibmsiSummaryInfo *si = libmsi_summary_info_new(db, INT_MAX, error); + gboolean success = FALSE; + + if (!si) return FALSE; + if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_SUBJECT, name, error)) + goto end; + if (author && !libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_AUTHOR, author, error)) - return FALSE; + goto end; if (template && !libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_TEMPLATE, template, error)) - return FALSE; + goto end; if (uuid && !libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_UUID, uuid, error)) - return FALSE; + goto end; - return TRUE; + if (!libmsi_summary_info_persist(si, error)) + goto end; + + success = TRUE; + +end: + if (si) + g_object_unref(si); + + return success; } static gboolean add_stream(const char *stream, const char *file, GError **error) @@ -257,10 +274,10 @@ int main(int argc, char *argv[]) /* Accept package after first option for winemsibuilder compatibility. */ if (argc >= 3 && argv[1][0] == '-') { - r = open_database(argv[2], &db, &si, &error); + r = open_database(argv[2], &db, &error); argv[2] = argv[1]; } else { - r = open_database(argv[1], &db, &si, &error); + r = open_database(argv[1], &db, &error); } if (r != LIBMSI_RESULT_SUCCESS) return 1; @@ -326,15 +343,11 @@ int main(int argc, char *argv[]) } if (r == LIBMSI_RESULT_SUCCESS) { - if (!libmsi_summary_info_persist(si, &error)) - goto end; - if (!libmsi_database_commit(db, &error)) goto end; } end: - g_object_unref(si); g_object_unref(db); if (error != NULL) { |