Package buildbot :: Package steps :: Package package :: Package rpm :: Module rpmbuild
[frames] | no frames]

Source Code for Module buildbot.steps.package.rpm.rpmbuild

  1  # Dan Radez <dradez+buildbot@redhat.com> 
  2  # Steve 'Ashcrow' Milner <smilner+buildbot@redhat.com> 
  3  # 
  4  # This software may be freely redistributed under the terms of the GNU 
  5  # general public license. 
  6  # 
  7  # You should have received a copy of the GNU General Public License 
  8  # along with this program; if not, write to the Free Software 
  9  # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
 10  """ 
 11  RPM Building steps. 
 12  """ 
 13   
 14  from buildbot.steps.shell import ShellCommand 
 15  from buildbot.process.buildstep import RemoteShellCommand 
 16   
 17   
18 -class RpmBuild(ShellCommand):
19 """ 20 Build and RPM based on pased spec filename 21 """ 22 23 name = "rpmbuilder" 24 haltOnFailure = 1 25 flunkOnFailure = 1 26 description = ["RPMBUILD"] 27 descriptionDone = ["RPMBUILD"] 28
29 - def __init__(self, 30 specfile=None, 31 topdir='`pwd`', 32 builddir='`pwd`', 33 rpmdir='`pwd`', 34 sourcedir='`pwd`', 35 specdir='`pwd`', 36 srcrpmdir='`pwd`', 37 dist='.el5', 38 autoRelease=False, 39 vcsRevision=False, 40 **kwargs):
41 """ 42 Creates the RpmBuild object. 43 44 @type specfile: str 45 @param specfile: the name of the spec file for the rpmbuild 46 @type topdir: str 47 @param topdir: the top directory for rpm building. 48 @type builddir: str 49 @param builddir: the directory to use for building 50 @type rpmdir: str 51 @param rpmdir: the directory to dump the rpms into 52 @type sourcedir: str 53 @param sourcedir: the directory that houses source code 54 @type srcrpmdir: str 55 @param srcrpmdir: the directory to dump source rpms into 56 @type dist: str 57 @param dist: the distribution to build for 58 @type autoRelease: boolean 59 @param autoRelease: if the auto release mechanics should be used 60 @type vcsRevision: boolean 61 @param vcsRevision: if the vcs revision mechanics should be used 62 @type kwargs: dict 63 @param kwargs: All further keyword arguments. 64 """ 65 ShellCommand.__init__(self, **kwargs) 66 self.addFactoryArguments(topdir=topdir, 67 builddir=builddir, 68 rpmdir=rpmdir, 69 sourcedir=sourcedir, 70 specdir=specdir, 71 srcrpmdir=srcrpmdir, 72 specfile=specfile, 73 dist=dist, 74 autoRelease=autoRelease, 75 vcsRevision=vcsRevision) 76 self.rpmbuild = ( 77 'rpmbuild --define "_topdir %s" --define "_builddir %s"' 78 ' --define "_rpmdir %s" --define "_sourcedir %s"' 79 ' --define "_specdir %s" --define "_srcrpmdir %s"' 80 ' --define "dist %s"' % (topdir, builddir, rpmdir, sourcedir, 81 specdir, srcrpmdir, dist)) 82 self.specfile = specfile 83 self.autoRelease = autoRelease 84 self.vcsRevision = vcsRevision
85
86 - def start(self):
87 """ 88 Buildbot Calls Me when it's time to start 89 """ 90 if self.autoRelease: 91 relfile = '%s.release' % ( 92 self.os.path.basename(self.specfile).split('.')[0]) 93 try: 94 rfile = open(relfile, 'r') 95 rel = int(rfile.readline().strip()) 96 rfile.close() 97 except: 98 rel = 0 99 self.rpmbuild = self.rpmbuild + ' --define "_release %s"' % rel 100 rfile = open(relfile, 'w') 101 rfile.write(str(rel+1)) 102 rfile.close() 103 104 if self.vcsRevision: 105 self.rpmbuild = self.rpmbuild + ' --define "_revision %s"' % \ 106 self.getProperty('got_revision') 107 108 self.rpmbuild = self.rpmbuild + ' -ba %s' % self.specfile 109 110 self.command = ['bash', '-c', self.rpmbuild] 111 112 # create the actual RemoteShellCommand instance now 113 kwargs = self.remote_kwargs 114 kwargs['command'] = self.command 115 cmd = RemoteShellCommand(**kwargs) 116 self.setupEnvironment(cmd) 117 self.checkForOldSlaveAndLogfiles() 118 self.startCommand(cmd)
119
120 - def createSummary(self, log):
121 """ 122 Create nice summary logs. 123 124 @param log: The log to create summary off of. 125 """ 126 rpm_prefixes = ['Provides:', 'Requires(rpmlib):', 'Requires:', 127 'Checking for unpackaged', 'Wrote:', 128 'Executing(%', '+ '] 129 rpm_err_pfx = [' ', 'RPM build errors:', 'error: '] 130 131 rpmcmdlog = [] 132 rpmerrors = [] 133 134 for line in log.readlines(): 135 for pfx in rpm_prefixes: 136 if pfx in line: 137 rpmcmdlog.append(line) 138 for err in rpm_err_pfx: 139 if err in line: 140 rpmerrors.append(line) 141 self.addCompleteLog('RPM Command Log', "".join(rpmcmdlog)) 142 self.addCompleteLog('RPM Errors', "".join(rpmerrors))
143