Package: reportbug Version: 6.6.3 Severity: wishlist Tags: patch Hi,
Here a patch to allow use of XDG_CONFIG_HOME/debian/reportbugrc for settings. Reading ~/.reportbugrc is still provided for convenience. Regards, Rodolphe -- Package-specific info: ** Environment settings: INTERFACE="text" ** /home/rodolphe/.reportbugrc: reportbug_version "6.6.3" mode advanced ui text email "rodol...@damsy.net" smtphost "mail.damsy.net:587" smtpuser "rodolphe" smtptls -- System Information: Debian Release: stretch/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.0.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages reportbug depends on: ii apt 1.1~exp8 ii python 2.7.9-1 ii python-reportbug 6.6.3 pn python:any <none> reportbug recommends no packages. Versions of packages reportbug suggests: pn claws-mail <none> ii debconf-utils 1.5.56 pn debsums <none> pn dlocate <none> pn emacs23-bin-common | emacs24-bin-common <none> ii file 1:5.22+15-2 ii gnupg 1.4.19-3 ii msmtp-mta [mail-transport-agent] 1.6.2-1 ii python-gtk2 2.24.0-4 pn python-gtkspell <none> pn python-urwid <none> pn python-vte <none> ii xdg-utils 1.1.0~rc1+git20111210-7.4 Versions of packages python-reportbug depends on: ii apt 1.1~exp8 ii python-debian 0.1.27 ii python-debianbts 1.12 pn python:any <none> python-reportbug suggests no packages. -- no debconf information
>From b08e22a0914315396a241731856ea13e521da0cd Mon Sep 17 00:00:00 2001 From: Rodolphe PELLOUX-PRAYER <rodol...@damsy.net> Date: Sat, 6 Jun 2015 10:34:28 +0200 Subject: [PATCH] Read reportbug config from XDG_CONFIG_HOME too. --- bin/reportbug | 21 ++++++++++++++------- man/reportbug.1 | 9 +++++---- man/reportbug.conf.5 | 4 ++-- reportbug/utils.py | 3 ++- share/script | 25 ++++++++++++++----------- 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/bin/reportbug b/bin/reportbug index 969e798..7761ce7 100755 --- a/bin/reportbug +++ b/bin/reportbug @@ -539,7 +539,7 @@ def offer_configuration(options): 'the first time you have used reportbug, we are ' 'configuring its behavior. These settings will be ' 'saved to the file "%s", which you will be free to ' - 'edit further.\n\n', utils.USERFILE) + 'edit further.\n\n', utils.XDGFILE) mode = ui.menu('Please choose the default operating mode for reportbug.', utils.MODES, 'Select mode: ', options.mode, order=utils.MODELIST) @@ -646,21 +646,28 @@ def offer_configuration(options): ' for example, http://192.168.1.1:3128/. ' 'Just press ENTER if you don\'t have one or don\'t know.', empty_ok=True, force_prompt=True) - + if os.path.exists(utils.USERFILE): + CONFFILE = utils.USERFILE + else: + CONFFILE = utils.XDGFILE + if not os.path.exists(os.path.dirname(CONFFILE)): + os.mkdir(os.path.dirname(CONFFILE)) + + if os.path.exists(CONFFILE): try: - os.rename(utils.USERFILE, utils.USERFILE+'~') + os.rename(CONFFILE, CONFFILE+'~') except OSError: - ui.display_failure('Unable to rename %s as %s~\n', utils.USERFILE, - utils.USERFILE) + ui.display_failure('Unable to rename %s as %s~\n', CONFFILE, + CONFFILE) try: - fd = os.open(utils.USERFILE, os.O_WRONLY|os.O_TRUNC|os.O_CREAT, + fd = os.open(CONFFILE, os.O_WRONLY|os.O_TRUNC|os.O_CREAT, 0600) except OSError, x: efail('Unable to save %s; most likely, you do not have a ' 'home directory. Please fix this before using ' - 'reportbug again.\n', utils.USERFILE) + 'reportbug again.\n', CONFFILE) fp = os.fdopen(fd, 'w') print >> fp, '# reportbug preferences file' diff --git a/man/reportbug.1 b/man/reportbug.1 index df33de5..9a58b58 100644 --- a/man/reportbug.1 +++ b/man/reportbug.1 @@ -93,9 +93,10 @@ Specify report class for GNATS BTSes. .TP .B \-\-configure Rerun the \fBreportbug\fP first time configuration routine, and write -a new \fB$HOME/.reportbugrc\fP file. This will erase any pre-existing +a new \fB$XDG_CONFIG_HOME/debian/reportbugrc\fP file (or +\fB$HOME/.reportbugrc\fP file if exists). This will erase any pre-existing settings in the file; however, a backup will be written as -\fB$HOME/.reportbugrc~\fP. +\fB$XDG_CONFIG_HOME/debian/reportbugrc~\fP (or \fB$HOME/.reportbugrc~\fP). .TP .B \-\-check\-available Check for newer releases of the package at \fBpackages.debian.org\fP @@ -498,8 +499,8 @@ path called \fBls\fP. .SH CONFIGURATION FILES From version 0.22 on, \fBreportbug\fP has supported a simple run control file syntax. Commands are read from \fB/etc/reportbug.conf\fP -and \fB$HOME/.reportbugrc\fP with commands in the latter overriding -those in the former. +\fB$XDG_CONFIG_HOME/debian/reportbugrc\fP, and \fB$HOME/.reportbugrc\fP +with commands in the latter overriding those in the former. Commands are not case sensitive, and currently take 0 or 1 argument; arguments containing whitespace must be enclosed in quotes. diff --git a/man/reportbug.conf.5 b/man/reportbug.conf.5 index 3493889..ff710f1 100644 --- a/man/reportbug.conf.5 +++ b/man/reportbug.conf.5 @@ -32,8 +32,8 @@ This manual page describes the layout of the \fBreportbug\fP and \fBquerybts\fP configuration file and the available configuration options. The default location of the file is \fB/etc/reportbug.conf\fP and the options may be overriding in -\fB$HOME/.reportbugrc\fP (which follows the same format as -\fBreportbug.conf\fP). +\fB$XDG_CONFIG_HOME/debian/reportbug\fP or \fB$HOME/.reportbugrc\fP +(which follows the same format as \fBreportbug.conf\fP). Please note that any configuration file has to be a valid UTF-8 document, and not in a different locale; this is particularly diff --git a/reportbug/utils.py b/reportbug/utils.py index fede038..6dc3178 100644 --- a/reportbug/utils.py +++ b/reportbug/utils.py @@ -815,8 +815,9 @@ class our_lex(shlex.shlex): token = token[1:-1] return token +XDGFILE = os.path.expanduser("%s/debian/reportbugrc" % (os.getenv('XDG_CONFIG_HOME') or '~/.config')) USERFILE = os.path.expanduser('~/.reportbugrc') -FILES = ('/etc/reportbug.conf', USERFILE) +FILES = ('/etc/reportbug.conf', XDGFILE, USERFILE) CONFIG_ARGS = ( 'sendto', 'severity', 'mua', 'mta', 'email', 'realname', 'bts', 'verify', diff --git a/share/script b/share/script index e64c5e9..7961aa9 100755 --- a/share/script +++ b/share/script @@ -17,15 +17,18 @@ for var in ['EDITOR', 'PAGER', 'VISUAL', 'REPORTBUGEMAIL', 'DEBEMAIL', 'EMAIL', passwdre = re.compile(r'\s*(smtppasswd)\s+(.*)$') +XDGFILE = os.path.expanduser("%s/debian/reportbugrc" % (os.getenv('XDG_CONFIG_HOME') or '~/.config')) USERFILE = os.path.expanduser('~/.reportbugrc') -if os.path.exists(USERFILE): - if envprint: - print >> OUT - print >> OUT, '** %s:' % USERFILE - for line in file(USERFILE): - line = line.strip() - if line and not line.startswith('#'): - m = passwdre.match(line) - if m: - line = '%s <omitted>' % m.group(1) - print >> OUT, line + +for conffile in (XDGFILE, USERFILE): + if os.path.exists(conffile): + if envprint: + print >> OUT + print >> OUT, '** %s:' % conffile + for line in file(conffile): + line = line.strip() + if line and not line.startswith('#'): + m = passwdre.match(line) + if m: + line = '%s <omitted>' % m.group(1) + print >> OUT, line -- libgit2 0.22.2