fixed some problems with selinux dupes and bodhi
This commit is contained in:
parent
0761ab6436
commit
6d5fcec891
@ -0,0 +1,90 @@
|
||||
From b26c6d5a3b9aff0933fb9abd393fd3c5f3b6cd02 Mon Sep 17 00:00:00 2001
|
||||
From: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
Date: Mon, 5 Dec 2011 18:48:17 +0100
|
||||
Subject: [PATCH 1/6] allow to specify bodh url and fix one NULL dereferencing
|
||||
|
||||
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
---
|
||||
src/include/internal_libreport.h | 2 +-
|
||||
src/plugins/abrt-bodhi.c | 20 ++++++++++++++++----
|
||||
2 files changed, 17 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
|
||||
index 4c50a26..c153aaa 100644
|
||||
--- a/src/include/internal_libreport.h
|
||||
+++ b/src/include/internal_libreport.h
|
||||
@@ -715,7 +715,7 @@ struct options {
|
||||
#define OPT_LIST( s, l, v, a, h) { OPTION_LIST , (s), (l), (v), (a) , (h) }
|
||||
|
||||
#define OPT__VERBOSE(v) OPT_BOOL('v', "verbose", (v), _("Be verbose"))
|
||||
-#define OPT__DUMP_DIR(v) OPT_STRING('d', "dump-dir", (v), "DIR", _("Dump directory"))
|
||||
+#define OPT__DUMP_DIR(v) OPT_STRING('d', "problem-dir", (v), "DIR", _("Problem directory"))
|
||||
|
||||
#define parse_opts libreport_parse_opts
|
||||
unsigned parse_opts(int argc, char **argv, const struct options *opt,
|
||||
diff --git a/src/plugins/abrt-bodhi.c b/src/plugins/abrt-bodhi.c
|
||||
index 28aa439..3495c24 100644
|
||||
--- a/src/plugins/abrt-bodhi.c
|
||||
+++ b/src/plugins/abrt-bodhi.c
|
||||
@@ -110,7 +110,7 @@
|
||||
}
|
||||
*/
|
||||
|
||||
-static const char *const bodhi_url = "https://admin.fedoraproject.org/updates/%s";
|
||||
+static const char *bodhi_url = "https://admin.fedoraproject.org/updates/";
|
||||
|
||||
struct bodhi {
|
||||
char *nvr;
|
||||
@@ -288,10 +288,10 @@ static GHashTable *bodhi_parse_json(json_object *json, const char *release)
|
||||
|
||||
static GHashTable *bodhi_query_list(const char *query, const char *release)
|
||||
{
|
||||
- char *bodhi_url_bugs = xasprintf(bodhi_url, "list");
|
||||
+ char *bodhi_url_bugs = xasprintf("%s/list", bodhi_url);
|
||||
|
||||
abrt_post_state_t *post_state = new_abrt_post_state(
|
||||
- ABRT_POST_WANT_BODY|ABRT_POST_WANT_SSL_VERIFY);
|
||||
+ ABRT_POST_WANT_BODY | ABRT_POST_WANT_SSL_VERIFY | ABRT_POST_WANT_ERROR_MSG);
|
||||
|
||||
const char *headers[] = {
|
||||
"Accept: application/json",
|
||||
@@ -301,6 +301,13 @@ static GHashTable *bodhi_query_list(const char *query, const char *release)
|
||||
log(_("Search for a new updates"));
|
||||
abrt_post_string(post_state, bodhi_url_bugs, "application/x-www-form-urlencoded",
|
||||
headers, query);
|
||||
+
|
||||
+ if (post_state->http_resp_code != 200)
|
||||
+ {
|
||||
+ char *errmsg = post_state->curl_error_msg;
|
||||
+ if (errmsg && errmsg[0])
|
||||
+ error_msg_and_die("%s '%s'", errmsg, bodhi_url_bugs);
|
||||
+ }
|
||||
free(bodhi_url_bugs);
|
||||
|
||||
// log("%s", post_state->body);
|
||||
@@ -357,9 +364,11 @@ int main(int argc, char **argv)
|
||||
/* Keep enum above and order of options below in sync! */
|
||||
struct options program_options[] = {
|
||||
OPT__VERBOSE(&g_verbose),
|
||||
+ OPT__DUMP_DIR(&dump_dir_path),
|
||||
+ OPT_GROUP(""),
|
||||
OPT_STRING('b', "bugs", &bugs, "ID1[,ID2,...]" , _("List of bug ids")),
|
||||
+ OPT_STRING('u', "url", &bodhi_url, "URL", _("Specify a bodhi server url")),
|
||||
OPT_OPTSTRING('r', "release", &release, "RELEASE", _("Specify a release")),
|
||||
- OPT__DUMP_DIR(&dump_dir_path),
|
||||
OPT_END()
|
||||
};
|
||||
|
||||
@@ -387,6 +396,9 @@ int main(int argc, char **argv)
|
||||
else
|
||||
{
|
||||
struct dump_dir *dd = dd_opendir(dump_dir_path, DD_OPEN_READONLY);
|
||||
+ if (!dd)
|
||||
+ xfunc_die();
|
||||
+
|
||||
problem_data_t *problem_data = create_problem_data_from_dump_dir(dd);
|
||||
dd_close(dd);
|
||||
if (!problem_data)
|
||||
--
|
||||
1.7.7.3
|
||||
|
151
0002-if-better-backtrace-is-avail-then-upload-one.patch
Normal file
151
0002-if-better-backtrace-is-avail-then-upload-one.patch
Normal file
@ -0,0 +1,151 @@
|
||||
From 480d39f86254f6088e53b69520b7354fa992b594 Mon Sep 17 00:00:00 2001
|
||||
From: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
Date: Tue, 29 Nov 2011 15:25:59 +0100
|
||||
Subject: [PATCH 2/6] if better backtrace is avail, then upload one
|
||||
|
||||
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
---
|
||||
src/plugins/reporter-bugzilla.c | 17 ++++++++++-
|
||||
src/plugins/rhbz.c | 62 +++++++++++++++++++++++++++++++++++----
|
||||
src/plugins/rhbz.h | 1 +
|
||||
3 files changed, 73 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
|
||||
index 4046b24..4739c2e 100644
|
||||
--- a/src/plugins/reporter-bugzilla.c
|
||||
+++ b/src/plugins/reporter-bugzilla.c
|
||||
@@ -377,14 +377,16 @@ int main(int argc, char **argv)
|
||||
{
|
||||
const char *package = get_problem_item_content_or_NULL(problem_data, FILENAME_PACKAGE);
|
||||
const char *arch = get_problem_item_content_or_NULL(problem_data, FILENAME_ARCHITECTURE);
|
||||
+ const char *rating_str = get_problem_item_content_or_NULL(problem_data, FILENAME_RATING);
|
||||
char *full_dsc = xasprintf("Package: %s\n"
|
||||
"Architecture: %s\n"
|
||||
"OS Release: %s\n"
|
||||
+ "rating: %s\n"
|
||||
"\n"
|
||||
"Comment\n"
|
||||
"-----\n"
|
||||
"%s\n",
|
||||
- package, arch, release, comment
|
||||
+ package, arch, release, rating_str, comment
|
||||
);
|
||||
log(_("Adding new comment to bug %d"), bz->bi_id);
|
||||
/* unused code, enable it when gui/cli will be ready
|
||||
@@ -394,6 +396,19 @@ int main(int argc, char **argv)
|
||||
*/
|
||||
rhbz_add_comment(client, bz->bi_id, full_dsc, 0);
|
||||
free(full_dsc);
|
||||
+
|
||||
+ unsigned rating = xatou(rating_str);
|
||||
+ if (bz->bi_best_bt_rating < rating)
|
||||
+ {
|
||||
+ char bug_id_str[sizeof(int)*3 + 2];
|
||||
+ sprintf(bug_id_str, "%i", bz->bi_id);
|
||||
+
|
||||
+ const char *bt = get_problem_item_content_or_NULL(problem_data,
|
||||
+ FILENAME_BACKTRACE);
|
||||
+ log(_("Attaching better backtrace"));
|
||||
+ rhbz_attach_blob(client, FILENAME_BACKTRACE, bug_id_str, bt, strlen(bt),
|
||||
+ RHBZ_NOMAIL_NOTIFY);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
|
||||
index 13957b8..6b71202 100644
|
||||
--- a/src/plugins/rhbz.c
|
||||
+++ b/src/plugins/rhbz.c
|
||||
@@ -42,14 +42,62 @@ void free_bug_info(struct bug_info *bi)
|
||||
|
||||
list_free_with_free(bi->bi_cc_list);
|
||||
|
||||
- bi->bi_status = NULL;
|
||||
- bi->bi_resolution = NULL;
|
||||
- bi->bi_reporter = NULL;
|
||||
- bi->bi_product = NULL;
|
||||
+ free(bi);
|
||||
+}
|
||||
|
||||
- bi->bi_cc_list = NULL;
|
||||
+static unsigned find_best_bt_rating_in_comments(xmlrpc_value *result_xml)
|
||||
+{
|
||||
+ xmlrpc_value *comments_memb = rhbz_get_member("longdescs", result_xml);
|
||||
+ if (!comments_memb)
|
||||
+ return 0;
|
||||
|
||||
- free(bi);
|
||||
+ int comments_memb_size = rhbz_array_size(comments_memb);
|
||||
+
|
||||
+ xmlrpc_env env;
|
||||
+ xmlrpc_env_init(&env);
|
||||
+ int best_bt_rating = 0;
|
||||
+ for (int i = 0; i < comments_memb_size; ++i)
|
||||
+ {
|
||||
+ xmlrpc_value* item = NULL;
|
||||
+ xmlrpc_array_read_item(&env, comments_memb, i, &item);
|
||||
+ if (env.fault_occurred)
|
||||
+ abrt_xmlrpc_die(&env);
|
||||
+
|
||||
+ char *comment_body = rhbz_bug_read_item("body", item, RHBZ_READ_STR);
|
||||
+ /* attachments are sometimes without comments -- skip them */
|
||||
+ if (!comment_body)
|
||||
+ continue;
|
||||
+
|
||||
+ char *start_rating_line = strstr(comment_body, "rating: ");
|
||||
+ if (!start_rating_line)
|
||||
+ {
|
||||
+ VERB3 error_msg("comment does not contain rating");
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ start_rating_line += strlen("rating: ");
|
||||
+ char *end_rating_line = strchr(start_rating_line, '\n');
|
||||
+ if (!end_rating_line)
|
||||
+ VERB3 error_msg("broken comment body");
|
||||
+
|
||||
+ char *rating_srt = xstrndup(start_rating_line, end_rating_line - start_rating_line);
|
||||
+ int old_errno = errno;
|
||||
+ errno = 0;
|
||||
+ char *e;
|
||||
+ long rating = strtoul(rating_srt, &e, 10);
|
||||
+ if (errno || rating_srt == e || *e != '\0' || rating > UINT_MAX)
|
||||
+ {
|
||||
+ /* error / no digits / illegal trailing chars */
|
||||
+ errno = old_errno;
|
||||
+ continue;
|
||||
+ }
|
||||
+ errno = old_errno; /* Ok. So restore errno. */
|
||||
+
|
||||
+ if (rating > best_bt_rating)
|
||||
+ best_bt_rating = rating;
|
||||
+ }
|
||||
+
|
||||
+ return best_bt_rating;
|
||||
}
|
||||
|
||||
void rhbz_login(struct abrt_xmlrpc *ax, const char* login, const char* passwd)
|
||||
@@ -273,6 +321,8 @@ struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id)
|
||||
|
||||
bz->bi_cc_list = rhbz_bug_cc(xml_bug_response);
|
||||
|
||||
+ bz->bi_best_bt_rating = find_best_bt_rating_in_comments(xml_bug_response);
|
||||
+
|
||||
xmlrpc_DECREF(xml_bug_response);
|
||||
|
||||
return bz;
|
||||
diff --git a/src/plugins/rhbz.h b/src/plugins/rhbz.h
|
||||
index 864f603..9878dd7 100644
|
||||
--- a/src/plugins/rhbz.h
|
||||
+++ b/src/plugins/rhbz.h
|
||||
@@ -48,6 +48,7 @@ enum {
|
||||
struct bug_info {
|
||||
int bi_id;
|
||||
int bi_dup_id;
|
||||
+ unsigned bi_best_bt_rating;
|
||||
|
||||
char *bi_status;
|
||||
char *bi_resolution;
|
||||
--
|
||||
1.7.7.3
|
||||
|
101
0003-search-only-by-duphash-for-selinux.patch
Normal file
101
0003-search-only-by-duphash-for-selinux.patch
Normal file
@ -0,0 +1,101 @@
|
||||
From 8bf23a12caac293637060b09f733f57f839a4a71 Mon Sep 17 00:00:00 2001
|
||||
From: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
Date: Wed, 30 Nov 2011 19:18:20 +0100
|
||||
Subject: [PATCH 3/6] search only by duphash for selinux
|
||||
|
||||
selinux guy's almost always move filled bug from component selinux-policy
|
||||
to right component.
|
||||
|
||||
bugzilla client is looking for duplicate bug by sending xmlrpc query
|
||||
|
||||
"ALL whiteboard:<hash> component:<name> [product:<product>]"
|
||||
|
||||
so if bug is moved from component selinux-policy to other, then query
|
||||
returns NULL and creates a new bug.
|
||||
|
||||
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
---
|
||||
src/plugins/reporter-bugzilla.c | 25 ++++++++++++++++++-------
|
||||
src/plugins/rhbz.c | 21 ++++++++++++---------
|
||||
2 files changed, 30 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
|
||||
index 4739c2e..b6356f9 100644
|
||||
--- a/src/plugins/reporter-bugzilla.c
|
||||
+++ b/src/plugins/reporter-bugzilla.c
|
||||
@@ -280,11 +280,22 @@ int main(int argc, char **argv)
|
||||
free(version);
|
||||
|
||||
log(_("Checking for duplicates"));
|
||||
- xmlrpc_value *result;
|
||||
- if (strcmp(product, "Fedora") == 0)
|
||||
- result = rhbz_search_duphash(client, component, product, duphash);
|
||||
- else
|
||||
- result = rhbz_search_duphash(client, component, NULL, duphash);
|
||||
+
|
||||
+ /*
|
||||
+ selinux guy's almost always move filled bug from component selinux-policy
|
||||
+ to right component.
|
||||
+
|
||||
+ bugzilla client is looking for duplicate bug by sending xmlrpc query
|
||||
+
|
||||
+ "ALL whiteboard:<hash> component:<name> [product:<product>]"
|
||||
+
|
||||
+ so if bug is moved from component selinux-policy to other, then query
|
||||
+ returns NULL and creates a new bug.
|
||||
+ */
|
||||
+ const char *product_substitute = (!strcmp(product, "Fedora")) ? product : NULL;
|
||||
+ const char *component_substitute = (!strcmp(component, "selinux-policy")) ? NULL : component;
|
||||
+ xmlrpc_value *result = rhbz_search_duphash(client, component_substitute,
|
||||
+ product_substitute, duphash);
|
||||
|
||||
xmlrpc_value *all_bugs = rhbz_get_member("bugs", result);
|
||||
xmlrpc_DECREF(result);
|
||||
@@ -310,8 +321,8 @@ int main(int argc, char **argv)
|
||||
/* found something, but its a different product */
|
||||
free_bug_info(bz);
|
||||
|
||||
- xmlrpc_value *result = rhbz_search_duphash(client, component,
|
||||
- product, duphash);
|
||||
+ xmlrpc_value *result = rhbz_search_duphash(client, component_substitute,
|
||||
+ product_substitute, duphash);
|
||||
xmlrpc_value *all_bugs = rhbz_get_member("bugs", result);
|
||||
xmlrpc_DECREF(result);
|
||||
|
||||
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
|
||||
index 6b71202..3662816 100644
|
||||
--- a/src/plugins/rhbz.c
|
||||
+++ b/src/plugins/rhbz.c
|
||||
@@ -116,17 +116,20 @@ void rhbz_login(struct abrt_xmlrpc *ax, const char* login, const char* passwd)
|
||||
xmlrpc_value *rhbz_search_duphash(struct abrt_xmlrpc *ax, const char *component,
|
||||
const char *product, const char *duphash)
|
||||
{
|
||||
- char *query = NULL;
|
||||
- if (!product)
|
||||
- query = xasprintf("ALL component:\"%s\" whiteboard:\"%s\"", component, duphash);
|
||||
- else
|
||||
- query = xasprintf("ALL component:\"%s\" whiteboard:\"%s\" product:\"%s\"",
|
||||
- component, duphash, product);
|
||||
+ struct strbuf *query = strbuf_new();
|
||||
+ strbuf_append_strf(query, "ALL whiteboard:\"%s\"", duphash);
|
||||
+
|
||||
+ if (product)
|
||||
+ strbuf_append_strf(query, " product:\"%s\"", product);
|
||||
|
||||
- VERB3 log("search for '%s'", query);
|
||||
+ if (component)
|
||||
+ strbuf_append_strf(query, " component:\"%s\"", component);
|
||||
+
|
||||
+ VERB3 log("search for '%s'", query->buf);
|
||||
xmlrpc_value *ret = abrt_xmlrpc_call(ax, "Bug.search", "({s:s})",
|
||||
- "quicksearch", query);
|
||||
- free(query);
|
||||
+ "quicksearch", query->buf);
|
||||
+ strbuf_free(query);
|
||||
+
|
||||
return ret;
|
||||
}
|
||||
|
||||
--
|
||||
1.7.7.3
|
||||
|
@ -0,0 +1,53 @@
|
||||
From 51a3918434aec04d057bf5a0d117214c9e6d9413 Mon Sep 17 00:00:00 2001
|
||||
From: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
Date: Wed, 30 Nov 2011 19:57:58 +0100
|
||||
Subject: [PATCH 4/6] reorganize comments for bugzilla -- message body comes
|
||||
first
|
||||
|
||||
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
---
|
||||
src/plugins/reporter-bugzilla.c | 22 ++++++++++------------
|
||||
1 files changed, 10 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
|
||||
index b6356f9..e150944 100644
|
||||
--- a/src/plugins/reporter-bugzilla.c
|
||||
+++ b/src/plugins/reporter-bugzilla.c
|
||||
@@ -389,24 +389,22 @@ int main(int argc, char **argv)
|
||||
const char *package = get_problem_item_content_or_NULL(problem_data, FILENAME_PACKAGE);
|
||||
const char *arch = get_problem_item_content_or_NULL(problem_data, FILENAME_ARCHITECTURE);
|
||||
const char *rating_str = get_problem_item_content_or_NULL(problem_data, FILENAME_RATING);
|
||||
- char *full_dsc = xasprintf("Package: %s\n"
|
||||
- "Architecture: %s\n"
|
||||
- "OS Release: %s\n"
|
||||
- "rating: %s\n"
|
||||
- "\n"
|
||||
- "Comment\n"
|
||||
- "-----\n"
|
||||
- "%s\n",
|
||||
- package, arch, release, rating_str, comment
|
||||
- );
|
||||
+
|
||||
+ struct strbuf *full_desc = strbuf_new();
|
||||
+ strbuf_append_strf(full_desc, "%s\n\n", comment);
|
||||
+ strbuf_append_strf(full_desc, "rating: %s\n", rating_str);
|
||||
+ strbuf_append_strf(full_desc, "Package: %s\n", package);
|
||||
+ strbuf_append_strf(full_desc, "Architecture: %s\n", arch);
|
||||
+ strbuf_append_strf(full_desc, "OS Release: %s\n", release);
|
||||
+
|
||||
log(_("Adding new comment to bug %d"), bz->bi_id);
|
||||
/* unused code, enable it when gui/cli will be ready
|
||||
int is_priv = is_private && string_to_bool(is_private);
|
||||
const char *is_private = get_problem_item_content_or_NULL(problem_data,
|
||||
"is_private");
|
||||
*/
|
||||
- rhbz_add_comment(client, bz->bi_id, full_dsc, 0);
|
||||
- free(full_dsc);
|
||||
+ rhbz_add_comment(client, bz->bi_id, full_desc->buf, 0);
|
||||
+ strbuf_free(full_desc);
|
||||
|
||||
unsigned rating = xatou(rating_str);
|
||||
if (bz->bi_best_bt_rating < rating)
|
||||
--
|
||||
1.7.7.3
|
||||
|
159
0005-do-not-insert-duplicate-comment-to-bugzilla.patch
Normal file
159
0005-do-not-insert-duplicate-comment-to-bugzilla.patch
Normal file
@ -0,0 +1,159 @@
|
||||
From 9786e890de57260d2975a605512147779383c137 Mon Sep 17 00:00:00 2001
|
||||
From: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
Date: Thu, 1 Dec 2011 14:48:48 +0100
|
||||
Subject: [PATCH 5/6] do not insert duplicate comment to bugzilla
|
||||
|
||||
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
---
|
||||
src/plugins/reporter-bugzilla.c | 11 +++++--
|
||||
src/plugins/rhbz.c | 60 +++++++++++++++++++++++++++++++++++----
|
||||
src/plugins/rhbz.h | 3 ++
|
||||
3 files changed, 65 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
|
||||
index e150944..9bdadba 100644
|
||||
--- a/src/plugins/reporter-bugzilla.c
|
||||
+++ b/src/plugins/reporter-bugzilla.c
|
||||
@@ -397,17 +397,22 @@ int main(int argc, char **argv)
|
||||
strbuf_append_strf(full_desc, "Architecture: %s\n", arch);
|
||||
strbuf_append_strf(full_desc, "OS Release: %s\n", release);
|
||||
|
||||
- log(_("Adding new comment to bug %d"), bz->bi_id);
|
||||
/* unused code, enable it when gui/cli will be ready
|
||||
int is_priv = is_private && string_to_bool(is_private);
|
||||
const char *is_private = get_problem_item_content_or_NULL(problem_data,
|
||||
"is_private");
|
||||
*/
|
||||
- rhbz_add_comment(client, bz->bi_id, full_desc->buf, 0);
|
||||
+
|
||||
+ int allow_comment = is_comment_dup(bz->bi_comments, full_desc->buf);
|
||||
+ if (!allow_comment)
|
||||
+ {
|
||||
+ log(_("Adding new comment to bug %d"), bz->bi_id);
|
||||
+ rhbz_add_comment(client, bz->bi_id, full_desc->buf, 0);
|
||||
+ }
|
||||
strbuf_free(full_desc);
|
||||
|
||||
unsigned rating = xatou(rating_str);
|
||||
- if (bz->bi_best_bt_rating < rating)
|
||||
+ if (!allow_comment && (bz->bi_best_bt_rating < rating))
|
||||
{
|
||||
char bug_id_str[sizeof(int)*3 + 2];
|
||||
sprintf(bug_id_str, "%i", bz->bi_id);
|
||||
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
|
||||
index 3662816..4c3c91f 100644
|
||||
--- a/src/plugins/rhbz.c
|
||||
+++ b/src/plugins/rhbz.c
|
||||
@@ -45,17 +45,17 @@ void free_bug_info(struct bug_info *bi)
|
||||
free(bi);
|
||||
}
|
||||
|
||||
-static unsigned find_best_bt_rating_in_comments(xmlrpc_value *result_xml)
|
||||
+static GList *parse_comments(xmlrpc_value *result_xml)
|
||||
{
|
||||
+ GList *comments = NULL;
|
||||
xmlrpc_value *comments_memb = rhbz_get_member("longdescs", result_xml);
|
||||
if (!comments_memb)
|
||||
- return 0;
|
||||
+ return NULL;
|
||||
|
||||
int comments_memb_size = rhbz_array_size(comments_memb);
|
||||
|
||||
xmlrpc_env env;
|
||||
xmlrpc_env_init(&env);
|
||||
- int best_bt_rating = 0;
|
||||
for (int i = 0; i < comments_memb_size; ++i)
|
||||
{
|
||||
xmlrpc_value* item = NULL;
|
||||
@@ -65,8 +65,55 @@ static unsigned find_best_bt_rating_in_comments(xmlrpc_value *result_xml)
|
||||
|
||||
char *comment_body = rhbz_bug_read_item("body", item, RHBZ_READ_STR);
|
||||
/* attachments are sometimes without comments -- skip them */
|
||||
- if (!comment_body)
|
||||
- continue;
|
||||
+ if (comment_body)
|
||||
+ comments = g_list_prepend(comments, comment_body);
|
||||
+ }
|
||||
+
|
||||
+ return g_list_reverse(comments);
|
||||
+}
|
||||
+
|
||||
+static char *trim_all_whitespace(const char *str)
|
||||
+{
|
||||
+ char *trim = xzalloc(sizeof(char) * strlen(str) + 1);
|
||||
+ int i = 0;
|
||||
+ while (*str)
|
||||
+ {
|
||||
+ if (!isspace(*str))
|
||||
+ trim[i++] = *str;
|
||||
+ str++;
|
||||
+ }
|
||||
+
|
||||
+ return trim;
|
||||
+}
|
||||
+
|
||||
+int is_comment_dup(GList *comments, const char *comment)
|
||||
+{
|
||||
+ for (GList *l = comments; l; l = l->next)
|
||||
+ {
|
||||
+ char *comment_body = (char *) l->data;
|
||||
+ char *trim_comment_body = trim_all_whitespace(comment_body);
|
||||
+ char *trim_comment = trim_all_whitespace(comment);
|
||||
+ if (!strcmp(trim_comment_body, trim_comment))
|
||||
+ {
|
||||
+ free(trim_comment_body);
|
||||
+ free(trim_comment);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return 0;;
|
||||
+}
|
||||
+
|
||||
+static unsigned find_best_bt_rating_in_comments(GList *comments)
|
||||
+{
|
||||
+ if (!comments)
|
||||
+ return 0;
|
||||
+
|
||||
+ int best_bt_rating = 0;
|
||||
+
|
||||
+ for (GList *l = comments; l; l = l->next)
|
||||
+ {
|
||||
+ char *comment_body = (char *) l->data;
|
||||
|
||||
char *start_rating_line = strstr(comment_body, "rating: ");
|
||||
if (!start_rating_line)
|
||||
@@ -324,7 +371,8 @@ struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id)
|
||||
|
||||
bz->bi_cc_list = rhbz_bug_cc(xml_bug_response);
|
||||
|
||||
- bz->bi_best_bt_rating = find_best_bt_rating_in_comments(xml_bug_response);
|
||||
+ bz->bi_comments = parse_comments(xml_bug_response);
|
||||
+ bz->bi_best_bt_rating = find_best_bt_rating_in_comments(bz->bi_comments);
|
||||
|
||||
xmlrpc_DECREF(xml_bug_response);
|
||||
|
||||
diff --git a/src/plugins/rhbz.h b/src/plugins/rhbz.h
|
||||
index 9878dd7..141db7d 100644
|
||||
--- a/src/plugins/rhbz.h
|
||||
+++ b/src/plugins/rhbz.h
|
||||
@@ -56,6 +56,7 @@ struct bug_info {
|
||||
char *bi_product;
|
||||
|
||||
GList *bi_cc_list;
|
||||
+ GList *bi_comments;
|
||||
};
|
||||
|
||||
struct bug_info *new_bug_info();
|
||||
@@ -94,6 +95,8 @@ int rhbz_attach_blob(struct abrt_xmlrpc *ax, const char *filename,
|
||||
int rhbz_attach_fd(struct abrt_xmlrpc *ax, const char *filename,
|
||||
const char *bug_id, int fd, int flags);
|
||||
|
||||
+int is_comment_dup(GList *comments, const char *comment);
|
||||
+
|
||||
GList *rhbz_bug_cc(xmlrpc_value *result_xml);
|
||||
|
||||
struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id);
|
||||
--
|
||||
1.7.7.3
|
||||
|
@ -0,0 +1,27 @@
|
||||
From 7e9ef41bcb10d13d550d6f983c9872d9c1fe19d5 Mon Sep 17 00:00:00 2001
|
||||
From: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
Date: Wed, 7 Dec 2011 14:53:04 +0100
|
||||
Subject: [PATCH 6/6] if OSRelease environ is empty, load OSRelease from
|
||||
problem-dir
|
||||
|
||||
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
|
||||
---
|
||||
src/plugins/reporter-bugzilla.c | 2 +-
|
||||
1 files changed, 1 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
|
||||
index 9bdadba..001cbd9 100644
|
||||
--- a/src/plugins/reporter-bugzilla.c
|
||||
+++ b/src/plugins/reporter-bugzilla.c
|
||||
@@ -265,7 +265,7 @@ int main(int argc, char **argv)
|
||||
const char *duphash = get_problem_item_content_or_NULL(problem_data, FILENAME_DUPHASH);
|
||||
//COMPAT, remove after 2.1 release
|
||||
if (!duphash) duphash = get_problem_item_content_or_die(problem_data, "global_uuid");
|
||||
- if (!release) /* if not overridden... */
|
||||
+ if (!release || !*release) /* if not overridden or empty... */
|
||||
{
|
||||
release = get_problem_item_content_or_NULL(problem_data, FILENAME_OS_RELEASE);
|
||||
//COMPAT, remove in abrt-2.1
|
||||
--
|
||||
1.7.7.3
|
||||
|
@ -5,11 +5,17 @@
|
||||
Summary: Generic library for reporting various problems
|
||||
Name: libreport
|
||||
Version: 2.0.8
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: GPLv2+
|
||||
Group: System Environment/Libraries
|
||||
URL: https://fedorahosted.org/abrt/
|
||||
Source: https://fedorahosted.org/released/abrt/%{name}-%{version}.tar.gz
|
||||
Patch0: 0001-allow-to-specify-bodh-url-and-fix-one-NULL-dereferen.patch
|
||||
Patch1: 0002-if-better-backtrace-is-avail-then-upload-one.patch
|
||||
Patch2: 0003-search-only-by-duphash-for-selinux.patch
|
||||
Patch3: 0004-reorganize-comments-for-bugzilla-message-body-comes-.patch
|
||||
Patch4: 0005-do-not-insert-duplicate-comment-to-bugzilla.patch
|
||||
Patch5: 0006-if-OSRelease-environ-is-empty-load-OSRelease-from-pr.patch
|
||||
BuildRequires: dbus-devel
|
||||
BuildRequires: gtk2-devel
|
||||
BuildRequires: curl-devel
|
||||
@ -210,6 +216,12 @@ Plugin to report bugs into anonymous FTP site associated with ticketing system.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
|
||||
%build
|
||||
autoconf
|
||||
@ -372,6 +384,13 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
|
||||
%config(noreplace) %{_sysconfdir}/libreport/events.d/uploader_event.conf
|
||||
|
||||
%changelog
|
||||
* Thu Dec 08 2011 Jiri Moskovcak <jmoskovc@redhat.com> 2.0.8-2
|
||||
- fixed crash in bodhi plugin
|
||||
- re-upload better backtrace if available
|
||||
- fixed dupe finding for selinux
|
||||
- don't duplicate comments in bugzilla
|
||||
- fixed problem with empty release
|
||||
|
||||
* Tue Dec 06 2011 Jiri Moskovcak <jmoskovc@redhat.com> 2.0.8-1
|
||||
- new version
|
||||
- added bodhi plugin rhbz#655783
|
||||
|
Loading…
Reference in New Issue
Block a user