|
|
10661d |
From 16b6963ef5e37805d2587684f90d2c6d5dd4ffdc Mon Sep 17 00:00:00 2001
|
|
|
10661d |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
10661d |
Date: Thu, 6 Dec 2018 17:57:59 +0100
|
|
|
10661d |
Subject: [PATCH] cli list: show a hint about creating a case in RHTS
|
|
|
10661d |
|
|
|
10661d |
Adds "Run 'abrt-cli report ...' for creating a case in Red Hat Customer Portal" to
|
|
|
10661d |
abrt-cli list output.
|
|
|
10661d |
|
|
|
10661d |
Resolves: #1649753
|
|
|
10661d |
|
|
|
10661d |
(cherry-picked from 7966e5737e8d3af43b1ecdd6a823234b8d25931d)
|
|
|
10661d |
|
|
|
10661d |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
10661d |
---
|
|
|
10661d |
configure.ac | 2 ++
|
|
|
10661d |
src/cli/Makefile.am | 3 ++-
|
|
|
10661d |
src/cli/list.c | 49 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
10661d |
3 files changed, 53 insertions(+), 1 deletion(-)
|
|
|
10661d |
|
|
|
10661d |
diff --git a/configure.ac b/configure.ac
|
|
|
10661d |
index 76e0f274b..5d70bb9a8 100644
|
|
|
10661d |
--- a/configure.ac
|
|
|
10661d |
+++ b/configure.ac
|
|
|
10661d |
@@ -246,6 +246,7 @@ DEFAULT_PLUGINS_CONF_DIR='${datadir}/${PACKAGE_NAME}/conf.d/plugins'
|
|
|
10661d |
EVENTS_DIR='${datadir}/libreport/events'
|
|
|
10661d |
EVENTS_CONF_DIR='${sysconfdir}/libreport/events.d'
|
|
|
10661d |
JOURNAL_CATALOG_DIR='$(prefix)/lib/systemd/catalog'
|
|
|
10661d |
+WORKFLOWS_DIR='${datadir}/libreport/workflows'
|
|
|
10661d |
ENABLE_SOCKET_OR_DBUS='-DENABLE_DBUS=1'
|
|
|
10661d |
DEFAULT_DUMP_LOCATION_MODE=0751
|
|
|
10661d |
DEFAULT_DUMP_DIR_MODE=$($PKG_CONFIG --variable=dd_mode libreport)
|
|
|
10661d |
@@ -389,6 +390,7 @@ AC_SUBST(PLUGINS_CONF_DIR)
|
|
|
10661d |
AC_SUBST(DEFAULT_PLUGINS_CONF_DIR)
|
|
|
10661d |
AC_SUBST(EVENTS_CONF_DIR)
|
|
|
10661d |
AC_SUBST(JOURNAL_CATALOG_DIR)
|
|
|
10661d |
+AC_SUBST(WORKFLOWS_DIR)
|
|
|
10661d |
AC_SUBST(EVENTS_DIR)
|
|
|
10661d |
AC_SUBST(DEFAULT_DUMP_LOCATION)
|
|
|
10661d |
AC_SUBST(DEFAULT_DUMP_LOCATION_MODE)
|
|
|
10661d |
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
|
|
|
10661d |
index 92dc20ab4..a7c76efa3 100644
|
|
|
10661d |
--- a/src/cli/Makefile.am
|
|
|
10661d |
+++ b/src/cli/Makefile.am
|
|
|
10661d |
@@ -17,7 +17,8 @@ abrt_cli_CFLAGS = \
|
|
|
10661d |
-I$(srcdir)/../include \
|
|
|
10661d |
-I$(srcdir)/../lib \
|
|
|
10661d |
$(LIBREPORT_CFLAGS) \
|
|
|
10661d |
- $(POLKIT_AGENT_CFLAGS)
|
|
|
10661d |
+ $(POLKIT_AGENT_CFLAGS) \
|
|
|
10661d |
+ -DWORKFLOWS_DIR=\"${WORKFLOWS_DIR}\"
|
|
|
10661d |
|
|
|
10661d |
if SUGGEST_AUTOREPORTING
|
|
|
10661d |
abrt_cli_CFLAGS += -DSUGGEST_AUTOREPORTING=1
|
|
|
10661d |
diff --git a/src/cli/list.c b/src/cli/list.c
|
|
|
10661d |
index d069695c6..2c140cb38 100644
|
|
|
10661d |
--- a/src/cli/list.c
|
|
|
10661d |
+++ b/src/cli/list.c
|
|
|
10661d |
@@ -77,6 +77,55 @@ static void print_crash(problem_data_t *problem_data, int detailed, int text_siz
|
|
|
10661d |
/*names_to_skip:*/ NULL,
|
|
|
10661d |
/*max_text_size:*/ text_size,
|
|
|
10661d |
MAKEDESC_SHOW_ONLY_LIST | MAKEDESC_SHOW_URLS);
|
|
|
10661d |
+
|
|
|
10661d |
+ /*
|
|
|
10661d |
+ * If the problem is reportable and has not yet been reported into RHTS
|
|
|
10661d |
+ * and there is at least one applicable Workflow which contains
|
|
|
10661d |
+ * 'report_RHTSupport' event, then append a short message informing
|
|
|
10661d |
+ * user that he can create a new case in Red Hat Customer Portal.
|
|
|
10661d |
+ */
|
|
|
10661d |
+ const char *const not_reportable = problem_data_get_content_or_NULL(problem_data, FILENAME_NOT_REPORTABLE);
|
|
|
10661d |
+ const char *const reported_to = not_reportable ? NULL : problem_data_get_content_or_NULL(problem_data, FILENAME_REPORTED_TO);
|
|
|
10661d |
+ report_result_t *const report = !reported_to ? NULL : find_in_reported_to_data(reported_to, "RHTSupport");
|
|
|
10661d |
+
|
|
|
10661d |
+ if (!not_reportable && !report)
|
|
|
10661d |
+ {
|
|
|
10661d |
+ /* The lines below should be replaced by something simpler, I'd
|
|
|
10661d |
+ * like to see:
|
|
|
10661d |
+ * GHashTable *possible_worfklows = load_applicable_workflows_for_dump();
|
|
|
10661d |
+ *
|
|
|
10661d |
+ * However, this feature (rhbz#1055565) is intended for RHEL only
|
|
|
10661d |
+ * and I'm not sure whether it's worth to file another bug against
|
|
|
10661d |
+ * libreport and try to improve libreport public API.
|
|
|
10661d |
+ */
|
|
|
10661d |
+ const char *const dump_dir_name = problem_data_get_content_or_NULL(problem_data, CD_DUMPDIR);
|
|
|
10661d |
+ GList *const wf_names = list_possible_events_glist(dump_dir_name, "workflow");
|
|
|
10661d |
+ GHashTable *const possible_workflows = load_workflow_config_data_from_list(wf_names, WORKFLOWS_DIR);
|
|
|
10661d |
+ g_list_free_full(wf_names, free);
|
|
|
10661d |
+
|
|
|
10661d |
+ int event_found = 0;
|
|
|
10661d |
+
|
|
|
10661d |
+ GHashTableIter iter;
|
|
|
10661d |
+ gpointer key = NULL;
|
|
|
10661d |
+ gpointer value = NULL;
|
|
|
10661d |
+
|
|
|
10661d |
+ g_hash_table_iter_init(&iter, possible_workflows);
|
|
|
10661d |
+ while (!event_found && g_hash_table_iter_next(&iter, &key, &value))
|
|
|
10661d |
+ {
|
|
|
10661d |
+ GList *const event_names = wf_get_event_names((workflow_t *)value);
|
|
|
10661d |
+ event_found = !!g_list_find_custom(event_names, "report_RHTSupport", (GCompareFunc)g_strcmp0);
|
|
|
10661d |
+ g_list_free_full(event_names, free);
|
|
|
10661d |
+ }
|
|
|
10661d |
+
|
|
|
10661d |
+ g_hash_table_destroy(possible_workflows);
|
|
|
10661d |
+
|
|
|
10661d |
+ if (event_found)
|
|
|
10661d |
+ {
|
|
|
10661d |
+ char *tmp = xasprintf("%sRun 'abrt-cli report %s' for creating a case in Red Hat Customer Portal\n", desc, dump_dir_name);
|
|
|
10661d |
+ free(desc);
|
|
|
10661d |
+ desc = tmp;
|
|
|
10661d |
+ }
|
|
|
10661d |
+ }
|
|
|
10661d |
}
|
|
|
10661d |
fputs(desc, stdout);
|
|
|
10661d |
free(desc);
|
|
|
10661d |
--
|
|
|
10661d |
2.17.2
|
|
|
10661d |
|