From 2585452cbbc7ed7694d445d3699d0f4bb541717c Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 16 Dec 2010 00:06:57 -0800 Subject: [PATCH] backportpackage: Allow specifying a working directory --- backportpackage | 17 +++++++++++++++-- doc/backportpackage.1 | 14 +++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/backportpackage b/backportpackage index 85e5b82..042481f 100755 --- a/backportpackage +++ b/backportpackage @@ -73,6 +73,11 @@ def parse(args): default=None, help='Package version to backport (or verify)', metavar='VERSION') + p.add_option('-w', '--workdir', + dest='workdir', + default=None, + help='Specify a working directory (default: temporary dir)', + metavar='WORKDIR') p.add_option('-l', '--launchpad', dest='launchpad', default='production', @@ -238,7 +243,14 @@ def main(args): except: error('No destination release specified and unable to guess yours') - workdir = tempfile.mkdtemp(prefix='backportpackage-') + if opts.workdir: + workdir = os.path.expanduser(opts.workdir) + else: + workdir = tempfile.mkdtemp(prefix='backportpackage-') + + if not os.path.exists(workdir): + os.makedirs(workdir) + try: dscfile = fetch_package(lp, workdir, @@ -255,7 +267,8 @@ def main(args): opts.builder, opts.upload) finally: - shutil.rmtree(workdir) + if not opts.workdir: + shutil.rmtree(workdir) if __name__ == '__main__': sys.exit(main(sys.argv)) diff --git a/doc/backportpackage.1 b/doc/backportpackage.1 index c81c338..bae8c13 100644 --- a/doc/backportpackage.1 +++ b/doc/backportpackage.1 @@ -44,6 +44,12 @@ package\fR in \fISOURCE\fR is the same as \fIVERSION\fR. Otherwise, package\fR, regardless of the release in which it was published (or if that version is still current). .TP +.B \-w \fIWORKDIR\fR, \-\-workdir=\fIWORKDIR\fR +If \fIWORKDIR\fR is specified, then all files are downloaded, +unpacked, built into, and otherwise manipulated in +\fIWORKDIR\fR. Otherwise, a temporary directory is created, which is +deleted before \fIbackportpackage\fR exits. +.TP .B \-l \fIINSTANCE\fR, \-\-launchpad=\fIINSTANCE\fR Use the specified instance of Launchpad (e.g. "staging"), instead of the default of "production". @@ -67,17 +73,19 @@ The default builder for Ubuntu development tools that support it \fBpbuilder\fR(8) is used. .SH EXAMPLES Test-build in your PPA a backport of znc from the current development -release to your workstation's release: +release to your workstation's release, deleting the build products +afterwards: .IP .nf .B backportpackage -u ppa:\fIuser\fR/\fIppa\fB znc .fi .PP Backport squashfs-tools from Maverick to both Karmic and Lucid and -test-build both locally: +test-build both locally, leaving all build products in the current +working directory: .IP .nf -.B backportpackage -b -s maverick -d karmic -d lucid squashfs-tools +.B backportpackage -b -s maverick -d karmic -d lucid -w . squashfs-tools .fi .SH AUTHOR \fBbackportpackage\fR and this manpage were written by Evan Broder