Add the build release information from MeeGo to corewatcher
authorWilliam Douglas <william.douglas@linux.intel.com>
Wed, 23 Mar 2011 19:09:35 +0000 (12:09 -0700)
committerWilliam Douglas <william.douglas@linux.intel.com>
Mon, 28 Mar 2011 18:13:29 +0000 (11:13 -0700)
configfile.c
coredump.c
corewatcher.conf
corewatcher.h

index 58c970f..361f2f8 100644 (file)
@@ -37,6 +37,7 @@
 int opted_in;
 int allow_distro_to_pass_on;
 char *submit_url[MAX_URLS];
+char *build_release;
 int url_count = 0;
 extern int do_unlink;
 
@@ -92,9 +93,18 @@ void read_config_file(char *filename)
                        if (c)
                                submit_url[url_count++] = strdup(c);
                }
+               c = strstr(line, "release-info");
+               if (c) {
+                       c += 11;
+                       c = strstr(c, "/");
+                       if (c)
+                               build_release = strdup(c);
+               }
                free(line);
        }
        fclose(file);
+       if (!build_release)
+               build_release = strdup("/etc/meego-release");
        if (!url_count)
                submit_url[url_count++] = strdup("http://crashdb.meego.com/submitbug.php");
 }
index d59175e..ba78971 100644 (file)
@@ -48,6 +48,43 @@ char *arch;
 
 #define MAX(A,B) ((A) > (B) ? (A) : (B))
 
+char *get_build(void) {
+       FILE *file;
+       char *line = NULL;
+       size_t dummy;
+
+       file = fopen(build_release, "r");
+       if (!file) {
+               line = strdup("Unknown");
+               return line;
+       }
+       while (!feof(file)) {
+               line = NULL;
+               if (getline(&line, &dummy, file) <= 0)
+                       break;
+               if (strstr(line, "BUILD") != NULL) {
+                       char *c;
+
+                       c = strchr(line, '\n');
+                       if (c) *c = 0;
+
+                       c = strstr(line, "BUILD");
+                       c += 7;
+                       c = strdup(c);
+
+                       free(line);
+                       fclose(file);
+                       return c;
+               }
+       }
+
+       fclose(file);
+
+       line = strdup("Unknown");
+
+       return line;
+}
+
 static char *get_release(void) {
        FILE *file;
        char *line = NULL;
@@ -209,6 +246,7 @@ static char *get_kernel(void) {
 char *build_core_header(char *appfile, char *corefile) {
        int ret = 0;
        char *result = NULL;
+       char *build = get_build();
        char *release = get_release();
        char *kernel = get_kernel();
        struct timeval tv;
@@ -226,6 +264,7 @@ char *build_core_header(char *appfile, char *corefile) {
                       "package: %s\n"
                       "reason: Process %s was killed by signal %d (%s)\n"
                       "release: %s\n"
+                      "build: %s\n"
                       "time: %lu\n"
                       "uid: %d\n"
                       "\nbacktrace\n-----\n",
@@ -237,12 +276,14 @@ char *build_core_header(char *appfile, char *corefile) {
                       package,
                       appfile, sig, signame(sig),
                       release,
+                      build,
                       tv.tv_sec,
                       uid);
 
        free(kernel);
        free(package);
        free(release);
+       free(build);
        free(component);
        free(arch);
 
index fb02cbd..dd8b775 100644 (file)
@@ -35,6 +35,16 @@ unlink = no
 
 #
 # URL for submitting the backtraces
+# Up to 10 additional URLs can be added in the same format
+# ie:
+# submit-url = http://url1.com/submitbug.php
+# submit-url = http://url2.com/submitbug.php
 #
 
 submit-url = http://crashdb.meego.com/submitbug.php
+
+#
+# Location for the MeeGo build release file
+#
+
+release-info = /etc/meego-release
\ No newline at end of file
index 7b68bea..1c3d905 100644 (file)
@@ -47,6 +47,7 @@ extern int opted_in;
 extern int allow_distro_to_pass_on;
 extern char *submit_url[MAX_URLS];
 extern int url_count;
+extern char *build_release;
 
 extern int testmode;
 extern int pinged;