From 1bb418e02fa775fb2431f8313b899a59e6e08c59 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 19 Dec 2010 22:32:53 +0200 Subject: [PATCH] Support configuration in backportpackage --- backportpackage | 12 +++++++----- doc/backportpackage.1 | 20 ++++++++++++++------ doc/ubuntu-dev-tools.5 | 5 +++++ ubuntutools/builder.py | 3 ++- ubuntutools/config.py | 8 ++++++++ 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/backportpackage b/backportpackage index ea2a8ec..8cb4617 100755 --- a/backportpackage +++ b/backportpackage @@ -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', diff --git a/doc/backportpackage.1 b/doc/backportpackage.1 index 0f6d065..e07cc40 100644 --- a/doc/backportpackage.1 +++ b/doc/backportpackage.1 @@ -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 diff --git a/doc/ubuntu-dev-tools.5 b/doc/ubuntu-dev-tools.5 index 162a228..5b6a1a5 100644 --- a/doc/ubuntu-dev-tools.5 +++ b/doc/ubuntu-dev-tools.5 @@ -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) diff --git a/ubuntutools/builder.py b/ubuntutools/builder.py index dab6fea..8b581cf 100644 --- a/ubuntutools/builder.py +++ b/ubuntutools/builder.py @@ -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() diff --git a/ubuntutools/config.py b/ubuntutools/config.py index 2713f8a..4c24ace 100644 --- a/ubuntutools/config.py +++ b/ubuntutools/config.py @@ -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):