From dd46215fbe4462a8525253025d2d55aeb073d0b4 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Jun 2011 12:15:57 +0200 Subject: [PATCH] submittodebian: Write a usable .reportbugrc if it doesn't exist. (LP: #800429) --- debian/changelog | 2 ++ submittodebian | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/debian/changelog b/debian/changelog index ccd5386..e1929b3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,8 @@ ubuntu-dev-tools (0.125) UNRELEASED; urgency=low guessing at the cause. (LP: #788447) * sponsor-patch: Use dch --release instead of --edit to work with DEBCHANGE_RELEASE_HEURISTIC=changelog. + * submittodebian: Write a usable .reportbugrc if it doesn't exist. + (LP: #800429) [ Dustin Kirkland ] * doc/lp-project-upload.1, lp-project-upload: diff --git a/submittodebian b/submittodebian index be6f883..c760e3a 100755 --- a/submittodebian +++ b/submittodebian @@ -25,6 +25,8 @@ import re, os, sys from tempfile import mkstemp +from ubuntutools.config import ubu_email +from ubuntutools.question import YesNoQuestion from ubuntutools.distro_info import UbuntuDistroInfo try: @@ -119,7 +121,47 @@ def run_cmd(cmd): print "%s\n" % cmd os.system(cmd) +def check_reportbug_config(): + fn = os.path.expanduser('~/.reportbugrc') + if os.path.exists(fn): + return + email = ubu_email()[1] + reportbugrc = """# Reportbug configuration generated by submittodebian(1) +# See reportbug.conf(5) for the configuration file format. + +# Use Debian's reportbug SMTP Server: +# Note: it's limited to 5 connections per hour, and cannot CC you at submission +# time. See /usr/share/doc/reportbug/README.Users.gz for more details. +smtphost reportbug.debian.org:587 +header "X-Debbugs-CC: %s" +no-cc + +# Use GMail's SMTP Server: +#smtphost smtp.googlemail.com:587 +#smtpuser "@gmail.com" +#smtptls +""" % email + + with file(fn, 'w') as f: + f.write(reportbugrc) + + print """You have not configured reportbug. Assuming this is the first time you have used it. +Writing a ~/.reportbugrc that will use Debian's mailserver, and CC the bug to +you at <%s> + +--- Generated ~/.reportbugrc --- +%s +--- End of ~/.reportbugrc --- + +If this is not correct, please exit now and edit ~/.reportbugrc or run +reportbug --configure for its configuration wizard. +""" % (email, reportbugrc.strip()) + + if YesNoQuestion().ask("Continue submitting this bug?", "yes") == "no": + sys.exit(1) + def main(): + check_reportbug_config() changelog_file = (check_file('debian/changelog', critical = False) or check_file('../debian/changelog')) changelog = Changelog(file(changelog_file).read())