Skip to content

Commit

Permalink
Improve steps.packaged.deb
Browse files Browse the repository at this point in the history
Add Cowbuilder support and more options for Pbuilder and Lintian.
  • Loading branch information
jiuka committed Jul 27, 2012
1 parent 9a0aafb commit cd57505
Show file tree
Hide file tree
Showing 5 changed files with 358 additions and 48 deletions.
4 changes: 2 additions & 2 deletions master/buildbot/steps/package/deb/__init__.py
Expand Up @@ -18,6 +18,6 @@
"""

from lintian import DebLintian
from pbuilder import DebPbuilder
from pbuilder import DebPbuilder, DebCowbuilder

__all__ = ['DebLintian', 'DebPbuilder']
__all__ = ['DebLintian', 'DebPbuilder', 'DebCowbuilder']
11 changes: 10 additions & 1 deletion master/buildbot/steps/package/deb/lintian.py
Expand Up @@ -28,25 +28,34 @@ class DebLintian(Test):
warningPattern = '.*W: .*'

fileloc = None
suppressTags = []

def __init__(self, fileloc=None, **kwargs):
def __init__(self, fileloc=None, suppressTags=None, **kwargs):
"""
Create the DebLintian object.
@type fileloc: str
@param fileloc: Location of the .deb or .changes to test.
@type suppressTags: list
@param suppressTags: List of tags to suppress.
@type kwargs: dict
@param kwargs: all other keyword arguments.
"""
Test.__init__(self, **kwargs)
if fileloc:
self.fileloc = fileloc
if suppressTags:
self.suppressTags = suppressTags

if not self.fileloc:
config.error("You must specify a fileloc")

self.command = ["lintian", "-v", self.fileloc]

if self.suppressTags:
for tag in self.suppressTags:
self.command += ['--suppress-tags', tag]

def createSummary(self, log):
"""
Create nice summary logs.
Expand Down
60 changes: 50 additions & 10 deletions master/buildbot/steps/package/deb/pbuilder.py
Expand Up @@ -43,15 +43,21 @@ class DebPbuilder(WarningCountingShellCommand):
basetgz = "/var/cache/pbuilder/%(distribution)s-%(architecture)s-buildbot.tgz"
mirror = "http://cdn.debian.net/debian/"
extrapackages = []
keyring = None
components = None

maxAge = 60*60*24*7
pbuilder = '/usr/sbin/pbuilder'
baseOption = '--basetgz'

def __init__(self,
architecture=None,
distribution=None,
basetgz=None,
mirror=None,
extrapackages=None,
extrapackages=None,
keyring=None,
components=None,
**kwargs):
"""
Creates the DebPbuilder object.
Expand All @@ -66,35 +72,43 @@ def __init__(self,
@param mirror: the mirror for building basetgz
@type extrapackages: list
@param extrapackages: adds packages specified to buildroot
@type keyring: str
@param keyring: keyring file to use for verification
@type components: str
@param components: components to use for chroot creation
@type kwargs: dict
@param kwargs: All further keyword arguments.
"""
WarningCountingShellCommand.__init__(self, **kwargs)

if architecture:
self.architecture = architecture
if distribution:
self.distribution = distribution
if mirror:
self.mirror = mirror
if extrapackages:
self.extrapackages = extrapackages
if keyring:
self.keyring = keyring
if components:
self.components = components

if self.architecture:
kwargs['architecture'] = self.architecture
else:
kwargs['architecture'] = 'ownarch'
kwargs['architecture'] = 'local'
kwargs['distribution'] = self.distribution

if basetgz:
self.basetgz = basetgz % kwargs
else:
self.basetgz = self.basetgz % kwargs

if extrapackages:
self.extrapackages = extrapackages

self.command = ['pdebuild', '--buildresult', '.']
self.command = ['pdebuild', '--buildresult', '.', '--pbuilder', self.pbuilder]
if self.architecture:
self.command += ['--architecture', self.architecture]
self.command += ['--', '--buildresult', '.', '--basetgz', self.basetgz]
self.command += ['--', '--buildresult', '.', self.baseOption, self.basetgz]
if self.extrapackages:
self.command += ['--extrapackages', " ".join(self.extrapackages)]

Expand All @@ -112,13 +126,17 @@ def checkBasetgz(self, cmd):
if cmd.rc != 0:
log.msg("basetgz not found, initializing it.")

command = ['sudo', '/usr/sbin/pbuilder', '--create', '--basetgz',
command = ['sudo', self.pbuilder, '--create', self.baseOption,
self.basetgz, '--distribution', self.distribution,
'--mirror', self.mirror]
if self.architecture:
command += ['--architecture', self.architecture]
if self.extrapackages:
command += ['--extrapackages', " ".join(self.extrapackages)]
if self.keyring:
command += ['--debootstrapopt', "--keyring=%s"%self.keyring]
if self.components:
command += ['--components', self.components]

cmd = buildstep.RemoteShellCommand(self.getWorkdir(), command)

Expand All @@ -134,8 +152,9 @@ def checkBasetgz(self, cmd):
age = time.time() - s[stat.ST_MTIME]
if age >= self.maxAge:
log.msg("basetgz outdated, updating")
command = ['sudo', '/usr/sbin/pbuilder', '--update', '--basetgz', self.basetgz]

command = ['sudo', self.pbuilder, '--update',
self.baseOption, self.basetgz]

cmd = buildstep.RemoteShellCommand(self.getWorkdir(), command)
stdio_log = stdio_log = self.addLog("pbuilder")
cmd.useLog(stdio_log, True, "stdio")
Expand All @@ -157,3 +176,24 @@ def commandComplete(self, cmd):
if m:
self.setProperty("deb-changes", m.group(1), "DebPbuilder")

class DebCowbuilder(DebPbuilder):
"""Build a debian package with cowbuilder inside of a chroot."""
name = "cowbuilder"

description = ["pdebuilding"]
descriptionDone = ["pdebuild"]

basetgz = "/var/cache/pbuilder/%(distribution)s-%(architecture)s-buildbot.cow/"

pbuilder = '/usr/sbin/cowbuilder'
baseOption = '--basepath'

class UbuPbuilder(DebPbuilder):
"""Build a Ubuntu package with pbuilder inside of a chroot."""
mirror = "http://archive.ubuntu.com/ubuntu/"

class UbuCowbuilder(DebCowbuilder):
"""Build a Ubuntu package with cowbuilder inside of a chroot."""
mirror = "http://archive.ubuntu.com/ubuntu/"

components = "main universe"
13 changes: 12 additions & 1 deletion master/buildbot/test/unit/test_steps_package_deb_lintian.py
Expand Up @@ -30,7 +30,7 @@ def tearDown(self):

def test_no_fileloc(self):
self.assertRaises(config.ConfigErrors, lambda :
lintian.DebLintian())
lintian.DebLintian())

def test_success(self):
self.setupStep(lintian.DebLintian('foo_0.23_i386.changes'))
Expand All @@ -41,4 +41,15 @@ def test_success(self):
self.expectOutcome(result=SUCCESS, status_text=['Lintian'])
return self.runStep()

def test_success_suppressTags(self):
self.setupStep(lintian.DebLintian('foo_0.23_i386.changes',
suppressTags=['bad-distribution-in-changes-file']))
self.expectCommands(
ExpectShell(workdir='wkdir', usePTY='slave-config',
command=['lintian', '-v', 'foo_0.23_i386.changes',
'--suppress-tags', 'bad-distribution-in-changes-file'])
+0)
self.expectOutcome(result=SUCCESS, status_text=['Lintian'])
return self.runStep()


0 comments on commit cd57505

Please sign in to comment.