mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
sponsor-patch: Separate multi-builder support into a Python module.
Rename SPONSOR_PATCH_BUILDER environment variable to UBUNTUTOOLS_BUILDER (but still support SPONSOR_PATCH_BUILDER)
This commit is contained in:
parent
fc7faa9780
commit
b56b02683b
@ -61,7 +61,7 @@ by \fBpbuilderrc\fR(5) to select the correct base image.
|
||||
.B \-B \fIBUILDER\fR, \fB\-\-builder\fR=\fIBUILDER
|
||||
Use the specify builder to build the package.
|
||||
Supported are \fBpbuilder\fR(8) and \fBsbuild\fR(1).
|
||||
This overrides \fBSPONSOR_PATCH_BUILDER\fR.
|
||||
This overrides \fBUBUNTUTOOLS_BUILDER\fR and \fBSPONSOR_PATCH_BUILDER\fR.
|
||||
The default is \fBpbuilder\fR(8).
|
||||
.TP
|
||||
.BR \-e ", " \-\-edit
|
||||
@ -90,11 +90,16 @@ Display a help message and exit.
|
||||
.SH ENVIRONMENT
|
||||
|
||||
.TP
|
||||
.B SPONSOR_PATCH_BUILDER
|
||||
The default builder for \fBsponsor\-patch\fR.
|
||||
.B UBUNTUTOOLS_BUILDER
|
||||
The default builder for Ubuntu development tools that support it (including \fBsponsor\-patch\fR.
|
||||
Supported are \fBpbuilder\fR(8) and \fBsbuild\fR(1).
|
||||
If unset and not provided on the command line, \fBpbuilder\fR(8) is used.
|
||||
|
||||
.TP
|
||||
.B SPONSOR_PATCH_BUILDER
|
||||
The default builder for \fBsponsor\-patch\fR.
|
||||
If specified, this overrides \fBUBUNTUTOOLS_BUILDER\fR.
|
||||
|
||||
.TP
|
||||
.B SPONSOR_PATCH_WORKDIR
|
||||
The default working directory for \fBsponsor\-patch\fR. If unset and not
|
||||
|
@ -28,6 +28,7 @@ import debian.deb822
|
||||
import debian.debian_support
|
||||
import launchpadlib.launchpad
|
||||
|
||||
from ubuntutools.builder import getBuilder
|
||||
import ubuntutools.update_maintainer
|
||||
from ubuntutools.logger import Logger
|
||||
|
||||
@ -149,50 +150,6 @@ class BugTask(object):
|
||||
return self.project == "ubuntu"
|
||||
|
||||
|
||||
class Builder(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
cmd = ["dpkg-architecture", "-qDEB_BUILD_ARCH_CPU"]
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
self.architecture = process.communicate()[0].strip()
|
||||
|
||||
def get_architecture(self):
|
||||
return self.architecture
|
||||
|
||||
def get_name(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Pbuilder(Builder):
|
||||
def __init__(self):
|
||||
Builder.__init__(self, "pbuilder")
|
||||
|
||||
def build(self, dsc_file, dist, result_directory):
|
||||
# TODO: Do not rely on a specific pbuilder configuration.
|
||||
cmd = ["sudo", "-E", "DIST=" + dist, "pbuilder", "--build",
|
||||
"--distribution", dist, "--architecture", self.architecture,
|
||||
"--buildresult", result_directory, dsc_file]
|
||||
Logger.command(cmd)
|
||||
return subprocess.call(cmd)
|
||||
|
||||
|
||||
class Sbuild(Builder):
|
||||
def __init__(self):
|
||||
Builder.__init__(self, "sbuild")
|
||||
|
||||
def build(self, dsc_file, dist, result_directory):
|
||||
workdir = os.getcwd()
|
||||
Logger.command(["cd", result_directory])
|
||||
os.chdir(result_directory)
|
||||
cmd = ["sbuild", "--arch-all", "--dist=" + dist,
|
||||
"--arch=" + self.architecture, dsc_file]
|
||||
Logger.command(cmd)
|
||||
result = subprocess.call(cmd)
|
||||
Logger.command(["cd", workdir])
|
||||
os.chdir(workdir)
|
||||
return result
|
||||
|
||||
|
||||
class Patch(object):
|
||||
def __init__(self, patch_file):
|
||||
self.patch_file = patch_file
|
||||
@ -732,7 +689,7 @@ if __name__ == "__main__":
|
||||
if "SPONSOR_PATCH_BUILDER" in os.environ:
|
||||
default_builder = os.environ["SPONSOR_PATCH_BUILDER"]
|
||||
else:
|
||||
default_builder = "pbuilder"
|
||||
default_builder = None
|
||||
|
||||
parser.add_option("-b", "--build", dest="build",
|
||||
help="Build the package with the specified builder.",
|
||||
@ -772,13 +729,8 @@ if __name__ == "__main__":
|
||||
Logger.error("Invalid bug number specified: %s" % (bug_number))
|
||||
sys.exit(1)
|
||||
|
||||
if options.builder == "pbuilder":
|
||||
builder = Pbuilder()
|
||||
elif options.builder == "sbuild":
|
||||
builder = Sbuild()
|
||||
else:
|
||||
Logger.error("Unsupported builder specified: %s. Only pbuilder and "
|
||||
"sbuild are supported." % (options.builder))
|
||||
builder = getBuilder(options.builder)
|
||||
if not builder:
|
||||
sys.exit(1)
|
||||
|
||||
if options.sponsoring:
|
||||
|
81
ubuntutools/builder.py
Normal file
81
ubuntutools/builder.py
Normal file
@ -0,0 +1,81 @@
|
||||
#
|
||||
# builder.py - Helper classes for building packages
|
||||
#
|
||||
# Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||
# Copyright (C) 2010, Evan Broder <evan@ebroder.net>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software
|
||||
# for any purpose with or without fee is hereby granted, provided
|
||||
# that the above copyright notice and this permission notice appear
|
||||
# in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
||||
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from ubuntutools.logger import Logger
|
||||
|
||||
class Builder(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
cmd = ["dpkg-architecture", "-qDEB_BUILD_ARCH_CPU"]
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
self.architecture = process.communicate()[0].strip()
|
||||
|
||||
def get_architecture(self):
|
||||
return self.architecture
|
||||
|
||||
def get_name(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Pbuilder(Builder):
|
||||
def __init__(self):
|
||||
Builder.__init__(self, "pbuilder")
|
||||
|
||||
def build(self, dsc_file, dist, result_directory):
|
||||
# TODO: Do not rely on a specific pbuilder configuration.
|
||||
cmd = ["sudo", "-E", "DIST=" + dist, "pbuilder", "--build",
|
||||
"--distribution", dist, "--architecture", self.architecture,
|
||||
"--buildresult", result_directory, dsc_file]
|
||||
Logger.command(cmd)
|
||||
return subprocess.call(cmd)
|
||||
|
||||
|
||||
class Sbuild(Builder):
|
||||
def __init__(self):
|
||||
Builder.__init__(self, "sbuild")
|
||||
|
||||
def build(self, dsc_file, dist, result_directory):
|
||||
workdir = os.getcwd()
|
||||
Logger.command(["cd", result_directory])
|
||||
os.chdir(result_directory)
|
||||
cmd = ["sbuild", "--arch-all", "--dist=" + dist,
|
||||
"--arch=" + self.architecture, dsc_file]
|
||||
Logger.command(cmd)
|
||||
result = subprocess.call(cmd)
|
||||
Logger.command(["cd", workdir])
|
||||
os.chdir(workdir)
|
||||
return result
|
||||
|
||||
|
||||
def getBuilder(builder=None):
|
||||
if not builder:
|
||||
builder = os.environ.get('UBUNTUTOOLS_BUILDER', 'pbuilder')
|
||||
|
||||
if builder == 'pbuilder':
|
||||
return Pbuilder()
|
||||
elif builder == 'sbuild':
|
||||
return Sbuild()
|
||||
|
||||
Logger.error("Unsupported builder specified: %s. Only pbuilder and "
|
||||
"sbuild are supported." % (options.builder))
|
Loading…
x
Reference in New Issue
Block a user