1# This file is part of Buildbot. Buildbot is free software: you can 2# redistribute it and/or modify it under the terms of the GNU General Public 3# License as published by the Free Software Foundation, version 2. 4# 5# This program is distributed in the hope that it will be useful, but WITHOUT 6# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 7# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 8# details. 9# 10# You should have received a copy of the GNU General Public License along with 11# this program; if not, write to the Free Software Foundation, Inc., 51 12# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 13# 14# Portions Copyright Buildbot Team Members 15# Portions Copyright Steve 'Ashcrow' Milner <smilner+buildbot@redhat.com> 16""" 17Steps and objects related to rpmlint. 18""" 19 20from twisted.internet import defer 21 22from buildbot.steps.package import util as pkgutil 23from buildbot.steps.shell import Test 24 25 26class RpmLint(Test): 27 28 """ 29 Rpmlint build step. 30 """ 31 32 name = "rpmlint" 33 34 description = ["Checking for RPM/SPEC issues"] 35 descriptionDone = ["Finished checking RPM/SPEC issues"] 36 37 fileloc = '.' 38 config = None 39 40 def __init__(self, 41 fileloc=None, 42 config=None, 43 **kwargs): 44 """ 45 Create the Rpmlint object. 46 47 @type fileloc: str 48 @param fileloc: Location glob of the specs or rpms. 49 @type config: str 50 @param config: path to the rpmlint user config. 51 @type kwargs: dict 52 @param fileloc: all other keyword arguments. 53 """ 54 super().__init__(**kwargs) 55 if fileloc: 56 self.fileloc = fileloc 57 if config: 58 self.config = config 59 60 self.command = ["rpmlint", "-i"] 61 if self.config: 62 self.command += ['-f', self.config] 63 self.command.append(self.fileloc) 64 65 self.obs = pkgutil.WEObserver() 66 self.addLogObserver('stdio', self.obs) 67 68 @defer.inlineCallbacks 69 def createSummary(self): 70 """ 71 Create nice summary logs. 72 73 @param log: log to create summary off of. 74 """ 75 warnings = self.obs.warnings 76 errors = [] 77 if warnings: 78 yield self.addCompleteLog('%d Warnings' % len(warnings), "\n".join(warnings)) 79 if errors: 80 yield self.addCompleteLog('%d Errors' % len(errors), "\n".join(errors)) 81