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

View File

@ -83,13 +83,19 @@ 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 .SH CONFIGURATION VARIABLES
The following variables can be set in the
.BR ubuntu\-dev\-tools (5)
configuration files:
.TP .TP
.B UBUNTUTOOLS_BUILDER .BR BACKPORTPACKAGE_BUILDER ", " UBUNTUTOOLS_BUILDER
The default builder for Ubuntu development tools that support it The default value for \fB\-\-builder\fR.
(including \fBbackportpackage\fR). Supported are \fBpbuilder\fR(8), .TP
\fBpbuilder-dist\fR(1), and \fBsbuild\fR(1). .BR BACKPORTPACKAGE_UPDATE_BUILDER ", " UBUNTUTOOLS_UPDATE_BUILDER
If unset and not provided on the command line, \fBpbuilder\fR(8) is used. The default value for \fB--update\fR.
.TP
.BR BACKPORTPACKAGE_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE
The default value for \fB--launchpad\fR.
.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, deleting the build products 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 backportpackage -d hardy -u ppa:\fIuser\fR/\fIppa\fR \\\\
.B " "https://launchpad.net/\fIsome/file.dsc\fR .B " "https://launchpad.net/\fIsome/file.dsc\fR
.fi .fi
.SH SEE ALSO
.BR ubuntu\-dev\-tools (5)
.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>

View File

@ -55,6 +55,11 @@ The currently recognised package\-wide variables are:
This specifies the preferred test\-builder, one of This specifies the preferred test\-builder, one of
.BR pbuilder " (default), " sbuild ", " pbuilder\-dist . .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 .SH SEE ALSO
.BR devscripts (1), .BR devscripts (1),
.BR devscripts.conf (5) .BR devscripts.conf (5)

View File

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

View File

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