2008-04-17 04:52:37 +02:00
|
|
|
# vim:sw=4:et
|
|
|
|
#############################################################################
|
|
|
|
# File : CheckBuildRoot.py
|
|
|
|
# Package : rpmlint
|
|
|
|
# Author : Dirk Mueller, Stephan Kulow
|
|
|
|
# Purpose : Check for files containing $RPM_BUILD_ROOT
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
from Filter import *
|
|
|
|
import AbstractCheck
|
|
|
|
import rpm
|
|
|
|
import re
|
|
|
|
import os
|
|
|
|
import commands
|
|
|
|
import Config
|
|
|
|
import stat
|
|
|
|
|
|
|
|
class BuildRootCheck(AbstractCheck.AbstractFilesCheck):
|
|
|
|
def __init__(self):
|
2009-08-21 18:19:06 +02:00
|
|
|
AbstractCheck.AbstractFilesCheck.__init__(self, "CheckBuildRoot", ".*")
|
2010-04-01 16:20:38 +02:00
|
|
|
t = rpm.expandMacro('%buildroot')
|
|
|
|
for m in ('name', 'version', 'release'):
|
|
|
|
t = t.replace("%%{%s}" % (m), "[\w\!-\.]{1,20}")
|
|
|
|
self.build_root_re = re.compile(t)
|
2008-04-17 04:52:37 +02:00
|
|
|
|
|
|
|
def check_file(self, pkg, filename):
|
|
|
|
if filename.startswith('/usr/lib/debug') or pkg.isSource():
|
|
|
|
return
|
2009-08-21 18:19:06 +02:00
|
|
|
if not stat.S_ISREG(pkg.files()[filename].mode):
|
2008-04-17 04:52:37 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
if len(pkg.grep(self.build_root_re, filename)):
|
|
|
|
printError(pkg, "file-contains-buildroot", filename)
|
|
|
|
|
|
|
|
check=BuildRootCheck()
|
|
|
|
|
|
|
|
if Config.info:
|
|
|
|
addDetails(
|
|
|
|
'file-contains-buildroot',
|
|
|
|
"Your file contains traces of $RPM_BUILD_ROOT."
|
|
|
|
)
|