mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-09 16:01:28 +00:00
backportpackage: Add a --build option. (And a --builder option)
This commit is contained in:
parent
b56b02683b
commit
ccb14b6831
@ -25,6 +25,7 @@ import tempfile
|
|||||||
from debian.deb822 import Dsc
|
from debian.deb822 import Dsc
|
||||||
import launchpadlib.launchpad
|
import launchpadlib.launchpad
|
||||||
|
|
||||||
|
from ubuntutools.builder import getBuilder
|
||||||
from ubuntutools.logger import Logger
|
from ubuntutools.logger import Logger
|
||||||
|
|
||||||
devnull = open('/dev/null', 'r+')
|
devnull = open('/dev/null', 'r+')
|
||||||
@ -43,10 +44,6 @@ def check_call(cmd, *args, **kwargs):
|
|||||||
def parse(args):
|
def parse(args):
|
||||||
usage = 'Usage: %prog [options] <source package>'
|
usage = 'Usage: %prog [options] <source package>'
|
||||||
p = optparse.OptionParser(usage)
|
p = optparse.OptionParser(usage)
|
||||||
p.add_option('-u', '--upload',
|
|
||||||
dest='upload',
|
|
||||||
help='Specify an upload destination (required)',
|
|
||||||
metavar='UPLOAD')
|
|
||||||
p.add_option('-t', '--to',
|
p.add_option('-t', '--to',
|
||||||
dest='dest_releases',
|
dest='dest_releases',
|
||||||
default=[],
|
default=[],
|
||||||
@ -58,6 +55,20 @@ def parse(args):
|
|||||||
default=None,
|
default=None,
|
||||||
help='Backport from SOURCE release (default: devel release)',
|
help='Backport from SOURCE release (default: devel release)',
|
||||||
metavar='SOURCE')
|
metavar='SOURCE')
|
||||||
|
p.add_option('-b', '--build',
|
||||||
|
dest='build',
|
||||||
|
default=False,
|
||||||
|
action='store_true',
|
||||||
|
help='Build the package before uploading (default: %default)')
|
||||||
|
p.add_option('-B', '--builder',
|
||||||
|
dest='builder',
|
||||||
|
default=None,
|
||||||
|
help='Specify the package builder (default: pbuilder)',
|
||||||
|
metavar='BUILDER')
|
||||||
|
p.add_option('-u', '--upload',
|
||||||
|
dest='upload',
|
||||||
|
help='Specify an upload destination',
|
||||||
|
metavar='UPLOAD')
|
||||||
p.add_option('-v', '--version',
|
p.add_option('-v', '--version',
|
||||||
dest='version',
|
dest='version',
|
||||||
default=None,
|
default=None,
|
||||||
@ -74,8 +85,6 @@ def parse(args):
|
|||||||
p.error('You must specify a source package')
|
p.error('You must specify a source package')
|
||||||
if not opts.dest_releases:
|
if not opts.dest_releases:
|
||||||
p.error('You must specify at least one destination release')
|
p.error('You must specify at least one destination release')
|
||||||
if not opts.upload:
|
|
||||||
p.error('You must specify an upload destination')
|
|
||||||
|
|
||||||
return opts, args
|
return opts, args
|
||||||
|
|
||||||
@ -143,16 +152,42 @@ def fetch_package(workdir, package, opts):
|
|||||||
|
|
||||||
def get_backport_version(version, upload, release):
|
def get_backport_version(version, upload, release):
|
||||||
v = version + ('~%s1' % release)
|
v = version + ('~%s1' % release)
|
||||||
if upload.startswith('ppa:'):
|
if upload and upload.startswith('ppa:'):
|
||||||
v += '~ppa1'
|
v += '~ppa1'
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def get_backport_dist(upload, release):
|
def get_backport_dist(upload, release):
|
||||||
if upload == 'ubuntu':
|
if not upload or upload == 'ubuntu':
|
||||||
return '%s-backports' % release
|
return '%s-backports' % release
|
||||||
else:
|
else:
|
||||||
return release
|
return release
|
||||||
|
|
||||||
|
def do_build(workdir, package, release, bp_version, opts):
|
||||||
|
builder = getBuilder(opts.builder)
|
||||||
|
if not builder:
|
||||||
|
return
|
||||||
|
|
||||||
|
builder.build(os.path.join(workdir,
|
||||||
|
'%s_%s.dsc' % (package, bp_version)),
|
||||||
|
release,
|
||||||
|
workdir)
|
||||||
|
|
||||||
|
def do_upload(workdir, package, bp_version, opts):
|
||||||
|
prompt = 'Do you want to upload this to %s? [Y/n]' % opts.upload
|
||||||
|
while True:
|
||||||
|
answer = raw_input(prompt).strip().lower()
|
||||||
|
if answer in ('', 'y', 'yes'):
|
||||||
|
break
|
||||||
|
elif answer in ('n', 'no'):
|
||||||
|
return
|
||||||
|
|
||||||
|
check_call(['dput',
|
||||||
|
opts.upload,
|
||||||
|
'%s_%s_source.changes' %
|
||||||
|
(package, bp_version)],
|
||||||
|
cwd=workdir)
|
||||||
|
|
||||||
|
|
||||||
def do_backport(workdir, package, dscfile, release, opts):
|
def do_backport(workdir, package, dscfile, release, opts):
|
||||||
dsc = Dsc(open(os.path.join(workdir, dscfile)))
|
dsc = Dsc(open(os.path.join(workdir, dscfile)))
|
||||||
v = dsc['Version']
|
v = dsc['Version']
|
||||||
@ -181,19 +216,11 @@ def do_backport(workdir, package, dscfile, release, opts):
|
|||||||
bp_version = bp_version[bp_version.find(':')+1:]
|
bp_version = bp_version[bp_version.find(':')+1:]
|
||||||
|
|
||||||
print 'Please check the package in file://%s carefully' % workdir
|
print 'Please check the package in file://%s carefully' % workdir
|
||||||
prompt = 'Do you want to upload this to %s? [Y/n]' % opts.upload
|
if opts.build:
|
||||||
while True:
|
do_build(workdir, package, release, bp_version, opts)
|
||||||
answer = raw_input(prompt).strip().lower()
|
if opts.upload:
|
||||||
if answer in ('', 'y', 'yes'):
|
do_upload(workdir, package, bp_version, opts)
|
||||||
check_call(['dput',
|
|
||||||
opts.upload,
|
|
||||||
'%s_%s_source.changes' %
|
|
||||||
(package, bp_version)],
|
|
||||||
cwd=workdir)
|
|
||||||
|
|
||||||
break
|
|
||||||
elif answer in ('n', 'no'):
|
|
||||||
break
|
|
||||||
shutil.rmtree(srcdir)
|
shutil.rmtree(srcdir)
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
|
@ -13,22 +13,32 @@ backportpackage \- helper to test package backports
|
|||||||
.B backportpackage \-h
|
.B backportpackage \-h
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.BR \-u \fIUPLOAD\fR, \-\-upload=\fIUPLOAD\fR
|
.B \-t \fIDEST\fR, \-\-to=\fIDEST\fR
|
||||||
\fBRequired\fR. Upload to \fIUPLOAD\fR with \fBdput\fR(1) (after
|
|
||||||
confirmation).
|
|
||||||
.TP
|
|
||||||
.BR \-t \fIDEST\fR, \-\-to=\fIDEST\fR
|
|
||||||
\fBRequired\fR. Backport the package to the specified Ubuntu
|
\fBRequired\fR. Backport the package to the specified Ubuntu
|
||||||
release. This option may be specified multiple times, but must be
|
release. This option may be specified multiple times, but must be
|
||||||
specified at least once.
|
specified at least once.
|
||||||
.TP
|
.TP
|
||||||
.BR \-f \fISOURCE\fR, \-\-from=\fISOURCE\fR
|
.B \-f \fISOURCE\fR, \-\-from=\fISOURCE\fR
|
||||||
Backport the package from the specified Ubuntu release. If neither
|
Backport the package from the specified Ubuntu release. If neither
|
||||||
this option nor \fB\-\-version\fR are specified, then
|
this option nor \fB\-\-version\fR are specified, then
|
||||||
\fBbackportpackage\fR defaults to the current Ubuntu development
|
\fBbackportpackage\fR defaults to the current Ubuntu development
|
||||||
release.
|
release.
|
||||||
.TP
|
.TP
|
||||||
.BR \-v \fIVERSION\fR, \-\-version=\fIVERSION\fR
|
.B \-b, \-\-build
|
||||||
|
Build the package with the specified builder before uploading. Note
|
||||||
|
for \fBpbuilder\fR(8) users: This assumes the common configuration,
|
||||||
|
where the \fBDIST\fR environment is read by \fBpbuilderrc\fR(5) to
|
||||||
|
select the correct base image.
|
||||||
|
.TP
|
||||||
|
.B \-B \fIBUILDER\fR, \fB\-\-builder\fR=\fIBUILDER
|
||||||
|
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 \fIUPLOAD\fR, \-\-upload=\fIUPLOAD\fR
|
||||||
|
Upload to \fIUPLOAD\fR with \fBdput\fR(1) (after confirmation).
|
||||||
|
.TP
|
||||||
|
.B \-v \fIVERSION\fR, \-\-version=\fIVERSION\fR
|
||||||
If the \fB\-\-from\fR option is specified, then \fBbackportpackage\fR
|
If the \fB\-\-from\fR option is specified, then \fBbackportpackage\fR
|
||||||
verifies that the current version of \fIsource package\fR in
|
verifies that the current version of \fIsource package\fR in
|
||||||
\fISOURCE\fR is the same as \fIVERSION\fR. Otherwise,
|
\fISOURCE\fR is the same as \fIVERSION\fR. Otherwise,
|
||||||
@ -36,19 +46,27 @@ verifies that the current version of \fIsource package\fR in
|
|||||||
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
|
||||||
.BR \-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".
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
\fBbackportpackage\fR fetches a package from one Ubuntu release and
|
\fBbackportpackage\fR fetches a package from one Ubuntu release and
|
||||||
creates a no-change backport of that package to a previous release,
|
creates a no-change backport of that package to a previous release,
|
||||||
uploading the resulting backport for testing.
|
optionally doing a test build of the package and/or uploading the
|
||||||
|
resulting backport for testing.
|
||||||
.PP
|
.PP
|
||||||
The backported package is fetched and built in a temporary directory
|
The backported package is fetched and built in a temporary directory
|
||||||
in \fB/tmp\fR, which is removed once the script finishes running.
|
in \fB/tmp\fR, which is removed once the script finishes running.
|
||||||
.PP
|
.PP
|
||||||
\fBbackportpackage\fR is only recommended for testing backports in a
|
\fBbackportpackage\fR is only recommended for testing backports in a
|
||||||
PPA, not uploading backports to the Ubuntu archive.
|
PPA, not uploading backports to the Ubuntu archive.
|
||||||
|
.SH ENVIRONMENT
|
||||||
|
.TP
|
||||||
|
.B UBUNTUTOOLS_BUILDER
|
||||||
|
The default builder for Ubuntu development tools that support it
|
||||||
|
(including \fBbackportpackage\fR. Supported are \fBpbuilder\fR(8) and
|
||||||
|
\fBsbuild\fR(1). If unset and not provided on the command line,
|
||||||
|
\fBpbuilder\fR(8) is used.
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
\fBbackportpackage\fR and this manpage were written by Evan Broder
|
\fBbackportpackage\fR and this manpage were written by Evan Broder
|
||||||
<evan@ebroder.net>
|
<evan@ebroder.net>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user