1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 from __future__ import with_statement
17
18
19
20 import os
21 from buildbot.steps.shell import ShellCommand
22 from buildbot.process import buildstep
23 from buildbot import config
24
26 """
27 RpmBuild build step.
28 """
29
30 name = "rpmbuilder"
31 haltOnFailure = 1
32 flunkOnFailure = 1
33 description = ["RPMBUILD"]
34 descriptionDone = ["RPMBUILD"]
35
36 - def __init__(self,
37 specfile=None,
38 topdir='`pwd`',
39 builddir='`pwd`',
40 rpmdir='`pwd`',
41 sourcedir='`pwd`',
42 specdir='`pwd`',
43 srcrpmdir='`pwd`',
44 dist='.el5',
45 autoRelease=False,
46 vcsRevision=False,
47 **kwargs):
48 """
49 Create the RpmBuild object.
50
51 @type specfile: str
52 @param specfile: location of the specfile to build
53 @type topdir: str
54 @param topdir: define the _topdir rpm parameter
55 @type builddir: str
56 @param builddir: define the _builddir rpm parameter
57 @type rpmdir: str
58 @param rpmdir: define the _rpmdir rpm parameter
59 @type sourcedir: str
60 @param sourcedir: define the _sourcedir rpm parameter
61 @type specdir: str
62 @param specdir: define the _specdir rpm parameter
63 @type srcrpmdir: str
64 @param srcrpmdir: define the _srcrpmdir rpm parameter
65 @type dist: str
66 @param dist: define the dist string.
67 @type autoRelease: boolean
68 @param autoRelease: Use auto incrementing release numbers.
69 @type vcsRevision: boolean
70 @param vcsRevision: Use vcs version number as revision number.
71 """
72 ShellCommand.__init__(self, **kwargs)
73 self.rpmbuild = (
74 'rpmbuild --define "_topdir %s" --define "_builddir %s"'
75 ' --define "_rpmdir %s" --define "_sourcedir %s"'
76 ' --define "_specdir %s" --define "_srcrpmdir %s"'
77 ' --define "dist %s"' % (topdir, builddir, rpmdir, sourcedir,
78 specdir, srcrpmdir, dist))
79 self.specfile = specfile
80 self.autoRelease = autoRelease
81 self.vcsRevision = vcsRevision
82
83 if not self.specfile:
84 config.error("You must specify a specfile")
85
116
118 rpm_prefixes = ['Provides:', 'Requires(', 'Requires:',
119 'Checking for unpackaged', 'Wrote:',
120 'Executing(%', '+ ', 'Processing files:']
121 rpm_err_pfx = [' ', 'RPM build errors:', 'error: ']
122
123 rpmcmdlog = []
124 rpmerrors = []
125
126 for line in log.getText().splitlines(True):
127 for pfx in rpm_prefixes:
128 if line.startswith(pfx):
129 rpmcmdlog.append(line)
130 break
131 for err in rpm_err_pfx:
132 if line.startswith(err):
133 rpmerrors.append(line)
134 break
135 self.addCompleteLog('RPM Command Log', "".join(rpmcmdlog))
136 if rpmerrors:
137 self.addCompleteLog('RPM Errors', "".join(rpmerrors))
138