backportpackage: Allow specifying a working directory

This commit is contained in:
Evan Broder 2010-12-16 00:06:57 -08:00
parent 44f2b31a98
commit 2585452cbb
2 changed files with 26 additions and 5 deletions

View File

@ -73,6 +73,11 @@ def parse(args):
default=None, default=None,
help='Package version to backport (or verify)', help='Package version to backport (or verify)',
metavar='VERSION') 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', p.add_option('-l', '--launchpad',
dest='launchpad', dest='launchpad',
default='production', default='production',
@ -238,7 +243,14 @@ def main(args):
except: except:
error('No destination release specified and unable to guess yours') 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: try:
dscfile = fetch_package(lp, dscfile = fetch_package(lp,
workdir, workdir,
@ -255,7 +267,8 @@ def main(args):
opts.builder, opts.builder,
opts.upload) opts.upload)
finally: finally:
shutil.rmtree(workdir) if not opts.workdir:
shutil.rmtree(workdir)
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main(sys.argv)) sys.exit(main(sys.argv))

View File

@ -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 package\fR, regardless of the release in which it was published (or if
that version is still current). that version is still current).
.TP .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 .B \-l \fIINSTANCE\fR, \-\-launchpad=\fIINSTANCE\fR
Use the specified instance of Launchpad (e.g. "staging"), instead of Use the specified instance of Launchpad (e.g. "staging"), instead of
the default of "production". the default of "production".
@ -67,17 +73,19 @@ The default builder for Ubuntu development tools that support it
\fBpbuilder\fR(8) is used. \fBpbuilder\fR(8) is used.
.SH EXAMPLES .SH EXAMPLES
Test-build in your PPA a backport of znc from the current development 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 .IP
.nf .nf
.B backportpackage -u ppa:\fIuser\fR/\fIppa\fB znc .B backportpackage -u ppa:\fIuser\fR/\fIppa\fB znc
.fi .fi
.PP .PP
Backport squashfs-tools from Maverick to both Karmic and Lucid and 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 .IP
.nf .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 .fi
.SH AUTHOR .SH AUTHOR
\fBbackportpackage\fR and this manpage were written by Evan Broder \fBbackportpackage\fR and this manpage were written by Evan Broder