diff --git a/backportpackage b/backportpackage index b0374a7..f007b87 100755 --- a/backportpackage +++ b/backportpackage @@ -2,6 +2,9 @@ # -*- coding: utf-8 -*- # ################################################################## # +# Copyright (C) 2010, Evan Broder +# Copyright (C) 2010, Benjamin Drung +# # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 2. @@ -55,6 +58,11 @@ def parse(args): default=None, help='Backport from SOURCE release (default: devel release)', metavar='SOURCE') + p.add_option('-S', '--suffix', + dest='suffix', + default=None, + help='Suffix to append to version number (default: ~ppa1)', + metavar='SUFFIX') p.add_option('-b', '--build', dest='build', default=False, @@ -74,6 +82,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, @@ -93,8 +106,8 @@ def parse(args): opts, args = p.parse_args(args) if len(args) != 1: p.error('You must specify a single source package or a .dsc URL/path') - if not opts.upload and not opts.build: - p.error('Nothing to do') + if not opts.upload and not opts.workdir: + p.error('Please specify either a working dir or an upload target') return opts, args @@ -171,9 +184,11 @@ def fetch_package(lp, workdir, package, version, source_release): cwd=workdir) return os.path.join(workdir, os.path.basename(dsc)) -def get_backport_version(version, upload, release): +def get_backport_version(version, suffix, upload, release): v = version + ('~%s1' % release) - if upload and upload.startswith('ppa:'): + if suffix is not None: + v += suffix + elif upload and upload.startswith('ppa:'): v += '~ppa1' return v @@ -198,22 +213,25 @@ 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 == "no": + 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, release, build, builder, - update, upload): +def do_backport(workdir, package, dscfile, version, suffix, release, build, + builder, update, upload, prompt): check_call(['dpkg-source', '-x', dscfile, package], cwd=workdir) srcdir = os.path.join(workdir, package) - bp_version = get_backport_version(version, upload, release) + bp_version = get_backport_version(version, suffix, upload, release) bp_dist = get_backport_dist(upload, release) check_call(['dch', @@ -232,7 +250,7 @@ def do_backport(workdir, package, dscfile, version, release, build, builder, 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) @@ -276,11 +294,13 @@ def main(args): package, dscfile, version, + opts.suffix, release, opts.build, opts.builder, opts.update, - opts.upload) + opts.upload, + opts.prompt) finally: if not opts.workdir: shutil.rmtree(workdir) diff --git a/doc/backportpackage.1 b/doc/backportpackage.1 index bd08f73..0f6d065 100644 --- a/doc/backportpackage.1 +++ b/doc/backportpackage.1 @@ -12,9 +12,9 @@ backportpackage \- helper to test package backports .SH OPTIONS .TP .B \-d \fIDEST\fR, \-\-destination=\fIDEST\fR -\fBRequired\fR. Backport the package to the specified Ubuntu -release. If this option is unspecified, then \fBbackportpackage\fR -defaults to the release on which it is currently running. +Backport the package to the specified Ubuntu release. If this option +is unspecified, then \fBbackportpackage\fR defaults to the release on +which it is currently running. .TP .B \-s \fISOURCE\fR, \-\-source=\fISOURCE\fR Backport the package from the specified Ubuntu release. If neither @@ -22,6 +22,16 @@ this option nor \fB\-\-version\fR are specified, then \fBbackportpackage\fR defaults to the current Ubuntu development release. .TP +.B \-S \fISUFFIX\fR, \-\-suffix=\fISUFFIX\fR +Add the specified suffix to the version number when +backporting. \fBbackportpackage\fR will always append +~\fIDESTINATION\fR1 to the original version number, and if +\fISUFFIX\fR is specified, it is appended to that, to get version +numbers of the form +\fIORIGINAL_VERSION\fR~\fIDESTINATION\fR1\fISUFFIX\fR. If the +backported package is being uploaded to a PPA, then \fISUFFIX\fR +defaults to \fB~ppa1\fR, otherwise the default is blank. +.TP .B \-b, \-\-build Build the package with the specified builder before uploading. Note for \fBpbuilder\fR(8) users: This assumes the common configuration, @@ -39,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