bugzilla: put VARIANT_ID= to Whiteboard

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
This commit is contained in:
Matej Habrnal 2015-09-15 11:02:40 +02:00
parent 9926ac3d6a
commit 90e88e5a1d
2 changed files with 85 additions and 1 deletions

View File

@ -0,0 +1,79 @@
From fdf8665e241190d1a7406ae2958e88d17f9b372b Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Tue, 1 Sep 2015 14:56:21 +0200
Subject: [PATCH] bugzilla: put VARIANT_ID= to Whiteboard
Parse /etc/os-release ('os-info' element), read VARIANT_ID and put its
value to Whiteboard of the newly created bug.
This commit allows users to search for ";VARIANT_ID=$ID;".
Related to abrt/abrt#995
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
src/plugins/rhbz.c | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index a376c13..c4af091 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -520,7 +520,35 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
char *summary = shorten_string_to_length(bzsummary, MAX_SUMMARY_LENGTH);
- char *status_whiteboard = xasprintf("abrt_hash:%s", duphash);
+ struct strbuf *status_whiteboard = strbuf_new();
+ strbuf_append_strf(status_whiteboard, "abrt_hash:%s;", duphash);
+
+ { /* Add fields from /etc/os-release to Whiteboard for simple metrics. */
+ map_string_t *osinfo = new_map_string();
+ problem_data_get_osinfo(problem_data, osinfo);
+
+ /* This is the highest abstraction level I am willing to introduce now.
+ *
+ * The lines below can be either reduced to the body of the for loop
+ * or the opts variable can be dynamically initialized
+ * or you can simply add an another /etc/os-release option name
+ * (e.g. BUILD_ID).
+ */
+ const char *const opts[] = { "VARIANT_ID", NULL };
+ for (const char *const *iter = opts; *iter != NULL; ++iter)
+ {
+ const char *v = get_map_string_item_or_NULL(osinfo, *iter);
+ if (v != NULL)
+ {
+ /* semi-colon (;) is the delimiter because /etc/os-release *_ID
+ * options does not permit the ';' character in values
+ */
+ strbuf_append_strf(status_whiteboard, "%s=%s;", *iter, v);
+ }
+ }
+
+ free_map_string(osinfo);
+ }
xmlrpc_env env;
xmlrpc_env_init(&env);
@@ -532,7 +560,7 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
abrt_xmlrpc_params_add_string(&env, params, "version", version);
abrt_xmlrpc_params_add_string(&env, params, "summary", summary);
abrt_xmlrpc_params_add_string(&env, params, "description", bzcomment);
- abrt_xmlrpc_params_add_string(&env, params, "status_whiteboard", status_whiteboard);
+ abrt_xmlrpc_params_add_string(&env, params, "status_whiteboard", status_whiteboard->buf);
if(arch)
abrt_xmlrpc_params_add_string(&env, params, "platform", arch);
@@ -562,7 +590,7 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
xmlrpc_DECREF(params);
xmlrpc_env_clean(&env);
- free(status_whiteboard);
+ strbuf_free(status_whiteboard);
free(summary);
if (!result)
--
2.5.0

View File

@ -7,7 +7,7 @@
Summary: Generic library for reporting various problems
Name: libreport
Version: 2.6.2
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv2+
Group: System Environment/Libraries
URL: https://abrt.readthedocs.org/
@ -21,6 +21,8 @@ Patch0002: 0002-dd-stop-warning-about-corrupted-mandatory-files.patch
Patch0003: 0003-dd-don-t-warn-about-missing-type-if-the-locking-fail.patch
Patch0004: 0004-curl-add-a-helper-for-HTTP-GET.patch
Patch0005: 0005-configure-use-hex-value-for-dump-dir-mode.patch
#Patch0006: 0006-autogen-use-dnf-instead-of-yum-to-install-dependenci.patch
Patch0007: 0007-bugzilla-put-VARIANT_ID-to-Whiteboard.patch
# git is need for '%%autosetup -S git' which automatically applies all the
# patches above. Please, be aware that the patches must be generated
@ -737,6 +739,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%changelog
* Tue Sep 15 2015 Matej Habrnal <mhabrnal@redhat.com> 2.6.2-5
- bugzilla: put VARIANT_ID= to Whiteboard
* Wed Aug 26 2015 Matej Habrnal <mhabrnal@redhat.com> 2.6.2-4
- add a helper for HTTP GET
- configure: use hex value for dump dir mode