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,
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))

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
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