extras-repoclosure BrokenDeps.py,NONE,1.1
Michael Schwendt
mschwendt at fedoraproject.org
Mon Sep 13 11:53:57 UTC 2010
Author: mschwendt
Update of /cvs/fedora/extras-repoclosure
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv18707
Added Files:
BrokenDeps.py
Log Message:
add file with stuff separated from rc-report.py
--- NEW FILE BrokenDeps.py ---
#!/usr/bin/python
# -*- mode: Python; indent-tabs-mode: nil; -*-
# License: GPLv2+
import re
import rpmUtils.miscutils
class Package:
def __init__(self):
self.pkgid = None # 'E:name-VR.arch' (previously: 'name-EVR.arch')
self.repoid = None # e.g. 'fedora-core-6-i386'
self.name = None # just the binary rpm %{name}
self.srpm_name = None # just the src.rpm %{name}
self.relatedpkgs = []
self.report = []
self.owner = ''
self.coowners = []
self.relatedowners = []
def GetRequires(b):
r = []
for line in b.report:
r.append(' '+b.pkgid+' requires '+line)
return '\n'.join(r)
def Parser(lines):
"""Parse extras-repoclosure output lines and return brokendeps array."""
brokendeps = []
pkgre = re.compile('(?P<name>.*)-[^-]+-[^-]+$')
inbody = 0
srcrpm = ''
for line in lines:
if line.startswith('source rpm: '):
w = line.rstrip().split(' ')
srcrpm = w[2]
res = pkgre.search( srcrpm ) # try to get src.rpm "name"
if not res: # only true for invalid input
inbody = 0
else:
srpm_name = res.group('name')
continue
elif line.startswith('package: '):
inbody = 1
b = Package()
w = line.rstrip().split(' ')
if len(w)==6:
b.repoid = w[5]
b.pkgid = w[1]+' - '+w[3] # name - EVR.arch
b.pkgid = b.pkgid.replace(' ','')
else:
b.repoid = w[3]
b.pkgid = w[1] # E:name-VR.arch
b.srpm_name = srpm_name
# Extract pkg name from pkgid.
b.name = rpmUtils.miscutils.splitFilename(b.pkgid)[0]
brokendeps.append(b)
if inbody == 1:
if line.startswith('related pkgs:'):
inbody = 2
continue
else:
# Copy report per broken package.
r = line.rstrip().lstrip()
if len(r)>0 and not r.startswith('package:') \
and not r.startswith('unresolved deps:'):
b.report.append(r)
elif inbody == 2:
n = line.lstrip().rstrip()
if len(n) and n!=srpm_name:
b.relatedpkgs.append(n)
return brokendeps
def SortBySourceName(a,b):
return cmp(a.srpm_name.lower(),b.srpm_name.lower())
def SortByOwnerAndName(a,b):
r = cmp(a.owner,b.owner)
if r==0: # equal?
return cmp(a.pkgid,b.pkgid)
else:
return r
def SortByRepoAndName(a,b):
r = cmp(a.repoid,b.repoid)
if r==0: # equal?
return cmp(a.pkgid,b.pkgid)
else:
return r
def DropUnwantedRepos(bd,keywords):
# Filter out unwanted repoids.
for b in list(bd):
for needle in keywords:
if b.repoid.find( needle ) >= 0: # wanted?
break
else:
bd.remove(b)
def DropWhiteListed(bd,whitelistfunc):
# Filter out entries from whitelist.
for b in list(bd):
if whitelistfunc(b):
bd.remove(b)
def DropBySourceName(bd,srpm_name):
for b in list(bd):
if b.srpm_name == srpm_name:
bd.remove(b)
def FindBySourceName(b,brokendeps):
for b2 in list(brokendeps):
if b.srpm_name == b2.srpm_name:
return b2
return None
def FindByPkgId(b,brokendeps):
for b2 in list(brokendeps):
if b.pkgid == b2.pkgid:
return b2
return None
More information about the scm-commits
mailing list