Hi!
These methods will allow to simply _checkInstall and _checkRemove a lot.
I sketched how the _checkInstall and _checkRemove methods could look after
the changes. Although the might look a bit like Python please see them as a
pseudo code implementation.
Florian
def _checkInstall(self, txmbr):
# removed some flags translation here
# must move into the SqliteSack
# if this is an update, we should check what the old
# requires were to make things faster
# XXX this changes the behavior: already existing problems are ignored
# TODO: discuss if this is wanted
oldreqs = set()
for oldpo in txmbr.updates:
for req in oldpo.returnPrco('requires'):
oldreqs.add(req)
ret = []
for req in txmbr.po.returnPrco('requires'):
if req[0].startswith('rpmlib(') or req in oldreqs:
continue
self.verbose_logger.log(logginglevels.DEBUG_2, "looking for %s as a requirement of %s", req, txmbr)
deps = self.tsInfo.whatProvides(req)
if not deps:
reqtuple = (req[0], version_tuple_to_string(req[2]), req[1])
self.dcobj.addRequires(txmbr.po, [reqtuple])
ret.append( ((txmbr.name, txmbr.version, txmbr.release),
(req[0], version_tuple_to_string(req[2])), req[1], None,
rpm.RPMDEP_SENSE_REQUIRES) )
# removed some code to .setAsDep() here
# TODO: is it really needed? Can it be done in a nicer way?
for conflict in txmbr.po.returnPrco('conflicts'):
for tx in self.tsInfo.whatProvides(*conflict):
ret.append( ((txmbr.name, txmbr.version, txmbr.release),
(r, version_tuple_to_string(v)), f,
None, rpm.RPMDEP_SENSE_CONFLICTS) )
return ret
def _checkRemove(self, txmbr):
po = txmbr.po
provs = po.returnPrco('provides')
# get the files in the package and express them as "provides"
filesasprovs = [(f, None, (None,None,None)) for f in po.filelist]
provs.extend(filesasprovs)
# if this is an update, we should check what the new package
# provides to make things faster
# TODO: check if this still is the case
newpoprovs = set()
for newpo in txmbr.updated_by:
for p in newpo.provides:
newpoprovs.add(p)
for f in newpo.filelist:
newpoprovs.add( (f, None, (None, None, None)) )
ret = []
for prov in provs:
if prov[0].startswith('rpmlib('): # ignore rpmlib() provides
continue
if newpoprovs.has_key(prov):
continue
for require_po in self.tsInfo.whatRequires(prov):
# XXX ugly, better returning {po : [PRCOs]} from .whatPRCO()?
for require in require_po.matchingRequires(prov):
if not self.tsInfo.whatProvides(require):
ret.append(
((po.name, po.version, po.release),
(r, version_tuple_to_string(v)),
flags[f], None, rpm.RPMDEP_SENSE_REQUIRES) )
return ret
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel