From 56d0dc6163b39daa540c585ae99f26d526293785 Mon Sep 17 00:00:00 2001
From: Matej Habrnal <mhabrnal@redhat.com>
Date: Fri, 6 Mar 2015 08:02:28 +0100
Subject: [PATCH] reporter-mantisbt: add man pages and change formatting file
 for duplicates

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
---
 ...ntisbt-change-default-formating-file-for-.patch |  43 ++
 ...ntisbt-adds-man-pages-for-reporter-mantis.patch | 489 +++++++++++++++++++++
 SPECS/libreport.spec                               |  10 +-
 3 files changed, 541 insertions(+), 1 deletion(-)
 create mode 100644 SOURCES/1001-reporter-mantisbt-change-default-formating-file-for-.patch
 create mode 100644 SOURCES/1003-reporter-mantisbt-adds-man-pages-for-reporter-mantis.patch

diff --git a/SOURCES/1001-reporter-mantisbt-change-default-formating-file-for-.patch b/SOURCES/1001-reporter-mantisbt-change-default-formating-file-for-.patch
new file mode 100644
index 0000000..e682611
--- /dev/null
+++ b/SOURCES/1001-reporter-mantisbt-change-default-formating-file-for-.patch
@@ -0,0 +1,43 @@
+From d2affaf4d017abe83065d5401a17754ade631436 Mon Sep 17 00:00:00 2001
+From: Matej Habrnal <mhabrnal@redhat.com>
+Date: Fri, 20 Feb 2015 00:27:05 +0100
+Subject: [PATCH 1001/1003] reporter-mantisbt: change default formating file
+ for duplicate issues
+
+reporter-mantisbt doesn't work well with mantisbt_format.conf as a default
+format conf file for creating duplicate issues because the note which is added
+doesn't contain an 'Additional information' section.
+
+Default formating file for duplicate is mantisbt_formatdup.conf
+
+Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
+---
+ src/plugins/reporter-mantisbt.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/src/plugins/reporter-mantisbt.c b/src/plugins/reporter-mantisbt.c
+index d281cdb..dc9968f 100644
+--- a/src/plugins/reporter-mantisbt.c
++++ b/src/plugins/reporter-mantisbt.c
+@@ -253,7 +253,8 @@ int main(int argc, char **argv)
+         "\nRecognized boolean parameter (VALUE should be 1/0, yes/no): SSLVerify, CreatePrivate."
+         "\nParameters can be overridden via $Mantisbt_PARAM environment variables."
+         "\n"
+-        "\nFMTFILE and FMTFILE2 default to "CONF_DIR"/plugins/mantisbt_format.conf"
++        "\nFMTFILE default to "CONF_DIR"/plugins/mantisbt_format.conf."
++        "\nFMTFILE2 default to "CONF_DIR"/plugins/mantisbt_formatdup.conf."
+     );
+ 
+     enum {
+@@ -272,7 +273,7 @@ int main(int argc, char **argv)
+     const char *dump_dir_name = ".";
+     GList *conf_file = NULL;
+     const char *fmt_file = CONF_DIR"/plugins/mantisbt_format.conf";
+-    const char *fmt_file2 = fmt_file;
++    const char *fmt_file2 = CONF_DIR"/plugins/mantisbt_formatdup.conf";
+     char *abrt_hash = NULL;
+     char *ticket_no = NULL;
+     const char *tracker_str = "ABRT Server";
+-- 
+1.8.3.1
+
diff --git a/SOURCES/1003-reporter-mantisbt-adds-man-pages-for-reporter-mantis.patch b/SOURCES/1003-reporter-mantisbt-adds-man-pages-for-reporter-mantis.patch
new file mode 100644
index 0000000..3e8858d
--- /dev/null
+++ b/SOURCES/1003-reporter-mantisbt-adds-man-pages-for-reporter-mantis.patch
@@ -0,0 +1,489 @@
+From 24938820521b3742f5ff954a889e7864256dc811 Mon Sep 17 00:00:00 2001
+From: Matej Habrnal <mhabrnal@redhat.com>
+Date: Fri, 20 Feb 2015 03:14:54 +0100
+Subject: [PATCH 1003/1003] reporter-mantisbt: adds man pages for
+ reporter-mantisbt
+
+Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
+
+Conflicts:
+	doc/Makefile.am
+---
+ doc/Makefile.am                      |  13 ++-
+ doc/centos_report_event.conf.5       |   1 +
+ doc/mantisbt.conf.txt                |  18 +++
+ doc/mantisbt_format.conf.txt         |  18 +++
+ doc/mantisbt_formatdup.conf.txt      |  18 +++
+ doc/report_CentOSBugTracker.conf.txt |  45 +++++++
+ doc/report_centos.conf.txt           |  41 +++++++
+ doc/reporter-mantisbt.txt            | 219 +++++++++++++++++++++++++++++++++++
+ 8 files changed, 371 insertions(+), 2 deletions(-)
+ create mode 100644 doc/centos_report_event.conf.5
+ create mode 100644 doc/mantisbt.conf.txt
+ create mode 100644 doc/mantisbt_format.conf.txt
+ create mode 100644 doc/mantisbt_formatdup.conf.txt
+ create mode 100644 doc/report_CentOSBugTracker.conf.txt
+ create mode 100644 doc/report_centos.conf.txt
+ create mode 100644 doc/reporter-mantisbt.txt
+
+diff --git a/doc/Makefile.am b/doc/Makefile.am
+index da4785e..b574a41 100644
+--- a/doc/Makefile.am
++++ b/doc/Makefile.am
+@@ -25,6 +25,7 @@ MAN1_TXT += reporter-print.txt
+ MAN1_TXT += reporter-rhtsupport.txt
+ MAN1_TXT += reporter-upload.txt
+ MAN1_TXT += reporter-ureport.txt
++MAN1_TXT += reporter-mantisbt.txt
+ 
+ MAN5_TXT =
+ MAN5_TXT += anaconda_event.conf.txt
+@@ -37,6 +38,9 @@ MAN5_TXT += bugzilla_formatdup_anaconda.conf.txt
+ MAN5_TXT += bugzilla_formatdup.conf.txt
+ MAN5_TXT += bugzilla_format_kernel.conf.txt
+ MAN5_TXT += bugzilla_format_libreport.conf.txt
++MAN5_TXT += mantisbt.conf.txt
++MAN5_TXT += mantisbt_format.conf.txt
++MAN5_TXT += mantisbt_formatdup.conf.txt
+ MAN5_TXT += emergencyanalysis_event.conf.txt
+ MAN5_TXT += forbidden_words.conf.txt
+ MAN5_TXT += mailx.conf.txt
+@@ -45,20 +49,25 @@ MAN5_TXT += print_event.conf.txt
+ MAN5_TXT += report_Bugzilla.conf.txt
+ MAN5_TXT += report_event.conf.txt
+ MAN5_TXT += report_fedora.conf.txt
++MAN5_TXT += report_centos.conf.txt
+ MAN5_TXT += report_Logger.conf.txt
+ MAN5_TXT += report_rhel.conf.txt
+ MAN5_TXT += report_rhel_bugzilla.conf.txt
+ MAN5_TXT += report_logger.conf.txt
+ MAN5_TXT += report_mailx.conf.txt
+ MAN5_TXT += report_uploader.conf.txt
++MAN5_TXT += report_CentOSBugTracker.conf.txt
+ MAN5_TXT += rhtsupport.conf.txt
+ MAN5_TXT += rhtsupport_event.conf.txt
+ MAN5_TXT += uploader_event.conf.txt
+ MAN5_TXT += ureport.conf.txt
+ 
++MAN5_PREFORMATTED =
++MAN5_PREFORMATTED += centos_report_event.conf.5
++
+ # Manual pages are generated from .txt via Docbook
+ man1_MANS = ${MAN1_TXT:%.txt=%.1}
+-man5_MANS = ${MAN5_TXT:%.txt=%.5}
++man5_MANS = ${MAN5_TXT:%.txt=%.5} ${MAN5_PREFORMATTED}
+ 
+ SUFFIXES = .1 .5
+ 
+@@ -73,5 +82,5 @@ SUFFIXES = .1 .5
+                                     --conf-file ../asciidoc.conf \
+                                     -alibreport_version=$(PACKAGE_VERSION) -o $@ $<
+ 
+-EXTRA_DIST = $(MAN1_TXT) $(MAN5_TXT)
++EXTRA_DIST = $(MAN1_TXT) $(MAN5_TXT) $(MAN5_PREFORMATTED)
+ CLEANFILES = $(man1_MANS)
+diff --git a/doc/centos_report_event.conf.5 b/doc/centos_report_event.conf.5
+new file mode 100644
+index 0000000..71c3fcb
+--- /dev/null
++++ b/doc/centos_report_event.conf.5
+@@ -0,0 +1 @@
++.so man5/report_event.conf.5
+diff --git a/doc/mantisbt.conf.txt b/doc/mantisbt.conf.txt
+new file mode 100644
+index 0000000..d4ba605
+--- /dev/null
++++ b/doc/mantisbt.conf.txt
+@@ -0,0 +1,18 @@
++mantisbt.conf(5)
++===============
++
++NAME
++----
++mantisbt.conf - configuration file for libreport.
++
++DESCRIPTION
++-----------
++This configuration file provides default configuration for 'reporter-mantisbt'.
++
++SEE ALSO
++--------
++reporter-mantisbt(1)
++
++AUTHOR
++------
++* ABRT team
+diff --git a/doc/mantisbt_format.conf.txt b/doc/mantisbt_format.conf.txt
+new file mode 100644
+index 0000000..860d911
+--- /dev/null
++++ b/doc/mantisbt_format.conf.txt
+@@ -0,0 +1,18 @@
++mantisbt_format.conf(5)
++=======================
++
++NAME
++----
++mantisbt_format.conf - configuration file for libreport.
++
++DESCRIPTION
++-----------
++This configuration file provides definition of general formatting for new MantisBT issues.
++
++SEE ALSO
++--------
++reporter-mantisbt(1)
++
++AUTHOR
++------
++* ABRT Team
+diff --git a/doc/mantisbt_formatdup.conf.txt b/doc/mantisbt_formatdup.conf.txt
+new file mode 100644
+index 0000000..a617226
+--- /dev/null
++++ b/doc/mantisbt_formatdup.conf.txt
+@@ -0,0 +1,18 @@
++mantisbt_formatdup.conf(5)
++==========================
++
++NAME
++----
++mantisbt_formatdup.conf - configuration file for libreport.
++
++DESCRIPTION
++-----------
++This configuration file provides definition of general formatting for duplicate MantisBT issues.
++
++SEE ALSO
++--------
++reporter-mantisbt(1)
++
++AUTHOR
++------
++* ABRT Team
+diff --git a/doc/report_CentOSBugTracker.conf.txt b/doc/report_CentOSBugTracker.conf.txt
+new file mode 100644
+index 0000000..6ba35d3
+--- /dev/null
++++ b/doc/report_CentOSBugTracker.conf.txt
+@@ -0,0 +1,45 @@
++report_CentOSBugTracker.conf(5)
++===============================
++
++NAME
++----
++report_CentOSBugTracker.conf - libreport's configuration file for 'report_CentOSBugTracker' events.
++
++DESCRIPTION
++-----------
++This configuration file contains values for options defined in
++/usr/share/libreport/events/report_CentOSBugTracker.xml
++
++Configuration file lines should have 'PARAM = VALUE' format. The parameters are:
++
++'Mantisbt_Login'::
++	Login to MantisBT account.
++
++'Mantisbt_Password'::
++	Password to MantisBT account.
++
++'Mantisbt_MantisbtURL'::
++	MantisBT HTTP(S) address. (default: https://bugs.centos.org)
++
++'Mantisbt_SSLVerify'::
++	Use yes/true/on/1 to verify server's SSL certificate. (default: yes)
++
++'Mantisbt_Project'::
++	Project issue field value. Useful if you needed different project than specified in /etc/os-release
++
++'Mantisbt_ProjectVersion'::
++	Version issue field value. Useful if you needed different project version than specified in /etc/os-release
++
++'http_proxy'::
++	the proxy server to use for HTTP
++
++'HTTPS_PROXY'::
++	the proxy server to use for HTTPS
++
++SEE ALSO
++--------
++report_event.conf(5), reporter-mantisbt(1)
++
++AUTHOR
++------
++* ABRT team
+diff --git a/doc/report_centos.conf.txt b/doc/report_centos.conf.txt
+new file mode 100644
+index 0000000..23a5fde
+--- /dev/null
++++ b/doc/report_centos.conf.txt
+@@ -0,0 +1,41 @@
++report_centos.conf(5)
++=====================
++
++NAME
++----
++report_centos.conf - configuration file for libreport.
++
++DESCRIPTION
++-----------
++This configuration file specifies which of the reporting work flow definitions
++are applicable for all problems types on CentOS.
++
++All applicable work flows are presented to users in User Interface as
++possibilities for processing of any problems. A particular work flow becomes
++applicable if its conditions are satisfied.
++
++This configuration file consists from one condition per line.
++
++Each condition line must start with EVENT=workflow_NAME where "workflow_" is
++constant prefix and "workflow_NAME" is base name of path to reporting work flow
++configuration file.
++
++The rest of condition line has form VAR=VAL, VAR!=VAL or VAL~=REGEX, where VAR
++is a name of problem directory element to be checked (for example,
++"executable", "package", hostname" etc). The condition may consists
++from as many element checks as it is necessary.
++
++EXAMPLES
++--------
++Condition line::
++    EVENT=workflow_CentOSCCpp analyzer=CCpp
++
++The condition line above expects existence of /usr/share/libreport/workflows/workflow_CentOSCCpp.xml
++
++SEE ALSO
++--------
++report-gtk(1)
++
++AUTHOR
++------
++* ABRT team
+diff --git a/doc/reporter-mantisbt.txt b/doc/reporter-mantisbt.txt
+new file mode 100644
+index 0000000..92255b0
+--- /dev/null
++++ b/doc/reporter-mantisbt.txt
+@@ -0,0 +1,219 @@
++reporter-mantisbt(1)
++====================
++
++NAME
++----
++reporter-mantisbt - Reports problem to Mantis Bug Tracker.
++
++SYNOPSIS
++--------
++'reporter-mantisbt' [-vrf] [-c CONFFILE]... [-F FMTFILE] [-A FMTFILE2] -d DIR
++
++Or:
++
++'reporter-mantisbt' [-v] [-c CONFFILE]... [-d DIR] -t[ID] FILE...
++
++Or:
++
++'reporter-mantisbt' [-v] [-c CONFFILE]... -h DUPHASH
++
++DESCRIPTION
++-----------
++The tool reads problem directory DIR. Then it logs in to MantisBT
++and tries to find an issue with the same duphash HEXSTRING in 'abrt_hash' field.
++
++If such issue is not found, then a new issue is created. Elements of DIR
++are stored in the issue as part of issue description or as attachments,
++depending on their type and size.
++
++Otherwise, if such issue is found and it is marked as CLOSED DUPLICATE,
++the tool follows the chain of duplicates until it finds a non-DUPLICATE issue.
++The tool adds a new note to found issue.
++
++The URL to new or modified issue is printed to stdout and recorded in
++'reported_to' element in DIR.
++
++Option -t uploads FILEs to the already created issue on MantisBT site.
++The issue ID is retrieved from directory specified by -d DIR.
++If problem data in DIR was never reported to MantisBT, upload will fail.
++
++Option -tID uploads FILEs to the issue with specified ID on MantisBT site.
++-d DIR is ignored.
++
++Option -r sets the last url from reporter_to element which is prefixed with
++TRACKER_NAME to URL field. This option is applied only when a new issue is to be
++filed. The default value is 'ABRT Server'"
++
++Configuration file
++~~~~~~~~~~~~~~~~~~
++If not specified, CONFFILE defaults to /etc/libreport/plugins/mantisbt.conf.
++Configuration file lines should have 'PARAM = VALUE' format. The parameters are:
++
++'Login'::
++	Login to MantisBT account.
++
++'Password'::
++	Password to MantisBT account.
++
++'MantisbtURL'::
++	MantisBT HTTP(S) address. (default: http://localhost/mantisbt)
++
++'SSLVerify'::
++	Use yes/true/on/1 to verify server's SSL certificate. (default: no)
++
++'Project'::
++	Project issue field value. Useful if you needed different project than specified in /etc/os-release
++
++'ProjectVersion'::
++	Version issue field value. Useful if you needed different project version than specified in /etc/os-release
++
++'CreatePrivate'::
++    Create private MantisBT issue. (default: no)
++
++Parameters can be overridden via $Mantisbt_PARAM environment variables.
++
++Formatting configuration files
++~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
++Lines starting with # are ignored.
++
++Lines can be continued on the next line using trailing backslash.
++
++Format:
++
++   "%summary:: summary format"
++   "section:: element1[,element2]..."
++   The literal text line to be added to MantisBT Description or Additional information. Can be empty.
++   (Empty lines are NOT ignored!)
++
++   Summary format is a line of text, where %element% is replaced by
++   text element's content, and [[...%element%...]] block is used only if
++   %element% exists. [[...]] blocks can nest.
++
++   Sections can be:
++   - %summary: issue Summary format string.
++   - %attach: a list of elements to attach.
++   - %Additional info: issue Additional Information content.
++   - text, double colon (::) and the list of comma-separated elements.
++
++   Description and Additional information MantisBT's fields:
++   All text, double colons (::) and lists of comma-separated elements which
++   are placed above the section '%Additional info::' in the configuration file are
++   stored in the 'Description' field in MantisBT. All text etc. which are placed
++   under the '%Additional info::' are stored in the 'Additional information' field.
++
++   For example:
++   |:: comment               |  (Description)
++   |                         |  (Description)
++   |Package:: package        |  (Description)
++   |                         |  (Description)
++   |%Additional_info::       |
++   |%reporter%               |  (Additional info)
++   |User:: user_name,uid     |  (Additional info)
++   |                         |  (Additional info)
++   |Directories:: root,cwd   |  (Additional info)
++
++   Elements can be:
++   - problem directory element names, which get formatted as
++     <element_name>: <contents>
++     or
++     <element_name>:
++     :<contents>
++     :<contents>
++     :<contents>
++   - problem directory element names prefixed by "%bare_",
++     which is formatted as-is, without "<element_name>:" and colons
++   - %oneline, %multiline, %text wildcards, which select all corresponding
++     elements for output or attachment
++   - %binary wildcard, valid only for %attach section, instructs to attach
++     binary elements
++   - problem directory element names prefixed by "-",
++     which excludes given element from all wildcards
++
++     Nonexistent elements are silently ignored.
++     If none of elements exists, the section will not be created.
++
++Integration with ABRT events
++~~~~~~~~~~~~~~~~~~~~~~~~~~~~
++'reporter-mantisbt' can be used as an ABRT reporter. Example
++fragment for /etc/libreport/report_event.conf:
++
++------------
++# Report Python crashes
++EVENT=report_CentOSBugTracker analyzer=Python
++      reporter-mantisbt -d . -c /etc/libreport/plugins/mantisbt.conf
++------------
++
++OPTIONS
++-------
++-d DIR::
++   Path to problem directory.
++
++-c CONFFILE::
++   Path to configuration file.
++
++-f::
++   Force reporting even if this problem is already reported.
++
++-F CONF_FORMAT_FILE::
++   Formatting file for new issues. Default: /etc/libreport/plugins/mantisbt_format.conf
++
++-A CONF_FORMAT_FILE::
++   Formatting file for duplicates. Default: /etc/libreport/plugins/mantisbt_formatdup.conf
++
++-t[ID]::
++   Upload FILEs to the already created issue on MantisBT site.
++
++-h::
++--duphash DUPHASH::
++   Search in MantisBT by abrt's DUPHASH and print ISSUE_ID.
++
++-r TRACKER_NAME::
++   Set the last url from reporter_to element which is prefixed with TRACKER_NAME to URL field in MantisBT.
++
++ENVIRONMENT VARIABLES
++---------------------
++Environment variables take precedence over values provided in
++the configuration file.
++
++'Mantisbt_Login'::
++	Login to MantisBT account.
++
++'Mantisbt_Password'::
++	Password to MantisBT account.
++
++'Mantisbt_MantisbtURL'::
++	MantisBT HTTP(S) address. (default: http://localhost/mantisbt)
++
++'Mantisbt_SSLVerify'::
++	Use yes/true/on/1 to verify server's SSL certificate. (default: no)
++
++'Mantisbt_Project'::
++	Project issue field value. Useful if you needed different project than specified in /etc/os-release
++
++'Mantisbt_ProjectVersion'::
++	Version issue field value. Useful if you needed different project version than specified in /etc/os-release
++
++'Mantisbt_CreatePrivate'::
++    Create private MantisBT issue. (default: no)
++
++FILES
++-----
++/usr/share/libreport/conf.d/plugins/mantisbt.conf::
++    Readonly default configuration files.
++
++/etc/libreport/plugins/mantisbt.conf::
++    Configuration file.
++
++/etc/libreport/plugins/mantisbt_format.conf::
++    Configure formating for reporting.
++
++/etc/libreport/plugins/mantisbt_formatdup.conf::
++    Configure formating for reporting duplicates.
++
++SEE ALSO
++--------
++report_event.conf(5), mantisbt_format.conf(5), mantisbt_formatdup.conf(5)
++
++AUTHORS
++-------
++* ABRT team
+-- 
+1.8.3.1
+
diff --git a/SPECS/libreport.spec b/SPECS/libreport.spec
index d2284a2..eace862 100644
--- a/SPECS/libreport.spec
+++ b/SPECS/libreport.spec
@@ -148,7 +148,8 @@ Patch130: 0130-lib-created-a-new-lib-file-for-reporters.patch
 Patch133: 0133-ureport-set-url-to-public-faf-server.patch
 Patch134: 0134-conf-changed-URL-for-sending-uReport.patch
 Patch1000: 1000-reporter-mantisbt-first-version-of-the-reporter-mant.patch
-#Patch1001: 1001-spec-changed-spec-file-to-work-with-reporter-mantisb.patch
+Patch1001: 1001-reporter-mantisbt-change-default-formating-file-for-.patch
+Patch1003: 1003-reporter-mantisbt-adds-man-pages-for-reporter-mantis.patch
 
 # git is need for '%%autosetup -S git' which automatically applies all the
 # patches above. Please, be aware that the patches must be generated
@@ -725,6 +726,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %config(noreplace) %{_sysconfdir}/libreport/plugins/mantisbt_format.conf
 %config(noreplace) %{_sysconfdir}/libreport/plugins/mantisbt_formatdup.conf
 %{_bindir}/reporter-mantisbt
+%{_mandir}/man1/reporter-mantisbt.1.gz
+%{_mandir}/man5/mantisbt.conf.5.*
+%{_mandir}/man5/mantisbt_format.conf.5.*
+%{_mandir}/man5/mantisbt_formatdup.conf.5.*
 
 %files centos
 %{_datadir}/%{name}/workflows/workflow_CentOSCCpp.xml
@@ -736,10 +741,13 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %{_datadir}/%{name}/workflows/workflow_CentOSLibreport.xml
 %{_datadir}/%{name}/workflows/workflow_CentOSJava.xml
 %config(noreplace) %{_sysconfdir}/libreport/workflows.d/report_centos.conf
+%{_mandir}/man5/report_centos.conf.5.*
 %{_datadir}/%{name}/events/report_CentOSBugTracker.xml
 %config(noreplace) %{_sysconfdir}/libreport/events/report_CentOSBugTracker.conf
+%{_mandir}/man5/report_CentOSBugTracker.conf.5.*
 # report_CentOSBugTracker events are shipped by libreport package
 %config(noreplace) %{_sysconfdir}/libreport/events.d/centos_report_event.conf
+%{_mandir}/man5/centos_report_event.conf.5.gz
 
 %files plugin-rhtsupport
 %defattr(-,root,root,-)
-- 
1.8.3.1

