From dcaab5fc4769388835dcb07836b0991323fa540f Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Fri, 30 Jul 2010 03:51:33 +0200 Subject: [PATCH] update-maintainer: Add a --quiet option. --- debian/changelog | 3 ++- syncpackage | 2 ++ update-maintainer | 23 ++++++++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 479e886..d81e1e4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,7 @@ ubuntu-dev-tools (0.101) UNRELEASED; urgency=low version for debian versions that contain more than one dash. - Prepend script name to every output - Output every executed command in verbose mode + * update-maintainer: Add a --quiet option. [ Michael Bienia ] * ubuntutools/lpapi/lpapicache.py: Use the new LP API method @@ -27,7 +28,7 @@ ubuntu-dev-tools (0.101) UNRELEASED; urgency=low * requestsync: Fix bug where the variable 'hasLP' is not always set (lp: #607874). - -- Benjamin Drung Fri, 30 Jul 2010 03:26:59 +0200 + -- Benjamin Drung Fri, 30 Jul 2010 03:51:02 +0200 ubuntu-dev-tools (0.100) maverick; urgency=low diff --git a/syncpackage b/syncpackage index fc717fc..a3980e0 100755 --- a/syncpackage +++ b/syncpackage @@ -325,6 +325,8 @@ def sync_dsc(script_name, dscurl, debian_dist, release, name, email, bugs, keyid # update the Maintainer field cmd = ["update-maintainer"] + if not verbose: + cmd.append("-q") if verbose: print_command(script_name, cmd) subprocess.check_call(cmd) diff --git a/update-maintainer b/update-maintainer index 2afe4c8..768c00e 100755 --- a/update-maintainer +++ b/update-maintainer @@ -26,11 +26,20 @@ # along with this program. If not, see . # +import optparse import os import re import sys import ubuntutools.packages +script_name = os.path.basename(sys.argv[0]) +usage = "%s [options]" % (script_name) +epilog = "See %s(1) for more info." % (script_name) +parser = optparse.OptionParser(usage=usage, epilog=epilog) +parser.add_option("-q", "--quiet", help="print no informational messages", + dest="quiet", action="store_true", default=False) +(options, args) = parser.parse_args() + valid_locations = ["debian/control.in", "control.in", "debian/control", "control"] control_file_found = False @@ -67,13 +76,15 @@ maintainer_name = maintainer_field[0][1] maintainer_mail = maintainer_field[0][2] if maintainer_mail.find("@ubuntu.com") != -1: - print "Maintainer email is set to an @ubuntu.com address - doing nothing." + if not options.quiet: + print "Maintainer email is set to an @ubuntu.com address - doing nothing." sys.exit(0) # Check if Maintainer field is as approved in TB decision. if 'Ubuntu Developers' in maintainer_name and \ '' in maintainer_mail: - print "Ubuntu Developers is already set as maintainer." + if not options.quiet: + print "Ubuntu Developers is already set as maintainer." sys.exit(0) if not (ubuntutools.packages.checkIsInDebian(package_name, 'unstable') or ubuntutools.packages.checkIsInDebian(package_name, 'experimental')): @@ -105,14 +116,16 @@ if not "lists.ubuntu.com" in original_maintainer: original_maintainer_fields = re.findall('(.*Original-Maintainer): (.*)', file_contents) if len(original_maintainer_fields) > 0: for original_maintainer_field in original_maintainer_fields: - print "Removing existing %s: %s" % original_maintainer_field + if not options.quiet: + print "Removing existing %s: %s" % original_maintainer_field file_contents = re.sub('.*Original-Maintainer: .*\n', "", file_contents) final_addition = "Maintainer: " + target_maintainer + "\nXSBC-Original-Maintainer: " + original_maintainer else: final_addition = "Maintainer: " + target_maintainer -print "The original maintainer for this package is: " + original_maintainer -print "Resetting as: " + target_maintainer +if not options.quiet: + print "The original maintainer for this package is: " + original_maintainer + print "Resetting as: " + target_maintainer # Replace text. debian_control_file = open(control_file, "w")