|
|
baab13 |
From 7966e5737e8d3af43b1ecdd6a823234b8d25931d Mon Sep 17 00:00:00 2001
|
|
|
baab13 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
baab13 |
Date: Wed, 22 Jan 2014 22:16:22 +0100
|
|
|
baab13 |
Subject: [ABRT PATCH 16/16] cli list: show a hint about creating a case in
|
|
|
baab13 |
RHTS
|
|
|
baab13 |
|
|
|
baab13 |
Resolves rhbz#1055565
|
|
|
baab13 |
|
|
|
baab13 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
baab13 |
---
|
|
|
baab13 |
configure.ac | 2 ++
|
|
|
baab13 |
src/cli/Makefile.am | 3 ++-
|
|
|
baab13 |
src/cli/list.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
baab13 |
3 files changed, 53 insertions(+), 1 deletion(-)
|
|
|
baab13 |
|
|
|
baab13 |
diff --git a/configure.ac b/configure.ac
|
|
|
baab13 |
index 479289c..3bd13bc 100644
|
|
|
baab13 |
--- a/configure.ac
|
|
|
baab13 |
+++ b/configure.ac
|
|
|
baab13 |
@@ -137,6 +137,7 @@ PLUGINS_CONF_DIR='${sysconfdir}/${PACKAGE_NAME}/plugins'
|
|
|
baab13 |
DEFAULT_PLUGINS_CONF_DIR='${datadir}/${PACKAGE_NAME}/conf.d/plugins'
|
|
|
baab13 |
EVENTS_DIR='${datadir}/libreport/events'
|
|
|
baab13 |
EVENTS_CONF_DIR='${sysconfdir}/libreport/events.d'
|
|
|
baab13 |
+WORKFLOWS_DIR='${datadir}/libreport/workflows'
|
|
|
baab13 |
ENABLE_SOCKET_OR_DBUS='-DENABLE_DBUS=1'
|
|
|
baab13 |
DEFAULT_DUMP_DIR_MODE=$($PKG_CONFIG --variable=dd_mode libreport)
|
|
|
baab13 |
LIBREPORT_PLUGINS_CONF_DIR=$($PKG_CONFIG --variable=plugins_conf_dir libreport)
|
|
|
baab13 |
@@ -224,6 +225,7 @@ AC_SUBST(VAR_RUN)
|
|
|
baab13 |
AC_SUBST(PLUGINS_CONF_DIR)
|
|
|
baab13 |
AC_SUBST(DEFAULT_PLUGINS_CONF_DIR)
|
|
|
baab13 |
AC_SUBST(EVENTS_CONF_DIR)
|
|
|
baab13 |
+AC_SUBST(WORKFLOWS_DIR)
|
|
|
baab13 |
AC_SUBST(EVENTS_DIR)
|
|
|
baab13 |
AC_SUBST(DEFAULT_DUMP_LOCATION)
|
|
|
baab13 |
AC_SUBST(DEFAULT_DUMP_DIR_MODE)
|
|
|
baab13 |
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
|
|
|
baab13 |
index 5b840ee..75efac5 100644
|
|
|
baab13 |
--- a/src/cli/Makefile.am
|
|
|
baab13 |
+++ b/src/cli/Makefile.am
|
|
|
baab13 |
@@ -15,7 +15,8 @@ abrt_cli_SOURCES = $(CLI_C) $(BUILTIN_C) builtin-cmd.h abrt-cli-core.h
|
|
|
baab13 |
abrt_cli_CFLAGS = \
|
|
|
baab13 |
-I$(srcdir)/../include \
|
|
|
baab13 |
-I$(srcdir)/../lib \
|
|
|
baab13 |
- $(LIBREPORT_CFLAGS)
|
|
|
baab13 |
+ $(LIBREPORT_CFLAGS) \
|
|
|
baab13 |
+ -DWORKFLOWS_DIR=\"${WORKFLOWS_DIR}\"
|
|
|
baab13 |
|
|
|
baab13 |
if SUGGEST_AUTOREPORTING
|
|
|
baab13 |
abrt_cli_CFLAGS += -DSUGGEST_AUTOREPORTING=1
|
|
|
baab13 |
diff --git a/src/cli/list.c b/src/cli/list.c
|
|
|
baab13 |
index 2eefcfe..b6b4790 100644
|
|
|
baab13 |
--- a/src/cli/list.c
|
|
|
baab13 |
+++ b/src/cli/list.c
|
|
|
baab13 |
@@ -80,6 +80,55 @@ static void print_crash(problem_data_t *problem_data, int detailed, int text_siz
|
|
|
baab13 |
/*names_to_skip:*/ NULL,
|
|
|
baab13 |
/*max_text_size:*/ text_size,
|
|
|
baab13 |
MAKEDESC_SHOW_ONLY_LIST | MAKEDESC_SHOW_URLS);
|
|
|
baab13 |
+
|
|
|
baab13 |
+ /*
|
|
|
baab13 |
+ * If the problem is reportable and has not yet been reported into RHTS
|
|
|
baab13 |
+ * and there is at least one applicable Workflow which contains
|
|
|
baab13 |
+ * 'report_RHTSupport' event, then append a short message informing
|
|
|
baab13 |
+ * user that he can create a new case in Red Hat Customer Portal.
|
|
|
baab13 |
+ */
|
|
|
baab13 |
+ const char *const not_reportable = problem_data_get_content_or_NULL(problem_data, FILENAME_NOT_REPORTABLE);
|
|
|
baab13 |
+ const char *const reported_to = not_reportable ? NULL : problem_data_get_content_or_NULL(problem_data, FILENAME_REPORTED_TO);
|
|
|
baab13 |
+ report_result_t *const report = !reported_to ? NULL : find_in_reported_to_data(reported_to, "RHTSupport");
|
|
|
baab13 |
+
|
|
|
baab13 |
+ if (!not_reportable && !report)
|
|
|
baab13 |
+ {
|
|
|
baab13 |
+ /* The lines below should be replaced by something simpler, I'd
|
|
|
baab13 |
+ * like to see:
|
|
|
baab13 |
+ * GHashTable *possible_worfklows = load_applicable_workflows_for_dump();
|
|
|
baab13 |
+ *
|
|
|
baab13 |
+ * However, this feature (rhbz#1055565) is intended for RHEL only
|
|
|
baab13 |
+ * and I'm not sure whether it's worth to file another bug against
|
|
|
baab13 |
+ * libreport and try to improve libreport public API.
|
|
|
baab13 |
+ */
|
|
|
baab13 |
+ const char *const dump_dir_name = problem_data_get_content_or_NULL(problem_data, CD_DUMPDIR);
|
|
|
baab13 |
+ GList *const wf_names = list_possible_events_glist(dump_dir_name, "workflow");
|
|
|
baab13 |
+ GHashTable *const possible_workflows = load_workflow_config_data_from_list(wf_names, WORKFLOWS_DIR);
|
|
|
baab13 |
+ g_list_free_full(wf_names, free);
|
|
|
baab13 |
+
|
|
|
baab13 |
+ int event_found = 0;
|
|
|
baab13 |
+
|
|
|
baab13 |
+ GHashTableIter iter;
|
|
|
baab13 |
+ gpointer key = NULL;
|
|
|
baab13 |
+ gpointer value = NULL;
|
|
|
baab13 |
+
|
|
|
baab13 |
+ g_hash_table_iter_init(&iter, possible_workflows);
|
|
|
baab13 |
+ while (!event_found && g_hash_table_iter_next(&iter, &key, &value))
|
|
|
baab13 |
+ {
|
|
|
baab13 |
+ GList *const event_names = wf_get_event_names((workflow_t *)value);
|
|
|
baab13 |
+ event_found = !!g_list_find_custom(event_names, "report_RHTSupport", (GCompareFunc)g_strcmp0);
|
|
|
baab13 |
+ g_list_free_full(event_names, free);
|
|
|
baab13 |
+ }
|
|
|
baab13 |
+
|
|
|
baab13 |
+ g_hash_table_destroy(possible_workflows);
|
|
|
baab13 |
+
|
|
|
baab13 |
+ if (event_found)
|
|
|
baab13 |
+ {
|
|
|
baab13 |
+ char *tmp = xasprintf("%sRun 'abrt-cli report %s' for creating a case in Red Hat Customer Portal\n", desc, dump_dir_name);
|
|
|
baab13 |
+ free(desc);
|
|
|
baab13 |
+ desc = tmp;
|
|
|
baab13 |
+ }
|
|
|
baab13 |
+ }
|
|
|
baab13 |
}
|
|
|
baab13 |
fputs(desc, stdout);
|
|
|
baab13 |
free(desc);
|
|
|
baab13 |
--
|
|
|
baab13 |
1.8.3.1
|
|
|
baab13 |
|