mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
backportpackage:
- Include -y option to skip prompts (LP: #691895) - Allow for just building the source package without a test build or upload (LP: #691896)
This commit is contained in:
commit
7d47a7679e
@ -2,6 +2,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# ##################################################################
|
# ##################################################################
|
||||||
#
|
#
|
||||||
|
# Copyright (C) 2010, Evan Broder <evan@ebroder.net>
|
||||||
|
# Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||||
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; version 2.
|
# as published by the Free Software Foundation; version 2.
|
||||||
@ -55,6 +58,11 @@ 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('-S', '--suffix',
|
||||||
|
dest='suffix',
|
||||||
|
default=None,
|
||||||
|
help='Suffix to append to version number (default: ~ppa1)',
|
||||||
|
metavar='SUFFIX')
|
||||||
p.add_option('-b', '--build',
|
p.add_option('-b', '--build',
|
||||||
dest='build',
|
dest='build',
|
||||||
default=False,
|
default=False,
|
||||||
@ -74,6 +82,11 @@ def parse(args):
|
|||||||
dest='upload',
|
dest='upload',
|
||||||
help='Specify an upload destination',
|
help='Specify an upload destination',
|
||||||
metavar='UPLOAD')
|
metavar='UPLOAD')
|
||||||
|
p.add_option('-y', '--yes',
|
||||||
|
dest='prompt',
|
||||||
|
default=True,
|
||||||
|
action='store_false',
|
||||||
|
help='Do not prompt before uploading to a PPA')
|
||||||
p.add_option('-v', '--version',
|
p.add_option('-v', '--version',
|
||||||
dest='version',
|
dest='version',
|
||||||
default=None,
|
default=None,
|
||||||
@ -93,8 +106,8 @@ def parse(args):
|
|||||||
opts, args = p.parse_args(args)
|
opts, args = p.parse_args(args)
|
||||||
if len(args) != 1:
|
if len(args) != 1:
|
||||||
p.error('You must specify a single source package or a .dsc URL/path')
|
p.error('You must specify a single source package or a .dsc URL/path')
|
||||||
if not opts.upload and not opts.build:
|
if not opts.upload and not opts.workdir:
|
||||||
p.error('Nothing to do')
|
p.error('Please specify either a working dir or an upload target')
|
||||||
|
|
||||||
return opts, args
|
return opts, args
|
||||||
|
|
||||||
@ -171,9 +184,11 @@ def fetch_package(lp, workdir, package, version, source_release):
|
|||||||
cwd=workdir)
|
cwd=workdir)
|
||||||
return os.path.join(workdir, os.path.basename(dsc))
|
return os.path.join(workdir, os.path.basename(dsc))
|
||||||
|
|
||||||
def get_backport_version(version, upload, release):
|
def get_backport_version(version, suffix, upload, release):
|
||||||
v = version + ('~%s1' % release)
|
v = version + ('~%s1' % release)
|
||||||
if upload and upload.startswith('ppa:'):
|
if suffix is not None:
|
||||||
|
v += suffix
|
||||||
|
elif upload and upload.startswith('ppa:'):
|
||||||
v += '~ppa1'
|
v += '~ppa1'
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@ -198,22 +213,25 @@ def do_build(workdir, package, release, bp_version, builder, update):
|
|||||||
release,
|
release,
|
||||||
os.path.join(workdir, "buildresult"))
|
os.path.join(workdir, "buildresult"))
|
||||||
|
|
||||||
def do_upload(workdir, package, bp_version, upload):
|
def do_upload(workdir, package, bp_version, upload, prompt):
|
||||||
print 'Please check %s %s in file://%s carefully!' % \
|
print 'Please check %s %s in file://%s carefully!' % \
|
||||||
(package, bp_version, workdir)
|
(package, bp_version, workdir)
|
||||||
question = 'Do you want to upload the package to %s' % upload
|
if prompt or upload == 'ubuntu':
|
||||||
answer = YesNoQuestion().ask(question, "yes")
|
question = 'Do you want to upload the package to %s' % upload
|
||||||
if answer == "yes":
|
answer = YesNoQuestion().ask(question, "yes")
|
||||||
changes_file = '%s_%s_source.changes' % (package, bp_version)
|
if answer == "no":
|
||||||
check_call(['dput', upload, changes_file], cwd=workdir)
|
return
|
||||||
|
|
||||||
|
changes_file = '%s_%s_source.changes' % (package, bp_version)
|
||||||
|
check_call(['dput', upload, changes_file], cwd=workdir)
|
||||||
|
|
||||||
|
|
||||||
def do_backport(workdir, package, dscfile, version, release, build, builder,
|
def do_backport(workdir, package, dscfile, version, suffix, release, build,
|
||||||
update, upload):
|
builder, update, upload, prompt):
|
||||||
check_call(['dpkg-source', '-x', dscfile, package], cwd=workdir)
|
check_call(['dpkg-source', '-x', dscfile, package], cwd=workdir)
|
||||||
srcdir = os.path.join(workdir, package)
|
srcdir = os.path.join(workdir, package)
|
||||||
|
|
||||||
bp_version = get_backport_version(version, upload, release)
|
bp_version = get_backport_version(version, suffix, upload, release)
|
||||||
bp_dist = get_backport_dist(upload, release)
|
bp_dist = get_backport_dist(upload, release)
|
||||||
|
|
||||||
check_call(['dch',
|
check_call(['dch',
|
||||||
@ -232,7 +250,7 @@ def do_backport(workdir, package, dscfile, version, release, build, builder,
|
|||||||
if 0 != do_build(workdir, package, release, bp_version, builder, update):
|
if 0 != do_build(workdir, package, release, bp_version, builder, update):
|
||||||
error('Package failed to build; aborting')
|
error('Package failed to build; aborting')
|
||||||
if upload:
|
if upload:
|
||||||
do_upload(workdir, package, bp_version, upload)
|
do_upload(workdir, package, bp_version, upload, prompt)
|
||||||
|
|
||||||
shutil.rmtree(srcdir)
|
shutil.rmtree(srcdir)
|
||||||
|
|
||||||
@ -276,11 +294,13 @@ def main(args):
|
|||||||
package,
|
package,
|
||||||
dscfile,
|
dscfile,
|
||||||
version,
|
version,
|
||||||
|
opts.suffix,
|
||||||
release,
|
release,
|
||||||
opts.build,
|
opts.build,
|
||||||
opts.builder,
|
opts.builder,
|
||||||
opts.update,
|
opts.update,
|
||||||
opts.upload)
|
opts.upload,
|
||||||
|
opts.prompt)
|
||||||
finally:
|
finally:
|
||||||
if not opts.workdir:
|
if not opts.workdir:
|
||||||
shutil.rmtree(workdir)
|
shutil.rmtree(workdir)
|
||||||
|
@ -12,9 +12,9 @@ backportpackage \- helper to test package backports
|
|||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B \-d \fIDEST\fR, \-\-destination=\fIDEST\fR
|
.B \-d \fIDEST\fR, \-\-destination=\fIDEST\fR
|
||||||
\fBRequired\fR. Backport the package to the specified Ubuntu
|
Backport the package to the specified Ubuntu release. If this option
|
||||||
release. If this option is unspecified, then \fBbackportpackage\fR
|
is unspecified, then \fBbackportpackage\fR defaults to the release on
|
||||||
defaults to the release on which it is currently running.
|
which it is currently running.
|
||||||
.TP
|
.TP
|
||||||
.B \-s \fISOURCE\fR, \-\-source=\fISOURCE\fR
|
.B \-s \fISOURCE\fR, \-\-source=\fISOURCE\fR
|
||||||
Backport the package from the specified Ubuntu release. If neither
|
Backport the package from the specified Ubuntu release. If neither
|
||||||
@ -22,6 +22,16 @@ 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
|
||||||
|
.B \-S \fISUFFIX\fR, \-\-suffix=\fISUFFIX\fR
|
||||||
|
Add the specified suffix to the version number when
|
||||||
|
backporting. \fBbackportpackage\fR will always append
|
||||||
|
~\fIDESTINATION\fR1 to the original version number, and if
|
||||||
|
\fISUFFIX\fR is specified, it is appended to that, to get version
|
||||||
|
numbers of the form
|
||||||
|
\fIORIGINAL_VERSION\fR~\fIDESTINATION\fR1\fISUFFIX\fR. If the
|
||||||
|
backported package is being uploaded to a PPA, then \fISUFFIX\fR
|
||||||
|
defaults to \fB~ppa1\fR, otherwise the default is blank.
|
||||||
|
.TP
|
||||||
.B \-b, \-\-build
|
.B \-b, \-\-build
|
||||||
Build the package with the specified builder before uploading. Note
|
Build the package with the specified builder before uploading. Note
|
||||||
for \fBpbuilder\fR(8) users: This assumes the common configuration,
|
for \fBpbuilder\fR(8) users: This assumes the common configuration,
|
||||||
@ -39,6 +49,10 @@ Update the build environment before attempting to build.
|
|||||||
.B \-u \fIUPLOAD\fR, \-\-upload=\fIUPLOAD\fR
|
.B \-u \fIUPLOAD\fR, \-\-upload=\fIUPLOAD\fR
|
||||||
Upload to \fIUPLOAD\fR with \fBdput\fR(1) (after confirmation).
|
Upload to \fIUPLOAD\fR with \fBdput\fR(1) (after confirmation).
|
||||||
.TP
|
.TP
|
||||||
|
.B \-y, \-\-yes
|
||||||
|
Do not prompt before uploading to a PPA. For everyone's safety, this
|
||||||
|
option is ignored if \fIUPLOAD\fR is \fBubuntu\fR.
|
||||||
|
.TP
|
||||||
.B \-v \fIVERSION\fR, \-\-version=\fIVERSION\fR
|
.B \-v \fIVERSION\fR, \-\-version=\fIVERSION\fR
|
||||||
If the \fB\-\-source\fR option is specified, then
|
If the \fB\-\-source\fR option is specified, then
|
||||||
\fBbackportpackage\fR verifies that the current version of \fIsource
|
\fBbackportpackage\fR verifies that the current version of \fIsource
|
||||||
|
Loading…
x
Reference in New Issue
Block a user