[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
Re: [HEADS-UP] replacing report with libreport
by Jiri Moskovcak
On 06/29/2011 01:16 PM, Daniel J Walsh wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 06/29/2011 05:50 AM, Jiri Moskovcak wrote:
>> Hi!
>> I'm going to replace the report library with the new libreport. Today I
>> plan to replace it in rawhide and if it goes smoothly I'd like to
>> replace it in F15 as well.
>>
> Hasn't this already reached F15? Have you readded the GTKIO stuff?
>> pros:
>> - libreport is written in C (report is in python), so it's easier to
>> write bindings for other languages
>> - it's API compatible with report (it has python bindings)
>> - it shares configuration with ABRT, so users just need to write their
>> credentials and defaults only once
>> - shares the UI with ABRT (the reporting wizard), so users are presented
>> with the same UI despite of from where they are reporting a problem
>>
>> cons:
>> - it has a bit different UI
>> - account information (e.g: bz loging+password) is forgotten and needs
>> to be entered again
> Why? Is it remembered within the session? Can't it save the bugzilla
> info within the gnome-keyring?
>> - some minor breakage expected (hopefully not...)
>>
>>
>> affected packages (according to repoquery):
>> - report + subpackages (being obsoleted)
>> - python-meh
>> - anaconda
>> - anaconda-0:15.31-1.fc15.x86_64
>> - firstboot-0:1.119-1.fc15.x86_64
>> - system-config-kickstart-0:2.8.7-2.fc15.noarch
>> - setroubleshoot
>>
>> As I said, libreport should be API compatible with report, so no changes
>> should needed, but of course can't be 100% sure if it's bugfree ;)
>
> Do we have to do anything to our packages to make this work?
- mentioned packages should change:
Requires: report{-gtk} to Requires: libreport{-gtk}
- but that's not needed right now since libreport provides report{-gtk}
- the references to report should be removed once we're done with the
transition
12 years, 9 months
[HEADS-UP] replacing report with libreport
by Jiri Moskovcak
Hi!
I'm going to replace the report library with the new libreport. Today I
plan to replace it in rawhide and if it goes smoothly I'd like to
replace it in F15 as well.
pros:
- libreport is written in C (report is in python), so it's easier to
write bindings for other languages
- it's API compatible with report (it has python bindings)
- it shares configuration with ABRT, so users just need to write their
credentials and defaults only once
- shares the UI with ABRT (the reporting wizard), so users are presented
with the same UI despite of from where they are reporting a problem
cons:
- it has a bit different UI
- account information (e.g: bz loging+password) is forgotten and needs
to be entered again
- some minor breakage expected (hopefully not...)
affected packages (according to repoquery):
- report + subpackages (being obsoleted)
- python-meh
- anaconda
- anaconda-0:15.31-1.fc15.x86_64
- firstboot-0:1.119-1.fc15.x86_64
- system-config-kickstart-0:2.8.7-2.fc15.noarch
- setroubleshoot
As I said, libreport should be API compatible with report, so no changes
should needed, but of course can't be 100% sure if it's bugfree ;)
12 years, 9 months
[PROPOSAL] Infrastructure for tests
by Michal Nowak
Last two weeks I worked on test infrastructure proposal and
implementation.
The idea is to build ABRT & libreport (and perhaps others related
components), run tests daily and report results to mailing list.
Currently we have ~15 tests range from executing internal test
suites to regression coverage of bugs from Red Hat Bugzilla, as
well as some sanity tests.
How is it expected to work?
===========================
At 2 AM Cron [1] executes `run-abrt-nightly-tests.sh', which installs
Virtual Machine with Fedora 15 by a Kickstart [2] and powers-on the
VM, if was not running (login: root password: redhat).
[1] E.g.: >>> 0 2 * * * root /home/newman/bin/run-abrt-nightly-tests.sh
[2] Currently: http://mnowak.fedorapeople.org/anaconda-ks.cfg
The Kickstart file provides Anaconda all the info, so it can install
w/o user interaction. Also it should provide most of the packages
the tests need to run.
Part of the Kickstart is Cron job installation[3] which executes
`abrt-nightly-test.sh' [4] at 3 AM which starts and logs all the
tests.
[3] 0 3 * * * root /usr/local/share/abrt-tests/abrt-nightly-test.sh | tee -a /tmp/abrt-nightly-test.log
[4] Currently: http://mnowak.fedorapeople.org/abrt/abrt-tests.tar.xz
First, `abrt-nightly-build.sh' [4] builds and installs ABRT and
libreport from Git, if this fails, everything fails. Then, all other
tests are alphabetically executed, one by one.
Summary [5] and complete log [6] is sent to this mailing-list
(currently I am not sure how to reliably send emails because mailx
succeeds in sending email but the email is not delivered then).
[5] "abrt-test-output.summary" in abrt-TESTOUT.tar.xz
[6] abrt-nightly-test.log.xz
What's needed?
- public machine capable of running VM connected to the Internet
- more tests
- integration to upstream Git
Ideas? Comments? Patches?
Michal
12 years, 9 months
[PATCH] [abrt] bring back to live abrt-cli
by Nikola Pajkovsky
abrt-cli uses commands now instead of switches for main purpose.
Usage string for abrt-cli:
abrt-cli [--version] [--base-dir=DUMP_DIR] <command> [<args>]
--base-dir - change base dir for dump directories
--version - print out version and die
commands are:
list
delete
report
Each command can take it's own arguments.
list command takes two switches -d -f, where -d behaves as old --info switch. Show
more detailed information about crash (all if not specified exactly dump-dir) and
with -f switch shows even multiline files from dump-dir
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
abrt.spec.in | 4 +-
configure.ac | 1 +
src/Makefile.am | 2 +-
src/cli/Makefile.am | 25 ++++++
src/cli/abrt-cli.c | 146 ++++++++++++++++++++++++++++++++++
src/cli/builtin-cmd.h | 27 +++++++
src/cli/list.c | 206 +++++++++++++++++++++++++++++++++++++++++++++++++
src/cli/report.c | 45 +++++++++++
src/cli/rm.c | 53 +++++++++++++
9 files changed, 506 insertions(+), 3 deletions(-)
create mode 100644 src/cli/Makefile.am
create mode 100644 src/cli/abrt-cli.c
create mode 100644 src/cli/builtin-cmd.h
create mode 100644 src/cli/list.c
create mode 100644 src/cli/report.c
create mode 100644 src/cli/rm.c
diff --git a/abrt.spec.in b/abrt.spec.in
index 2f53f76..351eb5e 100644
--- a/abrt.spec.in
+++ b/abrt.spec.in
@@ -235,8 +235,6 @@ mkdir -p $RPM_BUILD_ROOT/var/cache/abrt-di
mkdir -p $RPM_BUILD_ROOT/var/run/abrt
mkdir -p $RPM_BUILD_ROOT/var/spool/abrt
mkdir -p $RPM_BUILD_ROOT/var/spool/abrt-upload
-# compat before we split abrt-cli and report-cli
-ln -s %{_bindir}/report-cli $RPM_BUILD_ROOT/%{_bindir}/abrt-cli
desktop-file-install \
--dir ${RPM_BUILD_ROOT}%{_datadir}/applications \
@@ -513,6 +511,8 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%files cli
%defattr(-,root,root,-)
%{_bindir}/abrt-cli
+# provide asap
+#% {_mandir}/man1/report-cli.1.gz
%files desktop
%defattr(-,root,root,-)
diff --git a/configure.ac b/configure.ac
index baf0f01..3b2a669 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,7 @@ AC_CONFIG_FILES([
src/hooks/abrt-install-ccpp-hook
src/applet/Makefile
src/gui-gtk/Makefile
+ src/cli/Makefile
po/Makefile.in
icons/Makefile
])
diff --git a/src/Makefile.am b/src/Makefile.am
index b41b939..ab95ef7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1 +1 @@
-SUBDIRS = include lib hooks daemon applet gui-gtk plugins
+SUBDIRS = include lib hooks daemon applet gui-gtk plugins cli
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
new file mode 100644
index 0000000..c5ebc14
--- /dev/null
+++ b/src/cli/Makefile.am
@@ -0,0 +1,25 @@
+-include ../../config.mak
+
+bin_PROGRAMS = abrt-cli
+
+CLI_C =
+CLI_C += abrt-cli.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_CFLAGS = \
+ -I$(srcdir)/../include \
+ -I$(srcdir)/../lib \
+ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \
+ $(LIBREPORT_CFLAGS) \
+ -Wwrite-strings -Werror
+
+abrt_cli_LDADD = \
+ $(LIBREPORT_LIBS)
+
+DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
diff --git a/src/cli/abrt-cli.c b/src/cli/abrt-cli.c
new file mode 100644
index 0000000..79d17bb
--- /dev/null
+++ b/src/cli/abrt-cli.c
@@ -0,0 +1,146 @@
+/*
+ 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 "builtin-cmd.h"
+
+#define USAGE_OPTS_WIDTH 12
+#define USAGE_GAP 2
+
+/* TODO: add --pager(default) and --no-pager */
+
+/* better way to set <base-dir> as environ variable? */
+GList *D_list = NULL;
+
+const char abrt_cli_usage_string[] =
+ "abrt-cli [--version] [--base-dir=DUMP_DIR] <command> [<args>]";
+
+struct cmd_struct {
+ const char *cmd;
+ int (*fn)(int, const char **);
+ const char *help;
+};
+
+static void list_cmds_help(const struct cmd_struct *commands)
+{
+ for (const struct cmd_struct *p = commands; p->cmd; ++p)
+ {
+ size_t pos;
+ int pad;
+
+ pos = fprintf(stderr, " ");
+ pos += fprintf(stderr, "%s", p->cmd);
+
+ if (pos <= USAGE_OPTS_WIDTH)
+ pad = USAGE_OPTS_WIDTH - pos;
+ else
+ {
+ fputc('\n', stderr);
+ pad = USAGE_OPTS_WIDTH;
+ }
+
+ fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", p->help);
+ }
+}
+
+static void handle_internal_options(int *argc, const char ***argv)
+{
+ while (*argc > 0)
+ {
+ const char *cmd = (*argv)[0];
+ if (cmd[0] != '-')
+ break;
+
+ if (strcmp(cmd, "--version") == 0)
+ {
+ puts(PACKAGE_VERSION);
+ exit(0);
+ }
+ else if (prefixcmp(cmd, "--base-dir=") == 0)
+ D_list = g_list_append(D_list, xstrdup(cmd + strlen("--base-dir=")));
+#if 0
+ else if (prefixcmp(cmd, "--list-events") == 0)
+ {
+ const char *pfx = cmd + strlen("--list-events");
+ if (pfx && *pfx)
+ pfx += 1; /* skip '=' */
+
+ char *events = list_possible_events(NULL, dump_dir_name, pfx);
+ if (!events)
+ exit(1); /* error msg is already logged */
+
+ fputs(events, stdout);
+ free(events);
+
+ exit(0);
+ }
+#endif
+ else
+ error_msg_and_die("usage: %s", abrt_cli_usage_string);
+
+ (*argv)++;
+ (*argc)--;
+ }
+}
+
+static void handle_internal_command(int argc, const char **argv,
+ const struct cmd_struct *commands)
+{
+ const char *cmd = argv[0];
+
+ for (const struct cmd_struct *p = commands; p->cmd; ++p)
+ {
+ if (strcmp(p->cmd, cmd))
+ continue;
+
+ exit(p->fn(argc, argv));
+ }
+}
+
+int main(int argc, const char **argv)
+{
+ abrt_init((char **)argv);
+
+ setlocale(LC_ALL, "");
+#if ENABLE_NLS
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+#endif
+
+ argv++;
+ argc--;
+
+ const struct cmd_struct commands[] = {
+ {"list", cmd_list, _("List not yet reported problems")},
+ {"rm", cmd_rm, _("Remove files from problem directory")},
+ {"report", cmd_report, _("Analyze and report problem data in problem directory")},
+ {NULL, NULL, NULL}
+ };
+
+ handle_internal_options(&argc, &argv);
+ if (argc > 0)
+ handle_internal_command(argc, argv, commands);
+
+ /* user didn't specify command; print out help */
+ printf("%s\n\n", abrt_cli_usage_string);
+ list_cmds_help(commands);
+ printf("\n%s\n", _("See 'abrt-cli <command> -h' for more information"));
+
+ return 0;
+}
diff --git a/src/cli/builtin-cmd.h b/src/cli/builtin-cmd.h
new file mode 100644
index 0000000..28aa753
--- /dev/null
+++ b/src/cli/builtin-cmd.h
@@ -0,0 +1,27 @@
+/*
+ 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 _BUILTIN_CMD_H_
+#define _BUILTIN_CMD_H_
+
+extern int cmd_list(int argc, const char **argv);
+extern int cmd_rm(int argc, const char **argv);
+extern int cmd_report(int argc, const char **argv);
+
+#endif /* _BUILTIN-CMD_H_ */
diff --git a/src/cli/list.c b/src/cli/list.c
new file mode 100644
index 0000000..bdb371f
--- /dev/null
+++ b/src/cli/list.c
@@ -0,0 +1,206 @@
+/*
+ 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 "builtin-cmd.h"
+
+extern GList *D_list;
+
+/* TODO: npajkovs
+ * add --since
+ * add --until
+ * add --pretty=oneline|raw|normal|format="%a %b %c"
+ * add wildcard e.g. *-2011-04-01-10-* (list all problems in specific day)
+ *
+ * TODO?: remove base dir from list of crashes? is there a way that same crash can be in
+ * ~/.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)
+{
+ char *desc;
+ if (detailed)
+ {
+ int show_multiline = (detailed ? MAKEDESC_SHOW_MULTILINE : 0);
+ desc = make_description(problem_data,
+ /*names_to_skip:*/ NULL,
+ /*max_text_size:*/ CD_TEXT_ATT_SIZE,
+ MAKEDESC_SHOW_FILES | show_multiline);
+ }
+ else
+ {
+ 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, int include_reported,
+ int detailed)
+{
+ 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;
+ }
+ puts("");
+ print_crash(crash, detailed);
+ }
+}
+
+int cmd_list(int argc, const char **argv)
+{
+ const char *program_usage_string = _(
+ "\b list [options] [<dump-dir>]..."
+ );
+
+ static int opt_full, opt_detailed;
+ struct options program_options[] = {
+ OPT__VERBOSE(&g_verbose),
+ OPT_GROUP(""),
+ OPT_BOOL('f', "full" , &opt_full, _("List even reported problems")),
+ /* deprecate -d option with --pretty=full*/
+ OPT_BOOL('d', "detailed" , &opt_detailed, _("Show detailed report")),
+ OPT_END()
+ };
+
+ parse_opts(argc, (char **)argv, program_options, program_usage_string);
+
+ if (optind < argc)
+ {
+ while (optind < argc)
+ {
+ problem_data_t *problem = fill_crash_info(argv[optind++]);
+ print_crash(problem, opt_detailed);
+ free_problem_data(problem);
+ printf("\n");
+ }
+ exit(0);
+ }
+
+ if (!D_list)
+ {
+ char *home = getenv("HOME");
+ if (home)
+ D_list = g_list_append(D_list, concat_path_file(home, ".abrt/spool"));
+ D_list = g_list_append(D_list, xstrdup((void*)DEBUG_DUMPS_DIR));
+ }
+
+ VERB2
+ {
+ log("Base directory");
+ for (GList *li = D_list; li; li = li->next)
+ 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);
+ }
+ print_crash_list(ci, opt_full, opt_detailed);
+ free_vector_of_problem_data(ci);
+ g_list_free(D_list);
+
+ return 0;
+}
diff --git a/src/cli/report.c b/src/cli/report.c
new file mode 100644
index 0000000..8d9f006
--- /dev/null
+++ b/src/cli/report.c
@@ -0,0 +1,45 @@
+/*
+ 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 "builtin-cmd.h"
+
+int cmd_report(int argc, const char **argv)
+{
+ const char *program_usage_string = _(
+ "\b report [options] [<dump-dir>]..."
+ );
+
+ struct options program_options[] = {
+ OPT__VERBOSE(&g_verbose),
+ OPT_END()
+ };
+
+ parse_opts(argc, (char **)argv, program_options, program_usage_string);
+ if (optind < argc)
+ {
+ while (optind < argc)
+ {
+ report_problem_in_dir(argv[optind++], LIBREPORT_ANALYZE | LIBREPORT_NOWAIT);
+ log("report '%s'", argv[optind++]);
+ }
+ }
+
+ return 0;
+}
diff --git a/src/cli/rm.c b/src/cli/rm.c
new file mode 100644
index 0000000..eac01af
--- /dev/null
+++ b/src/cli/rm.c
@@ -0,0 +1,53 @@
+/*
+ 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 "builtin-cmd.h"
+
+/* TODO npajkovs:
+ * add -n, --dry-run
+ * add -q, --quite
+ */
+
+int cmd_rm(int argc, const char **argv)
+{
+ const char *program_usage_string = _(
+ "\b rm [options] [<dump-dir>]..."
+ );
+
+ struct options program_options[] = {
+ OPT__VERBOSE(&g_verbose),
+ OPT_END()
+ };
+
+ parse_opts(argc, (char **)argv, program_options, program_usage_string);
+ if (optind < argc)
+ {
+ int status;
+ while (optind < argc)
+ {
+ const char *rm_dir = argv[optind++];
+ status = delete_dump_dir_possibly_using_abrtd(rm_dir);
+ if (!status)
+ log("rm '%s'", rm_dir);
+ }
+ }
+
+ return 0;
+}
--
1.7.6.rc3
12 years, 9 months
[PATCH] remove Reported column and introduce Source column
by Jiri Moskovcak
as a part of gui revamp I removed the column "Reported" and replaced it
with column "Source" which is supposed to show the source of the
problem: it defaults to component otherwise it shows executable. The
idea about this column is to point user closer to the problem without
forcing him to do the search manually (like mapping the executable name
to package). Some use-cases:
sealert was killed by signal SIGSEGV: Source = setroubleshoot
Out of paper: Source = printer01
Too many dropped packets: Source = ethX
HDD failing: Source = sda
Please review,
Jirka
12 years, 9 months
[PATCH] [libreport] exclude information which are filled in bugzilla
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/lib/make_descr.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/lib/make_descr.c b/src/lib/make_descr.c
index e68ddb0..28dbb75 100644
--- a/src/lib/make_descr.c
+++ b/src/lib/make_descr.c
@@ -238,6 +238,10 @@ static const char *const blacklisted_items[] = {
FILENAME_UUID ,
FILENAME_COUNT ,
FILENAME_TAINTED_SHORT,
+ FILENAME_ARCHITECTURE,
+ FILENAME_PACKAGE,
+ FILENAME_OS_RELEASE,
+ FILENAME_COMPONENT,
NULL
};
--
1.7.6.rc3
12 years, 9 months
Dump directory has no UUID element
by Michal Nowak
Current upstream is not working for me. abrtd claims it's missing
UUID element in crash dir:
abrt[24038]: Unrecognized variable 'DumpLocation' in '/etc/abrt/abrt.conf'
abrtd: Unrecognized variable 'DumpLocation' in '/etc/abrt/abrt.conf'
abrt[24038]: saved core dump of pid 24035 (/bin/sleep) to /var/spool/abrt/ccpp-2011-06-17-16:10:12-24035.new/coredump (372736 bytes)
abrtd: Directory 'ccpp-2011-06-17-16:10:12-24035' creation detected
abrtd: Dump directory '/var/spool/abrt/ccpp-2011-06-17-16:10:12-24035' has no UUID element
abrtd: Corrupted or bad dump /var/spool/abrt/ccpp-2011-06-17-16:10:12-24035 (res:2), deleting
Michal
12 years, 9 months