[libreport/f16] - re-enabled bugzilla for non abrt crashes rhbz#725970, fixed repoting from anaconda rhbz#725857

Jiří Moskovčák jmoskovc at fedoraproject.org
Fri Jul 29 07:27:04 UTC 2011


commit 82dab9658c83f79bf454003424046ff821e6b4f0
Author: Jiri Moskovcak <jmoskovc at redhat.com>
Date:   Fri Jul 29 09:08:48 2011 +0200

    - re-enabled bugzilla for non abrt crashes rhbz#725970, fixed repoting from anaconda rhbz#725857

 ...lla_event.conf-to-enable-Bugzilla-for-all.patch |   35 +++
 ...d-compatibility-with-anaconda-rhbz-725857.patch |  288 ++++++++++++++++++++
 libreport.spec                                     |   12 +-
 3 files changed, 333 insertions(+), 2 deletions(-)
---
diff --git a/0031-added-bugzilla_event.conf-to-enable-Bugzilla-for-all.patch b/0031-added-bugzilla_event.conf-to-enable-Bugzilla-for-all.patch
new file mode 100644
index 0000000..1ceea33
--- /dev/null
+++ b/0031-added-bugzilla_event.conf-to-enable-Bugzilla-for-all.patch
@@ -0,0 +1,35 @@
+From 973be6c9f86e6966985984fc647be1156605ff58 Mon Sep 17 00:00:00 2001
+From: Jiri Moskovcak <jmoskovc at redhat.com>
+Date: Wed, 27 Jul 2011 19:57:00 +0200
+Subject: [PATCH 31/32] added bugzilla_event.conf to enable Bugzilla for all
+ problems not coming from ABRT rhbz#725970
+
+---
+ src/plugins/Makefile.am         |    1 +
+ src/plugins/bugzilla_event.conf |    1 +
+ 3 files changed, 3 insertions(+), 0 deletions(-)
+ create mode 100644 src/plugins/bugzilla_event.conf
+
+diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
+index d616ee5..02e0647 100644
+--- a/src/plugins/Makefile.am
++++ b/src/plugins/Makefile.am
+@@ -35,6 +35,7 @@ eventsconfdir = $(EVENTS_CONF_DIR)
+ dist_eventsconf_DATA = \
+     mailx_event.conf \
+     print_event.conf \
++    bugzilla_event.conf \
+     rhtsupport_event.conf
+ 
+ MAN_TXT = \
+diff --git a/src/plugins/bugzilla_event.conf b/src/plugins/bugzilla_event.conf
+new file mode 100644
+index 0000000..3fb604d
+--- /dev/null
++++ b/src/plugins/bugzilla_event.conf
+@@ -0,0 +1 @@
++EVENT=report_Bugzilla analyzer=libreport reporter-bugzilla
+\ No newline at end of file
+-- 
+1.7.6
+
diff --git a/0032-improved-compatibility-with-anaconda-rhbz-725857.patch b/0032-improved-compatibility-with-anaconda-rhbz-725857.patch
new file mode 100644
index 0000000..3190e68
--- /dev/null
+++ b/0032-improved-compatibility-with-anaconda-rhbz-725857.patch
@@ -0,0 +1,288 @@
+From 43d9b58ca0ef0242a3905253120c6dbc82c8bc0d Mon Sep 17 00:00:00 2001
+From: Jiri Moskovcak <jmoskovc at redhat.com>
+Date: Thu, 28 Jul 2011 14:44:43 +0200
+Subject: [PATCH 32/32] improved compatibility with anaconda rhbz#725857
+
+- + thoughts from the review
+---
+ src/lib/create_dump_dir.c     |    9 ++-
+ src/lib/dump_dir.c            |   15 ++++-
+ src/lib/parse_release.c       |    6 ++
+ src/report-python/__init__.py |  144 +++++++++++++++++++++++------------------
+ 4 files changed, 107 insertions(+), 67 deletions(-)
+
+diff --git a/src/lib/create_dump_dir.c b/src/lib/create_dump_dir.c
+index 13c42e4..27e3761 100644
+--- a/src/lib/create_dump_dir.c
++++ b/src/lib/create_dump_dir.c
+@@ -23,8 +23,6 @@ static struct dump_dir *try_dd_create(const char *base_dir_name, const char *dir
+ {
+     char *path = concat_path_file(base_dir_name, dir_name);
+     struct dump_dir *dd = dd_create(path, (uid_t)-1L, 0640);
+-    if (dd)
+-        dd_create_basic_files(dd, (uid_t)-1L);
+     free(path);
+     return dd;
+ }
+@@ -81,5 +79,12 @@ struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data,
+  next: ;
+     }
+ 
++    /* need to create basic files AFTER we save the pd to dump_dir
++     * otherwise we can't skip already created files like in case when
++     * reporting from anaconda where we can't read /etc/{system,redhat}-release
++     * and os_release is taken from anaconda
++    */
++    dd_create_basic_files(dd, (uid_t)-1L);
++
+     return dd;
+ }
+diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c
+index e4e7fad..d11eeb7 100644
+--- a/src/lib/dump_dir.c
++++ b/src/lib/dump_dir.c
+@@ -492,8 +492,19 @@ void dd_create_basic_files(struct dump_dir *dd, uid_t uid)
+     dd_save_text(dd, FILENAME_ARCHITECTURE, buf.machine);
+     dd_save_text(dd, FILENAME_HOSTNAME, buf.nodename);
+ 
+-    char *release = load_text_file("/etc/system-release",
+-                DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
++    /* if release exists in dumpdir don't create it, but don't warn
++     * if it doesn't
++     * i.e: anaconda doesn't have /etc/{fedora,redhat}-release and trying to load it
++     * results in errors: rhbz#725857
++    */
++    char *release = dd_load_text_ext(dd, FILENAME_OS_RELEASE,
++                    DD_FAIL_QUIETLY_ENOENT | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
++
++    if (release)
++        return;
++
++    release = load_text_file("/etc/system-release",
++            DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
+     if (!release)
+         release = load_text_file("/etc/redhat-release", /*flags:*/ 0);
+     dd_save_text(dd, FILENAME_OS_RELEASE, release);
+diff --git a/src/lib/parse_release.c b/src/lib/parse_release.c
+index 2cc11ba..889f539 100644
+--- a/src/lib/parse_release.c
++++ b/src/lib/parse_release.c
+@@ -40,6 +40,12 @@ static void parse_release(const char *release, char** product, char** version, b
+         strbuf_append_str(buf_product, release);
+     }
+ 
++    /* examples of release strings:
++     * installed system: Red Hat Enterprise Linux Server release 6.2 Beta (Santiago)
++     * anaconda: Red Hat Enterprise Linux 6.2
++       * ^ note missing "release"
++     * so the following parsing would fail, workaround is in python bindings
++     */
+     const char *r = strstr(release, "release");
+     const char *space = r ? strchr(r, ' ') : NULL;
+ 
+diff --git a/src/report-python/__init__.py b/src/report-python/__init__.py
+index 796d469..fbbc158 100644
+--- a/src/report-python/__init__.py
++++ b/src/report-python/__init__.py
+@@ -16,108 +16,118 @@ from _pyreport import *
+ 
+ 
+ #Compatibility with report package:
++# Author(s): Gavin Romig-Koch <gavin at redhat.com>
++# ABRT Team
+ 
+ import os
+ 
+ SYSTEM_RELEASE_PATHS = ["/etc/system-release","/etc/redhat-release"]
+-####SYSTEM_RELEASE_DEPS = ["system-release", "redhat-release"]
++SYSTEM_RELEASE_DEPS = ["system-release", "redhat-release"]
+ 
+ _hardcoded_default_product = ""
+ _hardcoded_default_version = ""
+ 
+-####def getProduct_fromPRODUCT():
+-####    try:
+-####        import product
+-####        return product.productName
+-####    except:
+-####        return ""
+-
+-####def getVersion_fromPRODUCT():
+-####    try:
+-####        import product
+-####        return product.productVersion
+-####    except:
+-####        return ""
+-
+-####def getProduct_fromRPM():
+-####    try:
+-####        import rpm
+-####        ts = rpm.TransactionSet()
+-####        for each_dep in SYSTEM_RELEASE_DEPS:
+-####            mi = ts.dbMatch('provides', each_dep)
+-####            for h in mi:
+-####                if h['name']:
+-####                    return h['name'].split("-")[0].capitalize()
+-####
+-####        return ""
+-####    except:
+-####        return ""
+-
+-####def getVersion_fromRPM():
+-####    try:
+-####        import rpm
+-####        ts = rpm.TransactionSet()
+-####        for each_dep in SYSTEM_RELEASE_DEPS:
+-####            mi = ts.dbMatch('provides', each_dep)
+-####            for h in mi:
+-####                if h['version']:
+-####                    return str(h['version'])
+-####        return ""
+-####    except:
+-####        return ""
++"""
++def getProduct_fromRPM():
++    try:
++        import rpm
++        ts = rpm.TransactionSet()
++        for each_dep in SYSTEM_RELEASE_DEPS:
++            mi = ts.dbMatch('provides', each_dep)
++            for h in mi:
++                if h['name']:
++                    return h['name'].split("-")[0].capitalize()
++
++        return ""
++    except:
++        return ""
+ 
+ def getProduct_fromFILE():
+     for each_path in SYSTEM_RELEASE_PATHS:
+-        try:
++        if os.path.exists(each_path):
+             file = open(each_path, "r")
+             content = file.read()
+             if content.startswith("Red Hat Enterprise Linux"):
+                 return "Red Hat Enterprise Linux"
++
+             if content.startswith("Fedora"):
+                 return "Fedora"
++
+             i = content.find(" release")
+             if i > -1:
+                 return content[0:i]
+-        except:
+-            pass
++
+     return ""
+ 
++def getVersion_fromRPM():
++    try:
++        import rpm
++        ts = rpm.TransactionSet()
++        for each_dep in SYSTEM_RELEASE_DEPS:
++            mi = ts.dbMatch('provides', each_dep)
++            for h in mi:
++                if h['version']:
++                    return str(h['version'])
++
++        return ""
++    except:
++        return ""
++
+ def getVersion_fromFILE():
+     for each_path in SYSTEM_RELEASE_PATHS:
+-        try:
++        if os.path.exists(each_path):
+             file = open(each_path, "r")
+             content = file.read()
+             if content.find("Rawhide") > -1:
+                 return "rawhide"
++
+             clist = content.split(" ")
+             i = clist.index("release")
+             return clist[i+1]
++        else:
++            return ""
++"""
++
++def getProduct_fromPRODUCT():
++    try:
++        from pyanaconda import product
++        return product.productName
++    except:
++        try:
++            import product
++            return product.productName
+         except:
+-            pass
+-    return ""
++            return ""
++
++def getVersion_fromPRODUCT():
++    try:
++        from pyanaconda import product
++        return product.productVersion
++    except:
++        try:
++            import product
++            return product.productVersion
++        except:
++            return ""
++
+ 
+ def getProduct():
+-    ####product = getProduct_fromPRODUCT()
+-    ####if product:
+-    ####    return product
+-    product = getProduct_fromFILE()
++    """Attempt to determine the product of the running system by asking anaconda
++    """
++    product = getProduct_fromPRODUCT()
+     if product:
+         return product
+-    ####product = getProduct_fromRPM()
+-    ####if product:
+-    ####    return product
++
+     return _hardcoded_default_product
+ 
+ def getVersion():
+-    ####version = getVersion_fromPRODUCT()
+-    ####if version:
+-    ####    return version
+-    version = getVersion_fromFILE()
++    """Attempt to determine the version of the running system by asking anaconda
++       Always return as a string.
++    """
++    version = getVersion_fromPRODUCT()
+     if version:
+         return version
+-    ####version = getVersion_fromRPM()
+-    ####if version:
+-    ####    return version
++
+     return _hardcoded_default_version
+ 
+ def createAlertSignature(component, hashmarkername, hashvalue, summary, alertSignature):
+@@ -140,8 +150,16 @@ def createPythonUnhandledExceptionSignature(component, hashmarkername, hashvalue
+     pd.add("duphash", hashvalue)
+     pd.add("reason", summary)
+     pd.add("description", description)
+-    #pd.add("product", getProduct())
+-    #pd.add("version", getVersion())
++    product = getProduct()
++    if product:
++        pd.add("product", product)
++    version = getVersion()
++    if version:
++        pd.add("version", version)
++    #libreport expect the os_release as in /etc/redhat-release
++    if (version and product):
++        # need to add "release", parse_release() expects format "<product> release <version>"
++        pd.add("os_release", product +" release "+ version)
+     pd.add_basics() # adds product and version + some other required field
+     # FIXME: how to handle files out of dump dir??
+     #1 = flag BIN
+-- 
+1.7.6
+
diff --git a/libreport.spec b/libreport.spec
index 701fe02..9675aad 100644
--- a/libreport.spec
+++ b/libreport.spec
@@ -5,7 +5,7 @@
 Summary: Generic library for reporting various problems
 Name: libreport
 Version: 2.0.5
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: GPLv2+
 Group: System Environment/Libraries
 URL: https://fedorahosted.org/abrt/
@@ -22,6 +22,8 @@ Patch8: 0009-report-cli-don-t-crash-when-invalid-analyzer-is-sele.patch
 Patch9: 0010-Add-another-reporting-flag-LIBREPORT_GETPID.patch
 Patch10: 0011-add-python-bindings-for-interactive-plugins.patch
 Patch11: 0012-run_event_on_dir-fix-double-free.patch
+Patch12: 0031-added-bugzilla_event.conf-to-enable-Bugzilla-for-all.patch
+PAtch13: 0032-improved-compatibility-with-anaconda-rhbz-725857.patch
 BuildRequires: dbus-devel
 BuildRequires: gtk2-devel
 BuildRequires: curl-devel
@@ -205,6 +207,8 @@ Plugin to report bugs into anonymous FTP site associated with ticketing system.
 %patch9 -p1
 %patch10 -p1
 %patch11 -p1
+%patch12 -p1
+%patch13 -p1
 
 %build
 mkdir -p m4
@@ -333,6 +337,7 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %config(noreplace) %{_sysconfdir}/libreport/plugins/Bugzilla.conf
 %{_sysconfdir}/libreport/events/report_Bugzilla.xml
 %config(noreplace) %{_sysconfdir}/libreport/events/report_Bugzilla.conf
+%config(noreplace) %{_sysconfdir}/libreport/events.d/bugzilla_event.conf
 # FIXME: remove with the old gui
 %{_mandir}/man1/reporter-bugzilla.1.gz
 %{_bindir}/reporter-bugzilla
@@ -350,6 +355,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %{_bindir}/reporter-upload
 
 %changelog
+* Fri Jul 29 2011 Jiri Moskovcak <jmoskovc at redhat.com> 2.0.5-3
+- enable bugzilla reporter for analyzer=libreport rhbz#725970
+- improved compatibility with anaconda
+
 * Thu Jul 21 2011 Jiri Moskovcak <jmoskovc at redhat.com> 2.0.5-2
 - obsolete report in rawhide properly rhbz#723320
 - added button to add attachments
@@ -359,7 +368,6 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 - added python bindings for interactive plugins
 - Resolves: #723320
 
-
 * Mon Jul 18 2011 Jiri Moskovcak <jmoskovc at redhat.com> 2.0.5-1
 - move reporter plugins from abrt to libreport
 - fixed provides/obsolete to properly obsolete report package


More information about the scm-commits mailing list