[PATCH] new bodhi plugin
by Nikola Pajkovsky
for now bodhi plugin has only two possibilities how to search updates.
1) give bodhi bugzilla id and if bz id is associate to any updates it returns
them, otherwise json-c dies on sigsegv (bug filled, but maybe I'll have to fix it)
2) give bodhi name of the package
Working on: -r, --release (f14, f15, ...); -s, --status (stable, update, pending)
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
.gitignore | 1 +
abrt.spec.in | 26 ++++-
configure.ac | 11 ++
src/plugins/Makefile.am | 57 +++++++---
src/plugins/abrt-action-bodhi.c | 241 +++++++++++++++++++++++++++++++++++++++
5 files changed, 319 insertions(+), 17 deletions(-)
create mode 100644 src/plugins/abrt-action-bodhi.c
diff --git a/.gitignore b/.gitignore
index a0c88d8..08df83f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@ src/plugins/abrt-action-generate-backtrace
src/plugins/abrt-action-upload
src/plugins/abrt-action-mailx
src/plugins/abrt-action-print
+src/plugins/abrt-action-bodhi
src/plugins/abrt-dump-oops
src/plugins/abrt-action-install-debuginfo-to-abrt-cache
src/plugins/abrt-retrace-client
diff --git a/abrt.spec.in b/abrt.spec.in
index d36a4d3..d8c05de 100644
--- a/abrt.spec.in
+++ b/abrt.spec.in
@@ -38,7 +38,7 @@ BuildRequires: asciidoc
BuildRequires: xmlto
# for rhel6
-%if 0%{?rhel} >= 6
+%if 0%{?rhel}
BuildRequires: gnome-keyring-devel
%else
BuildRequires: libgnome-keyring-devel
@@ -170,6 +170,18 @@ Requires: mailx
The simple reporter plugin which sends a report via mailx to a specified
email address.
+%if 0%{?fedora}
+%package plugin-bodhi
+Summary: %{name}'s bodhi plugin
+BuildRequires: json-c-devel
+Group: System Environment/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description plugin-bodhi
+Search for a new updates in bodhi
+%endif
+
+
%package plugin-bugzilla
Summary: %{name}'s bugzilla plugin
Group: System Environment/Libraries
@@ -264,7 +276,13 @@ generation service over a network using HTTP protocol.
%build
autoconf
+
+%if 0%{?rhel}
+%configure --disable-bodhi
+%else
%configure
+%endif
+
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
CFLAGS="-fno-strict-aliasing"
@@ -549,6 +567,12 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%{_bindir}/abrt-action-print
%{_mandir}/man*/abrt-action-print.*
+%if 0%{?fedora}
+%files plugin-bodhi
+%defattr(-,root,root,-)
+%{_bindir}/abrt-action-bodhi
+%endif
+
%files plugin-mailx
%defattr(-,root,root,-)
%{_sysconfdir}/%{name}/events/report_Mailx.xml
diff --git a/configure.ac b/configure.ac
index c568c43..71cff83 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,6 +20,9 @@ AC_ARG_ENABLE(debug,
[Enable debug information])],
[CFLAGS="$CFLAGS -DDEBUG -ggdb -g"])
+AC_ARG_ENABLE([bodhi],
+ AC_HELP_STRING([--disable-bodhi], [do not use bodhi plugin]))
+
dnl ****** INTERNATIONALIZATION **********************
GETTEXT_PACKAGE=abrt
AC_SUBST(GETTEXT_PACKAGE)
@@ -67,6 +70,14 @@ PKG_CHECK_MODULES([NSS], [nss])
PKG_CHECK_MODULES([XMLRPC], [xmlrpc])
PKG_CHECK_MODULES([XMLRPC_CLIENT], [xmlrpc_client])
PKG_CHECK_MODULES([GNOME_KEYRING], [gnome-keyring-1])
+
+AS_IF([test "x$enable_bodhi" != "xno"], [
+ dnl Do the stuff needed for enabling the feature
+ AC_DEFINE([HAVE_BODHI], [1], [Define if you have bodhi])
+ PKG_CHECK_MODULES([JSON_C], [json])
+])
+AM_CONDITIONAL(HAVE_BODHI, [test "x$enable_bodhi" != "xno"])
+
# Just PKG_CHECK_MODULES([PYTHON], [python]) works only with python2.7+
# Below, if python is not found, we set up for python2.6 w/o checking:
PKG_CHECK_MODULES([PYTHON], [python],,[
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index e3dbcff..903311f 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -7,22 +7,30 @@ bin_SCRIPTS = \
abrt-action-analyze-core.py \
abrt-action-list-dsos.py
-bin_PROGRAMS = \
- abrt-dump-oops \
- abrt-action-analyze-c \
- abrt-action-analyze-python \
- abrt-action-analyze-oops \
- abrt-action-trim-files \
- abrt-action-generate-backtrace \
- abrt-action-analyze-backtrace \
- abrt-action-bugzilla \
- abrt-action-rhtsupport \
- abrt-action-kerneloops \
- abrt-action-upload \
- abrt-action-mailx \
- abrt-action-print \
- abrt-action-install-debuginfo-to-abrt-cache \
- abrt-retrace-client
+BIN =
+
+BIN += abrt-dump-oops
+BIN += abrt-action-analyze-c
+BIN += abrt-action-analyze-python
+BIN += abrt-action-analyze-oops
+BIN += abrt-action-trim-files
+BIN += abrt-action-generate-backtrace
+BIN += abrt-action-analyze-backtrace
+BIN += abrt-action-bugzilla
+BIN += abrt-action-rhtsupport
+BIN += abrt-action-kerneloops
+BIN += abrt-action-upload
+BIN += abrt-action-mailx
+BIN += abrt-action-print
+
+if HAVE_BODHI
+BIN += abrt-action-bodhi
+endif
+
+BIN += abrt-action-install-debuginfo-to-abrt-cache
+BIN += abrt-retrace-client
+
+bin_PROGRAMS = $(BIN)
pluginsconfdir = $(PLUGINS_CONF_DIR)
@@ -260,6 +268,23 @@ abrt_action_bugzilla_LDADD = \
../lib/libabrt_web.la \
../lib/libreport.la
+if HAVE_BODHI
+abrt_action_bodhi_SOURCES = \
+ abrt-action-bodhi.c
+abrt_action_bodhi_CPPFLAGS = \
+ -I$(srcdir)/../include/report -I$(srcdir)/../include \
+ -I$(srcdir)/../lib \
+ $(GLIB_CFLAGS) \
+ $(JSON_C_CFLAGS) \
+ -D_GNU_SOURCE \
+ -Wall -Wwrite-strings
+abrt_action_bodhi_LDADD = \
+ $(GLIB_LIBS) \
+ $(JSON_C_LIBS) \
+ ../lib/libabrt_web.la \
+ ../lib/libreport.la
+endif
+
abrt_action_rhtsupport_SOURCES = \
abrt_rh_support.h abrt_rh_support.c \
abrt-action-rhtsupport.c
diff --git a/src/plugins/abrt-action-bodhi.c b/src/plugins/abrt-action-bodhi.c
new file mode 100644
index 0000000..0133da7
--- /dev/null
+++ b/src/plugins/abrt-action-bodhi.c
@@ -0,0 +1,241 @@
+/*
+ Copyright (C) 2011 ABRT team
+ Copyright (C) 2011 RedHat Inc
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include <json/json.h>
+
+#include "abrtlib.h"
+#include "abrt_curl.h"
+#include "parse_options.h"
+
+//699198,705037,705036
+
+static const char *bodhi_url = "https://admin.fedoraproject.org/updates/%s";
+
+struct bodhi {
+ const char *package_name;
+ const char *date_pushed;
+ int karma;
+
+ GList *bz_ids;
+};
+
+enum bodhi_flags {
+ BODHI_READ_STR,
+ BODHI_READ_INT,
+};
+
+static void free_bodhi_list(GList *bodhi_list)
+{
+ if (!bodhi_list)
+ return;
+
+ for (GList *li = bodhi_list; li; li = li->next)
+ {
+ struct bodhi *b = (struct bodhi *) li->data;
+ list_free_with_free(b->bz_ids);
+ free(b);
+ }
+
+ g_list_free(bodhi_list);
+}
+
+#define bodhi_read_value_int(item, bodhi, json) \
+ do { \
+ json_object *j; \
+ j = json_object_object_get((json), (item)); \
+ if (!j) \
+ error_msg_and_die("'%s' section is not available", (item)); \
+ bodhi = json_object_get_int(j); \
+ break; \
+ } while(0)
+
+#define bodhi_read_value_str(item, bodhi, json) \
+ do { \
+ json_object *j; \
+ j = json_object_object_get((json), (item)); \
+ if (!j) \
+ error_msg_and_die("'%s' section is not available", (item)); \
+ bodhi = json_object_to_json_string(j); \
+ } while(0)
+
+static void print_bodhi(struct bodhi *b)
+{
+ if (b->package_name)
+ printf("'%s'", b->package_name);
+ if (b->date_pushed)
+ printf(" '%s'", b->date_pushed);
+
+ printf(" %i", b->karma);
+
+ for (GList *li = b->bz_ids; li; li = li->next)
+ printf(" %i", *(int*) li->data);
+
+ puts("");
+}
+
+static GList *bodhi_parse_json(json_object *json)
+{
+ json_object *json_num_items = json_object_object_get(json, "num_items");
+ if (!json_num_items)
+ {
+ error_msg("'num_items' is not available");
+ return NULL;
+ }
+
+ int num_items = json_object_get_int(json_num_items);
+ if (num_items <= 0)
+ return NULL;
+
+ json_object *updates = json_object_object_get(json, "updates");
+ if (!updates)
+ {
+ error_msg("'update' section is not available");
+ return NULL;
+ }
+
+ int updates_len = json_object_array_length(updates);
+ VERB1 log("%i updates", updates_len);
+
+ GList *bodhi_list = NULL;
+ for (int i = 0; i < updates_len; ++i)
+ {
+ json_object *updates_item = json_object_array_get_idx(updates, i);
+
+ /* some of item are null */
+ if (!updates_item)
+ continue;
+
+ struct bodhi *b = xzalloc(sizeof(struct bodhi));
+ bodhi_read_value_str("title", b->package_name, updates_item);
+ bodhi_read_value_str("date_pushed", b->date_pushed, updates_item);
+ bodhi_read_value_int("karma", b->karma, updates_item);
+
+ json_object *bugs = json_object_object_get(updates_item, "bugs");
+ if (bugs)
+ {
+ for (int j = 0; j < json_object_array_length(bugs); ++j)
+ {
+ int *bz_id = xmalloc(sizeof(int));
+ json_object *bug_item = json_object_array_get_idx(bugs, j);
+ bodhi_read_value_int("bz_id", *bz_id, bug_item);
+ b->bz_ids = g_list_append(b->bz_ids, bz_id);
+ }
+ }
+
+ bodhi_list = g_list_append(bodhi_list, b);
+
+ VERB1 print_bodhi(b);
+ }
+
+ return bodhi_list;
+}
+
+static int bodhi_query_list(const char *query, const char *package)
+{
+ if (!query && !package)
+ return -1;
+
+ char *bodhi_url_bugs = xasprintf(bodhi_url, "list");
+
+ abrt_post_state_t *post_state = new_abrt_post_state(
+ ABRT_POST_WANT_BODY|ABRT_POST_WANT_SSL_VERIFY);
+
+ const char *headers[] = {
+ "Accept: application/json",
+ NULL
+ };
+
+ struct strbuf *data = strbuf_new();
+
+ if (query)
+ strbuf_append_str(data, query);
+
+ if (package && query)
+ strbuf_append_strf(data, "&package=%s", package);
+ if (package && !query)
+ strbuf_append_strf(data, "package=%s", package);
+
+ VERB1 log("data: %s", data->buf);
+
+ abrt_post_string(post_state, bodhi_url_bugs, "application/x-www-form-urlencoded",
+ headers, data->buf);
+ free(bodhi_url_bugs);
+ strbuf_free(data);
+
+ VERB3 log("%s", post_state->body);
+
+ /* when you try to search in bodhi server bug with number 'ss' (some invalid
+ * number or not associate to any updates, bodhi returns not json answer, but
+ * some html page. Bug filled here https://fedorahosted.org/bodhi/ticket/611
+ *
+ * What is worst is that json_tokener_parse() does not return NULL when
+ * invalid input is passed to function, but returns some rubbish pointer
+ * 0xfffffffffffffffc. Bug filled https://bugzilla.redhat.com/show_bug.cgi?id=709804
+ */
+ json_object *json = json_tokener_parse(post_state->body);
+ if (!json)
+ error_msg_and_die("unable parse response from bodhi server");
+
+ GList *bodhi_list = bodhi_parse_json(json);
+ free_bodhi_list(bodhi_list);
+ json_object_put(json);
+ free_abrt_post_state(post_state);
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ abrt_init(argv);
+ enum {
+ OPT_v = 1 << 0,
+ OPT_b = 1 << 1,
+ };
+
+ char *bugs = NULL;
+ /* Keep enum above and order of options below in sync! */
+ struct options program_options[] = {
+ OPT__VERBOSE(&g_verbose),
+ OPT_STRING('b', "bugs", &bugs, "id1[,id2,...]" , _("List of bug ids")),
+ OPT_END()
+ };
+
+ const char *program_usage_string = _(
+ "\b bodhi [-v] [-b] package-name package-name ...\n"
+ "\n"
+ "Search for a new updates in bodhi"
+ );
+
+ unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
+
+ int status = 0;
+
+ char *query = NULL;
+ if (opts & OPT_b)
+ query = xasprintf("bugs=%s", bugs);
+
+ if (optind < argc)
+ while (optind < argc)
+ status = bodhi_query_list(query, argv[optind++]);
+ else
+ status = bodhi_query_list(query, NULL);
+
+ free(query);
+ return 0;
+}
--
1.7.1
12 years, 6 months
[PATCH 1/3] add string_iso_date()
by Miroslav Lichvar
---
src/include/internal_libreport.h | 4 +++-
src/lib/iso_date_string.c | 10 +++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index d7b3257..616ea0d 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -533,7 +533,9 @@ char* get_environ(pid_t pid);
* Returns "YYYY-MM-DD-hh:mm:ss" string.
*/
#define iso_date_string libreport_iso_date_string
-char *iso_date_string(time_t *pt);
+char *iso_date_string(const time_t *pt);
+#define string_iso_date libreport_string_iso_date
+time_t string_iso_date(const char *date);
enum {
MAKEDESC_SHOW_FILES = (1 << 0),
diff --git a/src/lib/iso_date_string.c b/src/lib/iso_date_string.c
index e7d01cd..012ded3 100644
--- a/src/lib/iso_date_string.c
+++ b/src/lib/iso_date_string.c
@@ -19,7 +19,7 @@
#include "internal_libreport.h"
-char *iso_date_string(time_t *pt)
+char *iso_date_string(const time_t *pt)
{
static char buf[sizeof("YYYY-MM-DD-HH:MM:SS") + 4];
@@ -29,3 +29,11 @@ char *iso_date_string(time_t *pt)
return buf;
}
+
+time_t string_iso_date(const char *date)
+{
+ struct tm tm;
+ strptime(date, "%Y-%m-%d-%H:%M:%S", &tm);
+
+ return mktime(&tm);
+}
--
1.7.6
12 years, 8 months
[PATCH] [abrt] abrt-cli report @0
by Nikola Pajkovsky
abrt-cli can report problems by specifying number of crash instead of
long path name.
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/cli/Makefile.am | 3 +-
src/cli/abrt-cli-core.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++
src/cli/abrt-cli-core.h | 32 ++++++++++++++++
src/cli/list.c | 85 ++++-------------------------------------
src/cli/report.c | 36 +++++++++++++++++-
5 files changed, 173 insertions(+), 78 deletions(-)
create mode 100644 src/cli/abrt-cli-core.c
create mode 100644 src/cli/abrt-cli-core.h
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index bbd1402..3839e3c 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -4,13 +4,14 @@ bin_PROGRAMS = abrt-cli
CLI_C =
CLI_C += abrt-cli.c
+CLI_C += abrt-cli-core.c
BUILTIN_C =
BUILTIN_C += list.c
BUILTIN_C += rm.c
BUILTIN_C += report.c
-abrt_cli_SOURCES = $(CLI_C) $(BUILTIN_C) builtin-cmd.h
+abrt_cli_SOURCES = $(CLI_C) $(BUILTIN_C) builtin-cmd.h abrt-cli-core.h
abrt_cli_CFLAGS = \
-I$(srcdir)/../include \
diff --git a/src/cli/abrt-cli-core.c b/src/cli/abrt-cli-core.c
new file mode 100644
index 0000000..0221f03
--- /dev/null
+++ b/src/cli/abrt-cli-core.c
@@ -0,0 +1,95 @@
+/*
+ Copyright (C) 2011 ABRT Team
+ Copyright (C) 2011 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "abrtlib.h"
+#include "abrt-cli-core.h"
+
+/* Vector of problems: */
+/* problem_data_vector[i] = { "name" = { "content", CD_FLAG_foo_bits } } */
+
+inline problem_data_t *get_problem_data(vector_of_problem_data_t *vector, unsigned i)
+{
+ return (problem_data_t *)g_ptr_array_index(vector, i);
+}
+
+void free_vector_of_problem_data(vector_of_problem_data_t *vector)
+{
+ if (vector)
+ g_ptr_array_free(vector, TRUE);
+}
+
+vector_of_problem_data_t *new_vector_of_problem_data(void)
+{
+ return g_ptr_array_new_with_free_func((void (*)(void*)) &free_problem_data);
+}
+
+problem_data_t *fill_crash_info(const char *dump_dir_name)
+{
+ int sv_logmode = logmode;
+ logmode = 0; /* suppress EPERM/EACCES errors in opendir */
+ struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ DD_OPEN_READONLY);
+ logmode = sv_logmode;
+
+ if (!dd)
+ return NULL;
+
+ problem_data_t *problem_data = create_problem_data_from_dump_dir(dd);
+ dd_close(dd);
+ add_to_problem_data_ext(problem_data, CD_DUMPDIR, dump_dir_name,
+ CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE + CD_FLAG_LIST);
+
+ return problem_data;
+}
+
+vector_of_problem_data_t *fetch_crash_infos(GList *dir_list)
+{
+ vector_of_problem_data_t *ci = new_vector_of_problem_data();
+ for (GList *li = dir_list; li; li = li->next)
+ {
+ char *dir_name = (char *)li->data;
+ VERB1 log("Loading dumps from '%s'", dir_name);
+
+ DIR *dir = opendir(dir_name);
+ if (dir != NULL)
+ {
+ struct dirent *dent;
+ while ((dent = readdir(dir)) != NULL)
+ {
+ if (dot_or_dotdot(dent->d_name))
+ continue; /* skip "." and ".." */
+
+ char *dump_dir_name = concat_path_file(dir_name, dent->d_name);
+
+ struct stat statbuf;
+ if (stat(dump_dir_name, &statbuf) == 0
+ && S_ISDIR(statbuf.st_mode))
+ {
+ problem_data_t *problem_data = fill_crash_info(dump_dir_name);
+ if (problem_data)
+ g_ptr_array_add(ci, problem_data);
+ }
+ free(dump_dir_name);
+ }
+ closedir(dir);
+ }
+ }
+
+ return ci;
+}
+
diff --git a/src/cli/abrt-cli-core.h b/src/cli/abrt-cli-core.h
new file mode 100644
index 0000000..55a307b
--- /dev/null
+++ b/src/cli/abrt-cli-core.h
@@ -0,0 +1,32 @@
+/*
+ Copyright (C) 2011 ABRT Team
+ Copyright (C) 2011 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef ABRT_CLI_CORE_H_
+#define ABRT_CLI_CORE_H_
+
+typedef GPtrArray vector_of_problem_data_t;
+
+problem_data_t *get_problem_data(vector_of_problem_data_t *vector, unsigned i);
+
+void free_vector_of_problem_data(vector_of_problem_data_t *vector);
+vector_of_problem_data_t *new_vector_of_problem_data(void);
+problem_data_t *fill_crash_info(const char *dump_dir_name);
+vector_of_problem_data_t *fetch_crash_infos(GList *dir_list);
+
+#endif /* ABRT_CLI_CORE_H_ */
diff --git a/src/cli/list.c b/src/cli/list.c
index e4f30fe..131111a 100644
--- a/src/cli/list.c
+++ b/src/cli/list.c
@@ -18,6 +18,8 @@
*/
#include "abrtlib.h"
+
+#include "abrt-cli-core.h"
#include "builtin-cmd.h"
/* TODO: npajkovs
@@ -30,73 +32,6 @@
* ~/.abrt/spool and /var/spool/abrt? needs more _meditation_.
*/
-/* Vector of problems: */
-/* problem_data_vector[i] = { "name" = { "content", CD_FLAG_foo_bits } } */
-typedef GPtrArray vector_of_problem_data_t;
-
-static inline problem_data_t *get_problem_data(vector_of_problem_data_t *vector, unsigned i)
-{
- return (problem_data_t *)g_ptr_array_index(vector, i);
-}
-
-static void free_vector_of_problem_data(vector_of_problem_data_t *vector)
-{
- if (vector)
- g_ptr_array_free(vector, TRUE);
-}
-
-static vector_of_problem_data_t *new_vector_of_problem_data(void)
-{
- return g_ptr_array_new_with_free_func((void (*)(void*)) &free_problem_data);
-}
-
-static problem_data_t *fill_crash_info(const char *dump_dir_name)
-{
- int sv_logmode = logmode;
- logmode = 0; /* suppress EPERM/EACCES errors in opendir */
- struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ DD_OPEN_READONLY);
- logmode = sv_logmode;
-
- if (!dd)
- return NULL;
-
- problem_data_t *problem_data = create_problem_data_from_dump_dir(dd);
- dd_close(dd);
- add_to_problem_data_ext(problem_data, CD_DUMPDIR, dump_dir_name,
- CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE + CD_FLAG_LIST);
-
- return problem_data;
-}
-
-static void get_all_crash_infos(vector_of_problem_data_t *retval, const char *dir_name)
-{
- VERB1 log("Loading dumps from '%s'", dir_name);
-
- DIR *dir = opendir(dir_name);
- if (dir != NULL)
- {
- struct dirent *dent;
- while ((dent = readdir(dir)) != NULL)
- {
- if (dot_or_dotdot(dent->d_name))
- continue; /* skip "." and ".." */
-
- char *dump_dir_name = concat_path_file(dir_name, dent->d_name);
-
- struct stat statbuf;
- if (stat(dump_dir_name, &statbuf) == 0
- && S_ISDIR(statbuf.st_mode))
- {
- problem_data_t *problem_data = fill_crash_info(dump_dir_name);
- if (problem_data)
- g_ptr_array_add(retval, problem_data);
- }
- free(dump_dir_name);
- }
- closedir(dir);
- }
-}
-
/** Prints basic information about a crash to stdout. */
static void print_crash(problem_data_t *problem_data, int detailed)
{
@@ -141,6 +76,8 @@ static void print_crash_list(vector_of_problem_data_t *crash_list, int include_r
if (msg)
continue;
}
+
+ printf("@%i\n", i);
print_crash(crash, detailed);
if (i != crash_list->len - 1)
printf("\n");
@@ -187,17 +124,13 @@ int cmd_list(int argc, const char **argv)
log("\t %s", (char *) li->data);
}
- vector_of_problem_data_t *ci = new_vector_of_problem_data();
- while (D_list)
- {
- char *dir = (char *)D_list->data;
- get_all_crash_infos(ci, dir);
- D_list = g_list_remove(D_list, dir);
- free(dir);
- }
+ vector_of_problem_data_t *ci = fetch_crash_infos(D_list);
+
+ g_ptr_array_sort_with_data(ci, &cmp_problem_data, (char *) FILENAME_TIME);
+
print_crash_list(ci, opt_full, opt_detailed);
free_vector_of_problem_data(ci);
- g_list_free(D_list);
+ list_free_with_free(D_list);
return 0;
}
diff --git a/src/cli/report.c b/src/cli/report.c
index ce22456..770468a 100644
--- a/src/cli/report.c
+++ b/src/cli/report.c
@@ -18,6 +18,8 @@
*/
#include "abrtlib.h"
+
+#include "abrt-cli-core.h"
#include "builtin-cmd.h"
int cmd_report(int argc, const char **argv)
@@ -32,14 +34,46 @@ int cmd_report(int argc, const char **argv)
};
parse_opts(argc, (char **)argv, program_options, program_usage_string);
+
+ load_abrt_conf();
+ char *home = getenv("HOME");
+ GList *D_list = NULL;
+ if (home)
+ D_list = g_list_append(D_list, concat_path_file(home, ".abrt/spool"));
+ D_list = g_list_append(D_list, xstrdup(g_settings_dump_location));
+ free_abrt_conf_data();
+
if (optind < argc)
{
while (optind < argc)
{
- int status = report_problem_in_dir(argv[optind++],
+ const char *dir_name = argv[optind++];
+
+ vector_of_problem_data_t *ci = NULL;
+ if (*dir_name == '@')
+ {
+ dir_name++;
+ char *end;
+ errno = 0;
+ unsigned long at = strtoul(dir_name, &end, 10);
+ if (errno || end == dir_name || *end != '\0')
+ error_msg_and_die("error: not a number '%s'", dir_name);
+
+ ci = fetch_crash_infos(D_list);
+ if (at >= ci->len)
+ error_msg_and_die("error: number is out of range '%s'", dir_name);
+
+ g_ptr_array_sort_with_data(ci, &cmp_problem_data, (char *) FILENAME_TIME);
+ problem_data_t *pd = get_problem_data(ci, at);
+
+ dir_name = get_problem_item_content_or_NULL(pd, CD_DUMPDIR);
+ }
+
+ int status = report_problem_in_dir(dir_name,
LIBREPORT_ANALYZE
| LIBREPORT_WAIT
| LIBREPORT_RUN_CLI);
+ free_vector_of_problem_data(ci);
if (status)
exit(status);
}
--
1.7.6.345.g5c2f8
12 years, 8 months
[PATCH] Include vmcore scripts in EXTRA_DIST
by Martin Milata
There was mention that the vmcore processing is work in progress, but I
needed to apply these changes in order for 'make dist' and consequently
'make rpm' to work.
---
src/hooks/Makefile.am | 2 +-
src/plugins/Makefile.am | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am
index 4f1ad35..6715005 100644
--- a/src/hooks/Makefile.am
+++ b/src/hooks/Makefile.am
@@ -27,7 +27,7 @@ abrt_hook_ccpp_LDADD = \
$(LIBREPORT_LIBS)
python_PYTHON = abrt.pth abrt_exception_handler.py
-EXTRA_DIST = abrt_exception_handler.py.in abrt-install-ccpp-hook $(man_MANS)
+EXTRA_DIST = abrt_exception_handler.py.in abrt-install-ccpp-hook abrt-harvest-vmcore $(man_MANS)
CLEANFILES := $(notdir $(wildcard *~)) $(notdir $(wildcard *\#)) $(notdir $(wildcard \.\#*)) $(notdir $(wildcard *.pyc))
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index bf89ffc..f889356 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -75,7 +75,8 @@ CLEANFILES = $(man1_MANS)
PYTHON_FILES = \
abrt-action-install-debuginfo \
abrt-action-list-dsos \
- abrt-action-analyze-core
+ abrt-action-analyze-core \
+ abrt-action-analyze-vmcore
EXTRA_DIST = \
$(man_MANS) \
--
1.7.6
12 years, 8 months
[PATCH-libreport 0/7] Implement 'collect' events
by Martin Milata
Here are patches that implement collect events (#309). They add additional step
after analysis and before reporting phase (both in gui and cli) where user can
select collect_* events that can gather additional information from user's
system.
Smolt data and .xsession-errors collection have been rewritten as such events
and included are also two events that attach vim's configuration files when the
editor crashes.
I'll be grateful for any comments.
Martin Milata (7):
wizard: add new pages for the collect events
wizard: collect events - GUI state updating
wizard: collect events - next page selection
wizard: collect events - run selected events
report-cli: ugly hack to allow code reuse
report-cli: add getopt switches for collect action
report-cli: add support for collect events
src/cli/cli-report.c | 93 +++++++++++++++-
src/cli/cli-report.h | 1 +
src/cli/cli.c | 34 ++++--
src/gui-wizard-gtk/main.c | 3 +
src/gui-wizard-gtk/wizard.c | 227 ++++++++++++++++++++++++++++-----------
src/gui-wizard-gtk/wizard.glade | 140 +++++++++++++++++++++++-
src/gui-wizard-gtk/wizard.h | 1 +
7 files changed, 414 insertions(+), 85 deletions(-)
--
1.7.6
12 years, 8 months
Error with abrt-action-install-debuginfo on Fedora 15
by Chris Meek
Hello,
I tried running abrt-action-install-debuginfo with the -ids=- option,
providing the hex build_id on stdin on Fedora 15. I am getting an error
as follows:
$ abrt-action-install-debuginfo -y --ids=-
67b1a5daf785521a097dd1f29fe9513f60f842f0
Coredump references 1 debuginfo files, 1 of them are not installed
Looking for needed packages in repositories
Error retrieving filelists: 'failure:
repodata/6ad3ddc0b0eb5b314f41c263f9625a9528ed699d8159bebdec56203ab736ccfe-filelists.sqlite.bz2
from fedora-debuginfo: [Errno 256] No more mirrors to try.'
Missing debuginfo file:
/usr/lib/debug/.build-id/67/b1a5daf785521a097dd1f29fe9513f60f842f0.debug
But when I run abrt-action-install-debuginfo-to-abrt-cache also with
-ids=- and the
same input, it successfully downloads and installs the debuginfo.
Is there a way to get the first one to work correctly?
Thanks,
Chris
12 years, 8 months
[PATCH] improved compatibility with anaconda rhbz#725857
by Jiri Moskovcak
This patch reinstates some functions we removed from python bindings -
as it turned out, we don't have /etc/*release when anaconda is running
so we need to obtain "os_release" from anaconda and we should avoid
reading /etc/*-release, because it shows an error message on tty1:
Can't open /etc/system-release: No such file or directory
which from users POV can be considered as a bug. So this patch tries to
get the os_release from anaconda then from /etc and the function
dd_create_basic_files() now skips creating os_release if it already
exists (this check shouldn't generate any error msg if the file doesn't
exist). It also modifies create_dump_dir_from_problem_data() moving the
dd_create_basic_files() to the end when all fields from problem_data are
saved in dump_dir, so the mentioned check for "os_release" can happen.
Please review carefully, I can help with anaconda images if someone
would like to test it (I did of course ;)).
Thank you,
Jirka
12 years, 8 months
[PATCH] wizard: warning log torso
by Martin Milata
Not meant to be pushed yet.
---
src/gui-wizard-gtk/wizard.c | 13 +++++++++++++
src/gui-wizard-gtk/wizard.h | 1 +
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index aba044e..5f7a203 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -94,6 +94,8 @@ static GtkEntry *g_search_entry_bt;
static GtkBuilder *builder;
static PangoFontDescription *monospace_font;
+static GList *g_warnings = NULL;
+
/* THE PAGE FLOW
* page_5: user comments
@@ -336,6 +338,17 @@ void show_error_as_msgbox(const char *msg)
gtk_widget_destroy(dialog);
}
+void wizard_show_warning(const char *msg)
+{
+ GList *li = g_list_find_custom(g_warnings, msg, (GCompareFunc)strcmp);
+ if (li)
+ return; /* Warning already in the list */
+
+ g_warnings = g_list_append(g_warnings, xstrdup(msg));
+
+ VERB1 log("Added warning: %s", msg);
+}
+
static void load_text_to_text_view(GtkTextView *tv, const char *name)
{
GtkTextBuffer *tb = gtk_text_view_get_buffer(tv);
diff --git a/src/gui-wizard-gtk/wizard.h b/src/gui-wizard-gtk/wizard.h
index 2e1767c..8704f4c 100644
--- a/src/gui-wizard-gtk/wizard.h
+++ b/src/gui-wizard-gtk/wizard.h
@@ -24,6 +24,7 @@
void create_assistant(void);
void update_gui_state_from_problem_data(void);
void show_error_as_msgbox(const char *msg);
+void wizard_show_warning(const char *msg);
extern char *g_glade_file;
--
1.7.6
12 years, 8 months
[PATCH] a-a-save-package-data: Fix NULL dereference
by Martin Milata
Fixes #324.
---
src/daemon/abrt-action-save-package-data.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c
index d37a05d..ddcf4ac 100644
--- a/src/daemon/abrt-action-save-package-data.c
+++ b/src/daemon/abrt-action-save-package-data.c
@@ -160,7 +160,7 @@ static char *get_argv1_if_full_path(const char* cmdline)
* with '/', it is not a full path to script
* and we can't use it to determine the package name
*/
- if (*argv1 != '/')
+ if (argv1 == NULL || *argv1 != '/')
return NULL;
/* good, it has "/foo/bar" form, return it */
--
1.7.6
12 years, 8 months
[PATCH 1/2] [libreport] code was moved to abrt.git
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/cli/cli.c | 198 +++++---------------------------------------------------
1 files changed, 18 insertions(+), 180 deletions(-)
diff --git a/src/cli/cli.c b/src/cli/cli.c
index 49484c3..1fc6a9d 100644
--- a/src/cli/cli.c
+++ b/src/cli/cli.c
@@ -23,126 +23,6 @@
#include "internal_libreport.h"
#include "cli-report.h"
-
-/* Vector of problems: */
-/* problem_data_vector[i] = { "name" = { "content", CD_FLAG_foo_bits } } */
-
-typedef GPtrArray vector_of_problem_data_t;
-
-static inline problem_data_t *get_problem_data(vector_of_problem_data_t *vector, unsigned i)
-{
- return (problem_data_t *)g_ptr_array_index(vector, i);
-}
-
-static void free_vector_of_problem_data(vector_of_problem_data_t *vector)
-{
- if (vector)
- g_ptr_array_free(vector, TRUE);
-}
-
-static vector_of_problem_data_t *new_vector_of_problem_data(void)
-{
- return g_ptr_array_new_with_free_func((void (*)(void*)) &free_problem_data);
-}
-
-
-static problem_data_t *FillCrashInfo(const char *dump_dir_name)
-{
- int sv_logmode = logmode;
- logmode = 0; /* suppress EPERM/EACCES errors in opendir */
- struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ DD_OPEN_READONLY);
- logmode = sv_logmode;
-
- if (!dd)
- return NULL;
-
- problem_data_t *problem_data = create_problem_data_from_dump_dir(dd);
- dd_close(dd);
- add_to_problem_data_ext(problem_data, CD_DUMPDIR, dump_dir_name, CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE + CD_FLAG_LIST);
-
- return problem_data;
-}
-
-static void GetCrashInfos(vector_of_problem_data_t *retval, const char *dir_name)
-{
- VERB1 log("Loading dumps from '%s'", dir_name);
-
- DIR *dir = opendir(dir_name);
- if (dir != NULL)
- {
- struct dirent *dent;
- while ((dent = readdir(dir)) != NULL)
- {
- if (dot_or_dotdot(dent->d_name))
- continue; /* skip "." and ".." */
-
- char *dump_dir_name = concat_path_file(dir_name, dent->d_name);
-
- struct stat statbuf;
- if (stat(dump_dir_name, &statbuf) == 0
- && S_ISDIR(statbuf.st_mode)
- ) {
- problem_data_t *problem_data = FillCrashInfo(dump_dir_name);
- if (problem_data)
- g_ptr_array_add(retval, problem_data);
- }
- free(dump_dir_name);
- }
- closedir(dir);
- }
-}
-
-/** Prints basic information about a crash to stdout. */
-static void print_crash(problem_data_t *problem_data)
-{
- char* desc = make_description(
- problem_data,
- /*names_to_skip:*/ NULL,
- /*max_text_size:*/ CD_TEXT_ATT_SIZE,
- MAKEDESC_SHOW_ONLY_LIST
- );
- fputs(desc, stdout);
- free(desc);
-}
-
-/**
- * Prints a list containing "crashes" to stdout.
- * @param include_reported
- * Do not skip entries marked as already reported.
- */
-static void print_crash_list(vector_of_problem_data_t *crash_list, bool include_reported)
-{
- unsigned i;
- for (i = 0; i < crash_list->len; ++i)
- {
- problem_data_t *crash = get_problem_data(crash_list, i);
- if (!include_reported)
- {
- const char *msg = get_problem_item_content_or_NULL(crash, FILENAME_REPORTED_TO);
- if (msg)
- continue;
- }
-
- printf("%u.\n", i);
- print_crash(crash);
- }
-}
-
-/**
- * Prints full information about a crash
- */
-static void print_crash_info(problem_data_t *problem_data, bool show_multiline)
-{
- char* desc = make_description(
- problem_data,
- /*names_to_skip:*/ NULL,
- /*max_text_size:*/ CD_TEXT_ATT_SIZE,
- MAKEDESC_SHOW_FILES | (show_multiline ? MAKEDESC_SHOW_MULTILINE : 0)
- );
- fputs(desc, stdout);
- free(desc);
-}
-
static char *do_log(char *log_line, void *param)
{
log("%s", log_line);
@@ -165,46 +45,36 @@ int main(int argc, char** argv)
/* Can't keep these strings/structs static: _() doesn't support that */
const char *program_usage_string = _(
- "\b [-vsp] -l[f] [-D BASE_DIR]...\n"
- "or: \b [-vsp] -i[f] DUMP_DIR\n"
- "or: \b [-vsp] -L[PREFIX] [DUMP_DIR]\n"
- "or: \b [-vsp] -e EVENT DUMP_DIR\n"
- "or: \b [-vsp] -a[y] DUMP_DIR\n"
- "or: \b [-vsp] -r[y|o] DUMP_DIR\n"
- "or: \b [-vsp] -d DUMP_DIR"
+ "\b [-vsp] -L[PREFIX] [DUMP_DIR]\n"
+ " or: \b [-vsp] -e EVENT DUMP_DIR\n"
+ " or: \b [-vsp] -a[y] DUMP_DIR\n"
+ " or: \b [-vsp] -r[y|o] DUMP_DIR\n"
+ " or: \b [-vsp] -d DUMP_DIR"
);
enum {
- OPT_list = 1 << 0,
- OPT_D = 1 << 1,
- OPT_info = 1 << 2,
- OPT_list_events = 1 << 3,
- OPT_run_event = 1 << 4,
- OPT_analyze = 1 << 5,
- OPT_report = 1 << 6,
- OPT_delete = 1 << 7,
- OPT_version = 1 << 8,
- OPTMASK_op = OPT_list|OPT_info|OPT_list_events|OPT_run_event|OPT_analyze|OPT_report|OPT_version,
- OPTMASK_need_arg = OPT_info|OPT_run_event|OPT_analyze|OPT_report|OPT_delete,
- OPT_f = 1 << 9,
- OPT_y = 1 << 10,
- OPT_o = 1 << 11,
- OPT_v = 1 << 12,
- OPT_s = 1 << 13,
- OPT_p = 1 << 14,
+ OPT_list_events = 1 << 0,
+ OPT_run_event = 1 << 1,
+ OPT_analyze = 1 << 2,
+ OPT_report = 1 << 3,
+ OPT_version = 1 << 4,
+ OPT_delete = 1 << 5,
+ OPTMASK_op = OPT_list_events|OPT_run_event|OPT_analyze|OPT_report|OPT_version,
+ OPTMASK_need_arg = OPT_delete|OPT_run_event|OPT_analyze|OPT_report,
+ OPT_y = 1 << 6,
+ OPT_o = 1 << 7,
+ OPT_v = 1 << 8,
+ OPT_s = 1 << 9,
+ OPT_p = 1 << 10,
};
/* Keep enum above and order of options below in sync! */
struct options program_options[] = {
/* short_name long_name value parameter_name help */
- OPT_BOOL( 'l', "list" , NULL, _("List not yet reported problems, or all with -f")),
- OPT_LIST( 'D', NULL , &D_list, "BASE_DIR", _("Directory to list problems from (default: -D $HOME/.abrt/spool -D "DEBUG_DUMPS_DIR")")),
- OPT_BOOL( 'i', "info" , NULL, _("Print information about DUMP_DIR (detailed with -f)")),
OPT_OPTSTRING('L', NULL , &pfx, "PREFIX", _("List possible events [which start with PREFIX]")),
OPT_STRING( 'e', NULL , &event_name, "EVENT", _("Run EVENT on DUMP_DIR")),
OPT_BOOL( 'a', "analyze", NULL, _("Run analyze event(s) on DUMP_DIR")),
OPT_BOOL( 'r', "report" , NULL, _("Analyze and report problem data in DUMP_DIR")),
OPT_BOOL( 'd', "delete" , NULL, _("Remove DUMP_DIR")),
OPT_BOOL( 'V', "version", NULL, _("Display version and exit")),
- OPT_BOOL( 'f', "full" , NULL, _("Full listing")),
OPT_BOOL( 'y', "always" , NULL, _("Noninteractive: don't ask questions, assume 'yes'")),
OPT_BOOL( 'o', "report-only" , NULL, _("With -r: do not run analyzers, run only reporters")),
OPT__VERBOSE(&g_verbose),
@@ -244,7 +114,6 @@ int main(int argc, char** argv)
}
char *dump_dir_name = argv[0];
- bool full = (opts & OPT_f);
bool always = (opts & OPT_y);
bool report_only = (opts & OPT_o);
@@ -263,19 +132,6 @@ int main(int argc, char** argv)
int exitcode = 0;
switch (op)
{
- case OPT_list:
- {
- vector_of_problem_data_t *ci = new_vector_of_problem_data();
- while (D_list)
- {
- char *dir = (char *)D_list->data;
- GetCrashInfos(ci, dir);
- D_list = g_list_remove(D_list, dir);
- }
- print_crash_list(ci, full);
- free_vector_of_problem_data(ci);
- break;
- }
case OPT_list_events: /* -L[PREFIX] */
{
/* Note that dump_dir_name may be NULL here, it means "show all
@@ -345,24 +201,6 @@ int main(int argc, char** argv)
error_msg_and_die("Crash '%s' not found", dump_dir_name);
break;
}
- case OPT_info:
- {
- /* Load problem_data from dump dir */
- struct dump_dir *dd = dd_opendir(dump_dir_name, DD_OPEN_READONLY);
- if (!dd)
- return -1;
-
- problem_data_t *problem_data = create_problem_data_from_dump_dir(dd);
- dd_close(dd);
-
- add_to_problem_data_ext(problem_data, CD_DUMPDIR, dump_dir_name,
- CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE);
-
- print_crash_info(problem_data, full);
- free_problem_data(problem_data);
-
- break;
- }
}
if (opts & OPT_delete)
--
1.7.6.345.g5c2f8
12 years, 8 months