Support configuration in backportpackage

This commit is contained in:
Stefano Rivera 2010-12-19 22:32:53 +02:00
parent 8b5cd3d045
commit 1bb418e02f
5 changed files with 36 additions and 12 deletions

View File

@ -30,6 +30,7 @@ from debian.deb822 import Dsc
import launchpadlib.launchpad
import lsb_release
from ubuntutools.config import get_value, ubu_email
from ubuntutools.builder import getBuilder
from ubuntutools.logger import Logger
from ubuntutools.question import YesNoQuestion
@ -70,12 +71,12 @@ def parse(args):
help='Build the package before uploading (default: %default)')
p.add_option('-B', '--builder',
dest='builder',
default=None,
help='Specify the package builder (default: pbuilder)',
default=get_value('BUILDER'),
help='Specify the package builder (default: %default)',
metavar='BUILDER')
p.add_option('-U', '--update',
dest='update',
default=False,
default=get_value('UPDATE_BUILDER'),
action='store_true',
help='Update the build environment before attempting to build')
p.add_option('-u', '--upload',
@ -94,12 +95,12 @@ def parse(args):
metavar='VERSION')
p.add_option('-w', '--workdir',
dest='workdir',
default=None,
default=get_value('WORKDIR'),
help='Specify a working directory (default: temporary dir)',
metavar='WORKDIR')
p.add_option('-l', '--launchpad',
dest='launchpad',
default='production',
default=get_value('LPINSTANCE'),
help='Launchpad instance to connect to (default: %default)',
metavar='INSTANCE')
@ -233,6 +234,7 @@ def do_backport(workdir, package, dscfile, version, suffix, release, build,
bp_version = get_backport_version(version, suffix, upload, release)
bp_dist = get_backport_dist(upload, release)
ubu_email()
check_call(['dch',
'--force-bad-version',
'--preserve',

View File

@ -83,13 +83,19 @@ removed once the script finishes running.
.PP
\fBbackportpackage\fR is only recommended for testing backports in a
PPA, not uploading backports to the Ubuntu archive.
.SH ENVIRONMENT
.SH CONFIGURATION VARIABLES
The following variables can be set in the
.BR ubuntu\-dev\-tools (5)
configuration files:
.TP
.B UBUNTUTOOLS_BUILDER
The default builder for Ubuntu development tools that support it
(including \fBbackportpackage\fR). Supported are \fBpbuilder\fR(8),
\fBpbuilder-dist\fR(1), and \fBsbuild\fR(1).
If unset and not provided on the command line, \fBpbuilder\fR(8) is used.
.BR BACKPORTPACKAGE_BUILDER ", " UBUNTUTOOLS_BUILDER
The default value for \fB\-\-builder\fR.
.TP
.BR BACKPORTPACKAGE_UPDATE_BUILDER ", " UBUNTUTOOLS_UPDATE_BUILDER
The default value for \fB--update\fR.
.TP
.BR BACKPORTPACKAGE_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE
The default value for \fB--launchpad\fR.
.SH EXAMPLES
Test-build in your PPA a backport of znc from the current development
release to your workstation's release, deleting the build products
@ -115,6 +121,8 @@ to the same PPA:
.B backportpackage -d hardy -u ppa:\fIuser\fR/\fIppa\fR \\\\
.B " "https://launchpad.net/\fIsome/file.dsc\fR
.fi
.SH SEE ALSO
.BR ubuntu\-dev\-tools (5)
.SH AUTHOR
\fBbackportpackage\fR and this manpage were written by Evan Broder
<evan@ebroder.net>

View File

@ -55,6 +55,11 @@ The currently recognised package\-wide variables are:
This specifies the preferred test\-builder, one of
.BR pbuilder " (default), " sbuild ", " pbuilder\-dist .
.TP
.B UBUNTUTOOLS_LPINSTANCE
The launchpad instance to communicate with. e.g. \fBproduction\fR
(default) or \fBstaging\fR.
.SH SEE ALSO
.BR devscripts (1),
.BR devscripts.conf (5)

View File

@ -22,6 +22,7 @@
import os
import subprocess
from ubuntutools.config import get_value
from ubuntutools.logger import Logger
class Builder(object):
@ -146,7 +147,7 @@ class Sbuild(Builder):
def getBuilder(builder=None):
if not builder:
builder = os.environ.get('UBUNTUTOOLS_BUILDER', 'pbuilder')
builder = get_value('BUILDER')
if builder == 'pbuilder':
return Pbuilder()

View File

@ -25,6 +25,12 @@ import sys
from ubuntutools.common import memoize_noargs
defaults = {
'BUILDER': 'pbuilder',
'UPDATE_BUILDER': False,
'LPINSTANCE': 'production',
}
@memoize_noargs
def get_devscripts_config():
"""Read the devscripts configuration files, and return the values as a
@ -67,6 +73,8 @@ def get_value(key, default=None, prefix=None, compat_vars=[]):
value = value == 'yes'
return value
if key in defaults:
return defaults[key]
return default
def ubu_email(name=None, email=None, export=True):