Package: reportbug
Version: 3.99.0
Severity: normal

It seems that in version 3.43 the way that the --template option works
was slightly changed, so that if a package has a bug script, it will
be executed and the output will be included in the template. This was
not the case with earlier versions where using the --template would not
cause the script in /usr/share/bug/PACKAGE/script to be executed.

Unfortunately this change can cause problems when it's necessary to
call reportbug with the --template option non-interactively, for
example from a script, because some packages' bug scripts are
interactive.

Specifically the function debian-bug, provided by the debian-el
package to report bugs from Emacs, needs to call reportbug with the
--template option, and thus will have problems when used with a
package that has a bug script that is requesting input from the user.
See bug report #502426.

Apparently, this has also been an issue before. See for example bug
#314695.


I'm not sure what is the best approach here, but I've attached a patch
suggesting the implementation of a --no-bug-script option. Though, as
said, I'm not sure whether this would be the best thing to do, as I
realize it might not be optimal to add even more options to reportbug.
Also, in the patch I've removed the condition (interactive or
self.options.template) in the test of whether to execute the bug
script, since it seems to be a tautology: interactive is only set to
false if self.options.template is true. Furthermore, since this leaves
only one case where the variable interactive is referenced, and since
interactive is directly dependent on self.options.template, I replaced
that reference with a reference to self.options.template and removed
the variable interactive altogether.


-- Package-specific info:
** Environment settings:
EDITOR="emacs"
EMAIL="ha...@stordahl.org"
INTERFACE="text"

** /home/haakonst/.reportbugrc:
mode standard
ui text
realname "Håkon Stordahl"
email "ha...@stordahl.org"

-- System Information:
Debian Release: 5.0
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-1-686 (SMP w/2 CPU cores)
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/bash

Versions of packages reportbug depends on:
ii  apt                           0.7.20     Advanced front-end for dpkg
ii  python                        2.5.2-3    An interactive high-level object-o
ii  python-reportbug              3.99.0     Python modules for interacting wit

reportbug recommends no packages.

Versions of packages reportbug suggests:
ii  debconf-utils                 1.5.24     debconf utilities
ii  debsums                       2.0.40     verification of installed package 
ii  dlocate                       0.96.1     fast alternative to dpkg -L and dp
ii  exim4                         4.69-9     metapackage to ease Exim MTA (v4) 
ii  exim4-daemon-light [mail-tran 4.69-9     lightweight Exim MTA (v4) daemon
ii  file                          4.26-2     Determines file type using "magic"
ii  gnupg                         1.4.9-3    GNU privacy guard - a free PGP rep
ii  python-gtk2                   2.12.1-6   Python bindings for the GTK+ widge
ii  python-urwid                  0.9.8.3-1  curses-based UI/widget library for

-- no debconf information

--- a/bin/reportbug	2008-10-23 13:42:53.000000000 +0000
+++ b/bin/reportbug	2009-01-08 14:00:54.000000000 +0000
@@ -626,7 +626,7 @@
                     editor='', offline=False, verify=True, check_uid=True,
                     testmode=False, attachments=[], keyid='', body=None,
                     bodyfile=None, smtptls=False, smtpuser='', smtppasswd='',
-                    paranoid=False)
+                    paranoid=False, bug_script=True)
 
     if not sys.stdin.isatty():
         defaults.update({ 'dontquery' : True, 'notatty' : True,
@@ -815,6 +815,10 @@
     parser.add_option('--no-paranoid', action='store_false', dest='paranoid',
                       help='don\'t show contents of message before sending '
                       '(default)')
+    parser.add_option('--bug-script', action='store_true', dest='bug_script',
+                      help='execute the package\'s bug script (default)')
+    parser.add_option('--no-bug-script', action='store_false', dest='bug_script',
+                      help='don\'t  execute the package\'s bug script')
 
     (options, args) = parser.parse_args()
 
@@ -927,7 +931,7 @@
 
         interactive = True
         if self.options.template:
-            check_available = interactive = False
+            check_available = False
             dontquery = quietly = notatty = True
             mua = smtphost = None
             severity = severity or 'wishlist'
@@ -1507,7 +1511,7 @@
 
         ewrite('\n')
         prompted = False
-        if interactive and not (self.options.kudos or exinfo) and presubj:
+        if not self.options.template and not (self.options.kudos or exinfo) and presubj:
             ui.display_report(open(presubj).read()+'\n')
 
         if self.options.kudos:
@@ -1676,7 +1680,7 @@
             tags = ''
 
         # Execute bug script
-        if (interactive or self.options.template) and bugexec and not self.options.kudos:
+        if self.options.bug_script and bugexec and not self.options.kudos:
             if os.path.exists('handle_bugscript'):
                 handler = './handle_bugscript'
             else:
--- a/man/reportbug.1	2008-09-16 20:09:49.000000000 +0000
+++ b/man/reportbug.1	2009-01-08 14:18:26.000000000 +0000
@@ -84,6 +84,12 @@
 skipped.  (BODYFILE may also be a named pipe; using a device special
 file may lead to unusual results.)
 .TP
+.B \-\-bug\-script
+Execute the package's bug script (default).
+.TP
+.B \-\-no\-bug\-script
+Don't execute the package's bug script.
+.TP
 .B \-c, \-\-no\-config\-files
 Omit configuration files from the bug report without asking.  By
 default, you are asked if you want to include them; in some cases,
_______________________________________________
Reportbug-maint mailing list
Reportbug-maint@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/reportbug-maint

Reply via email to