From 9f6067b68f7da32abab1d7d23e4f5935a6aaf877 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Mon, 13 Dec 2010 04:00:14 -0800 Subject: [PATCH] sponsor-patch: Add --update option to make sure build environment is up to date (LP: #689605) --- backportpackage | 8 ++++++++ debian/changelog | 4 +++- doc/backportpackage.1 | 3 +++ doc/sponsor-patch.1 | 3 +++ sponsor-patch | 23 ++++++++++++++++++----- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/backportpackage b/backportpackage index 27eebed..8a1411c 100755 --- a/backportpackage +++ b/backportpackage @@ -65,6 +65,11 @@ def parse(args): default=None, help='Specify the package builder (default: pbuilder)', metavar='BUILDER') + p.add_option('-U', '--update', + dest='update', + default=False, + action='store_true', + help='Update the build environment before attempting to build') p.add_option('-u', '--upload', dest='upload', help='Specify an upload destination', @@ -166,6 +171,9 @@ def do_build(workdir, package, release, bp_version, opts): if not builder: return + if opts.update: + builder.update(release) + builder.build(os.path.join(workdir, '%s_%s.dsc' % (package, bp_version)), release, diff --git a/debian/changelog b/debian/changelog index 3cc0184..e425cf6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,8 +7,10 @@ ubuntu-dev-tools (0.108) UNRELEASED; urgency=low [ Evan Broder ] * backportpackage: new script for testing backport requests in a PPA. + * sponsor-patch: Add --update option to make sure build environment is + up to date (LP: #689605) - -- Evan Broder Sat, 11 Dec 2010 14:11:54 -0800 + -- Evan Broder Mon, 13 Dec 2010 03:57:20 -0800 ubuntu-dev-tools (0.107) experimental; urgency=low diff --git a/doc/backportpackage.1 b/doc/backportpackage.1 index 341beaf..8fce4c7 100644 --- a/doc/backportpackage.1 +++ b/doc/backportpackage.1 @@ -35,6 +35,9 @@ Use the specified builder to build the package. Supported are \fBpbuilder\fR(8) and \fBsbuild\fR(1). This overrides \fBUBUNTUTOOLS_BUILDER\fR. The default is \fBpbuilder\fR(8). .TP +.B \-U, \-\-update +Update the builder environment before attempting to build. +.TP .B \-u \fIUPLOAD\fR, \-\-upload=\fIUPLOAD\fR Upload to \fIUPLOAD\fR with \fBdput\fR(1) (after confirmation). .TP diff --git a/doc/sponsor-patch.1 b/doc/sponsor-patch.1 index c0e5b6b..5c4f1ec 100644 --- a/doc/sponsor-patch.1 +++ b/doc/sponsor-patch.1 @@ -77,6 +77,9 @@ Shortcut for sponsored uploads. Equivalent to \fB\-b \-u ubuntu\fR. .B \-u \fIDEST\fR, \fB\-\-upload\fR=\fIDEST Upload to \fIDEST\fR with \fBdput\fR(1) (after confirmation). .TP +.BR \-U ", " \-\-update +Make sure the build environment is up to date before building. +.TP .BR \-v ", " \-\-verbose Print more information. .TP diff --git a/sponsor-patch b/sponsor-patch index 0d8cde6..63099a1 100755 --- a/sponsor-patch +++ b/sponsor-patch @@ -409,8 +409,8 @@ def apply_patch(task, patch): edit = True return edit -def main(script_name, bug_number, build, edit, keyid, upload, workdir, builder, - verbose=False): +def main(script_name, bug_number, update, build, edit, keyid, upload, workdir, + builder, verbose=False): workdir = os.path.expanduser(workdir) if not os.path.isdir(workdir): try: @@ -598,6 +598,15 @@ def main(script_name, bug_number, build, edit, keyid, upload, workdir, builder, continue if build: + if update: + ret = builder.update() + if ret != 0: + Logger.error("Failed to update %s chroot for %s." % \ + (changelog.distributions, + builder.get_name())) + ask_for_manual_fixing() + continue + buildresult = os.path.join(workdir, task.package + "-buildresult") if not os.path.isdir(buildresult): os.makedirs(buildresult) @@ -609,7 +618,7 @@ def main(script_name, bug_number, build, edit, keyid, upload, workdir, builder, Logger.error("Failed to build %s from source with %s." % \ (os.path.basename(new_dsc_file), builder.get_name())) - # TODO: Add "retry" and "update" option + # TODO: Add "retry" option ask_for_manual_fixing() continue @@ -706,6 +715,9 @@ if __name__ == "__main__": dest="sponsoring", action="store_true", default=False) parser.add_option("-u", "--upload", dest="upload", default=None, help="Specify an upload destination (default none).") + parser.add_option("-U", "--update", dest="update", default=False, + action="store_true", + help="Update builder chroot before building") parser.add_option("-v", "--verbose", help="print more information", dest="verbose", action="store_true", default=False) parser.add_option("-w", "--workdir", dest="workdir", @@ -737,5 +749,6 @@ if __name__ == "__main__": options.build = True options.upload = "ubuntu" - main(script_name, bug_number, options.build, options.edit, options.keyid, - options.upload, options.workdir, builder, options.verbose) + main(script_name, bug_number, options.update, options.build, options.edit, + options.keyid, options.upload, options.workdir, builder, + options.verbose)