Check all matching installed packages, not only the first (for multiarch systems and/or multi-version packages).

git-svn-id: svn+ssh://rpmlint.zarb.org/home/projects/rpmlint/svn/trunk@1192 9bc8b190-ac0f-0410-8968-dc7d1f502856
This commit is contained in:
Ville Skyttä 2006-06-05 20:45:07 +00:00
parent 5a19cd621e
commit 807d9d346b
2 changed files with 29 additions and 5 deletions

21
Pkg.py
View File

@ -388,6 +388,27 @@ class Pkg:
rpm.RPMTAG_OBSOLETEVERSION,
rpm.RPMTAG_OBSOLETEFLAGS)
def getInstalledPkgs(name):
"""Get list of installed package objects by name."""
pkgs = []
if v42:
ts = rpm.TransactionSet()
tab = ts.dbMatch("name", name)
if not tab:
raise KeyError, name
for hdr in tab:
pkgs.append(InstalledPkg(name, hdr))
else:
db = rpm.opendb()
ixs = db.findbyname(name)
if not ixs:
del db
raise KeyError, name
for ix in ixs:
pkgs.append(InstalledPkg(name, db[ix]))
del db
return pkgs
# Class to provide an API to an installed package
class InstalledPkg(Pkg):
def __init__(self, name, h=None):

View File

@ -56,31 +56,34 @@ def main():
# Loop over all file names given in arguments
dirs=[]
for f in args:
pkgs = []
try:
try:
st=os.stat(f)
if stat.S_ISREG(st[stat.ST_MODE]):
pkg=Pkg.Pkg(f, extract_dir)
pkgs.append(Pkg.Pkg(f, extract_dir))
elif stat.S_ISDIR(st[stat.ST_MODE]) and (f.index('/') >=0):
dirs.append(f)
continue
else:
raise OSError
except OSError:
pkg=Pkg.InstalledPkg(f)
pkgs.extend(Pkg.getInstalledPkgs(f))
except KeyboardInterrupt:
sys.stderr.write('Interrupted, exiting while reading ' + f + '\n')
sys.exit(2)
except rpm.error, e:
sys.stderr.write('Error while reading %s: %s\n' % (f, e))
pkg=None
pkgs = []
continue
except:
sys.stderr.write('Error while reading ' + f + '\n')
pkg=None
pkgs = []
continue
runChecks(pkg)
for pkg in pkgs:
runChecks(pkg)
pkg.cleanup()
for d in dirs:
try: