From 735ac962c3b353793c3259b6476de3346c762b8f Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sat, 18 Dec 2010 12:29:38 -0800 Subject: [PATCH] Include -y option to skip prompts (LP: #691895) --- backportpackage | 27 ++++++++++++++++++--------- debian/changelog | 1 + doc/backportpackage.1 | 4 ++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/backportpackage b/backportpackage index de6c472..e3cd8b2 100755 --- a/backportpackage +++ b/backportpackage @@ -81,6 +81,11 @@ def parse(args): dest='upload', help='Specify an upload destination', metavar='UPLOAD') + p.add_option('-y', '--yes', + dest='prompt', + default=True, + action='store_false', + help='Do not prompt before uploading to a PPA') p.add_option('-v', '--version', dest='version', default=None, @@ -207,18 +212,21 @@ def do_build(workdir, package, release, bp_version, builder, update): release, os.path.join(workdir, "buildresult")) -def do_upload(workdir, package, bp_version, upload): +def do_upload(workdir, package, bp_version, upload, prompt): print 'Please check %s %s in file://%s carefully!' % \ (package, bp_version, workdir) - question = 'Do you want to upload the package to %s' % upload - answer = YesNoQuestion().ask(question, "yes") - if answer == "yes": - changes_file = '%s_%s_source.changes' % (package, bp_version) - check_call(['dput', upload, changes_file], cwd=workdir) + if prompt or upload == 'ubuntu': + question = 'Do you want to upload the package to %s' % upload + answer = YesNoQuestion().ask(question, "yes") + if answer != "yes": + return + + changes_file = '%s_%s_source.changes' % (package, bp_version) + check_call(['dput', upload, changes_file], cwd=workdir) def do_backport(workdir, package, dscfile, version, suffix, release, build, - builder, update, upload): + builder, update, upload, prompt): check_call(['dpkg-source', '-x', dscfile, package], cwd=workdir) srcdir = os.path.join(workdir, package) @@ -241,7 +249,7 @@ def do_backport(workdir, package, dscfile, version, suffix, release, build, if 0 != do_build(workdir, package, release, bp_version, builder, update): error('Package failed to build; aborting') if upload: - do_upload(workdir, package, bp_version, upload) + do_upload(workdir, package, bp_version, upload, prompt) shutil.rmtree(srcdir) @@ -290,7 +298,8 @@ def main(args): opts.build, opts.builder, opts.update, - opts.upload) + opts.upload, + opts.prompt) finally: if not opts.workdir: shutil.rmtree(workdir) diff --git a/debian/changelog b/debian/changelog index 772920f..5fa76b9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,7 @@ ubuntu-dev-tools (0.108) UNRELEASED; urgency=low [ Evan Broder ] * backportpackage: new script for testing backport requests in a PPA. + - Include -y option to skip prompts (LP: #691895) * sponsor-patch: Add --update option to make sure build environment is up to date (LP: #689605) diff --git a/doc/backportpackage.1 b/doc/backportpackage.1 index cdd4ede..0f6d065 100644 --- a/doc/backportpackage.1 +++ b/doc/backportpackage.1 @@ -49,6 +49,10 @@ Update the build environment before attempting to build. .B \-u \fIUPLOAD\fR, \-\-upload=\fIUPLOAD\fR Upload to \fIUPLOAD\fR with \fBdput\fR(1) (after confirmation). .TP +.B \-y, \-\-yes +Do not prompt before uploading to a PPA. For everyone's safety, this +option is ignored if \fIUPLOAD\fR is \fBubuntu\fR. +.TP .B \-v \fIVERSION\fR, \-\-version=\fIVERSION\fR If the \fB\-\-source\fR option is specified, then \fBbackportpackage\fR verifies that the current version of \fIsource