2008-04-17 04:52:37 +02:00
|
|
|
# vim:sw=4:et
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
# Module : rpmlint
|
|
|
|
# File : CheckPkgConfig
|
|
|
|
# Author : Stephan Kulow, Dirk Mueller
|
|
|
|
# Purpose : Check for errors in Pkgconfig files
|
|
|
|
#---------------------------------------------------------------
|
|
|
|
|
|
|
|
from Filter import *
|
|
|
|
import AbstractCheck
|
|
|
|
import rpm
|
|
|
|
import re
|
|
|
|
import commands
|
|
|
|
import Config
|
|
|
|
import os
|
2008-11-21 13:08:09 +01:00
|
|
|
import stat
|
2008-04-17 04:52:37 +02:00
|
|
|
|
|
|
|
class PkgConfigCheck(AbstractCheck.AbstractFilesCheck):
|
|
|
|
def __init__(self):
|
2009-08-21 18:19:06 +02:00
|
|
|
AbstractCheck.AbstractFilesCheck.__init__(self, "CheckPkgConfig", ".*/pkgconfig/.*\.pc$")
|
2008-04-17 04:52:37 +02:00
|
|
|
# currently causes too many failures (2008-03-05)
|
|
|
|
#self.suspicious_dir=re.compile('(?:/usr/src/\w+/BUILD|/var/tmp|/tmp|/home|\@\w{1,50}\@)')
|
|
|
|
self.suspicious_dir=re.compile('(?:/usr/src/\w+/BUILD|/var/tmp|/tmp|/home)')
|
|
|
|
|
2008-11-18 13:33:47 +01:00
|
|
|
def check(self, pkg):
|
|
|
|
# check for references to /lib when in lib64 mode
|
|
|
|
if pkg.arch in ('x86_64', 'ppc64', 's390x'):
|
|
|
|
self.wronglib_dir=re.compile('-L/usr/lib\\b')
|
|
|
|
else:
|
|
|
|
self.wronglib_dir=re.compile('-L/usr/lib64\\b')
|
|
|
|
|
|
|
|
AbstractCheck.AbstractFilesCheck.check(self, pkg)
|
|
|
|
|
|
|
|
|
2008-04-17 04:52:37 +02:00
|
|
|
def check_file(self, pkg, filename):
|
2009-08-28 22:12:54 +02:00
|
|
|
if pkg.isSource() or not stat.S_ISREG(pkg.files()[filename].mode):
|
2008-04-17 04:52:37 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
if pkg.grep(self.suspicious_dir, filename):
|
|
|
|
printError(pkg, "invalid-pkgconfig-file", filename)
|
|
|
|
|
2008-11-18 13:33:47 +01:00
|
|
|
pc_file=file(pkg.dirName() + "/" + filename, "r")
|
|
|
|
for l in pc_file:
|
|
|
|
if l.startswith('Libs:') and self.wronglib_dir.search(l):
|
|
|
|
printError(pkg, 'pkgconfig-invalid-libs-dir', filename, l)
|
|
|
|
|
2008-04-17 04:52:37 +02:00
|
|
|
check=PkgConfigCheck()
|
|
|
|
|
|
|
|
if Config.info:
|
|
|
|
addDetails(
|
|
|
|
'invalid-pkgconfig-file',
|
|
|
|
'''Your .pc file appears to be invalid. Possible causes are:
|
|
|
|
- it contains traces of $RPM_BUILD_ROOT or $RPM_BUILD_DIR.
|
|
|
|
- it contains unreplaced macros (@have_foo@)
|
|
|
|
- it references invalid paths (e.g. /home or /tmp)
|
|
|
|
|
|
|
|
Please double-check and report false positives.
|
2008-11-18 13:33:47 +01:00
|
|
|
''',
|
|
|
|
'pkgconfig-invalid-libs-dir',
|
|
|
|
''' Your .pc file contains -L/usr/lib or -L/lib and is built for a lib64 target,
|
|
|
|
or contains references to -L/usr/lib64 or -L/lib64 and is built for a lib target.
|
|
|
|
Please remove the wrong library paths from the pc file.'''
|
2008-04-17 04:52:37 +02:00
|
|
|
)
|