[systemd-commits] 2 commits - Makefile.am src/journal

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Fri Nov 16 02:04:36 PST 2012


 Makefile.am           |   12 ++++++++++++
 src/journal/catalog.c |   32 ++++++++++++++++++++++----------
 2 files changed, 34 insertions(+), 10 deletions(-)

New commits:
commit e2bb347f85fbf5a32abc20e0dada752d3cade01d
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Nov 16 11:00:49 2012 +0100

    build-sys: update catalog on installation

diff --git a/Makefile.am b/Makefile.am
index 43db5a5..c0eec94 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2714,6 +2714,18 @@ libsystemd-journal-uninstall-hook:
 UNINSTALL_EXEC_HOOKS += \
 	libsystemd-journal-uninstall-hook
 
+# Update catalog on installation / deinstallation. Do not bother if installing
+# in DESTDIR, since this is likely for packaging purposes.
+catalog-update-hook:
+	test -n "$(DESTDIR)" || journalctl --update-catalog
+
+INSTALL_EXEC_HOOKS += \
+	catalog-update-hook
+
+UNINSTALL_EXEC_HOOKS += \
+	catalog-update-hook
+
+
 noinst_PROGRAMS += \
 	test-journal \
 	test-journal-send \

commit 80343dc19a9bcd703275ad2ad88f43e5310559d6
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Nov 16 10:28:06 2012 +0100

    journalctl: better error messages for --update-catalog
    
    Also add informational message about catalog size.

diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index 639e2d1..ce6cfab 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -269,6 +269,9 @@ static int import_file(Hashmap *h, struct strbuf *sb, const char *path) {
         return 0;
 }
 
+#define CATALOG_PATH "/var/lib/systemd/catalog"
+#define CATALOG_DATABASE CATALOG_PATH "/database"
+
 int catalog_update(void) {
         _cleanup_strv_free_ char **files = NULL;
         _cleanup_fclose_ FILE *w = NULL;
@@ -309,7 +312,8 @@ int catalog_update(void) {
                 log_info("No items in catalog.");
                 r = 0;
                 goto finish;
-        }
+        } else
+                log_debug("Found %u items in catalog.", hashmap_size(h));
 
         strbuf_complete(sb);
 
@@ -328,11 +332,16 @@ int catalog_update(void) {
         assert(n == hashmap_size(h));
         qsort(items, n, sizeof(CatalogItem), catalog_compare_func);
 
-        mkdir_p("/var/lib/systemd/catalog", 0775);
+        r = mkdir_p(CATALOG_PATH, 0775);
+        if (r < 0) {
+                log_error("Recursive mkdir %s: %s", CATALOG_PATH, strerror(-r));
+                goto finish;
+        }
 
-        r = fopen_temporary("/var/lib/systemd/catalog/database", &w, &p);
+        r = fopen_temporary(CATALOG_DATABASE, &w, &p);
         if (r < 0) {
-                log_error("Failed to open database for writing: %s", strerror(-r));
+                log_error("Failed to open database for writing: %s: %s",
+                          CATALOG_DATABASE, strerror(-r));
                 goto finish;
         }
 
@@ -344,37 +353,40 @@ int catalog_update(void) {
 
         k = fwrite(&header, 1, sizeof(header), w);
         if (k != sizeof(header)) {
-                log_error("Failed to write header.");
+                log_error("%s: failed to write header.", p);
                 goto finish;
         }
 
         k = fwrite(items, 1, n * sizeof(CatalogItem), w);
         if (k != n * sizeof(CatalogItem)) {
-                log_error("Failed to write database.");
+                log_error("%s: failed to write database.", p);
                 goto finish;
         }
 
         k = fwrite(sb->buf, 1, sb->len, w);
         if (k != sb->len) {
-                log_error("Failed to write strings.");
+                log_error("%s: failed to write strings.", p);
                 goto finish;
         }
 
         fflush(w);
 
         if (ferror(w)) {
-                log_error("Failed to write database.");
+                log_error("%s: failed to write database.", p);
                 goto finish;
         }
 
         fchmod(fileno(w), 0644);
 
-        if (rename(p, "/var/lib/systemd/catalog/database") < 0) {
-                log_error("rename() failed: %m");
+        if (rename(p, CATALOG_DATABASE) < 0) {
+                log_error("rename (%s -> %s) failed: %m", p, CATALOG_DATABASE);
                 r = -errno;
                 goto finish;
         }
 
+        log_info("%s: wrote %u items, with %zu bytes of strings, %zu total size.",
+                 CATALOG_DATABASE, n, sb->len, ftell(w));
+
         free(p);
         p = NULL;
 



More information about the systemd-commits mailing list