Hi!

I back ported my checkConflict patch to CVS head. It is not that elegant but it should fix the problems. As it also uses linear search to check against the INSTALL_STATES performance is weak. CheckConflicts need 56 seconds for a full install but only ~4 for a 900 pkg install. As this check is done on every mytscheck round cases with lots of rounds suffer more than easier cases (yum install [a-k]* 78s).

I submit that patch for further review and - if no issues come up - for inclusion in the 3.2.1 release.

Florian Festi
Index: yum/depsolve.py
===================================================================
RCS file: /cvsroot/yum/cvs/yum/yum/depsolve.py,v
retrieving revision 1.168
diff -u -r1.168 depsolve.py
--- yum/depsolve.py	13 Jun 2007 17:52:02 -0000	1.168
+++ yum/depsolve.py	15 Jun 2007 14:31:37 -0000
@@ -768,6 +768,8 @@
             if len(thisneeds) == 0:
                 self._dcobj.already_seen[txmbr] = 1
             ret.extend(thisneeds)
+
+        ret.extend(self._checkConflicts())
             
         return ret
 
@@ -967,28 +969,60 @@
                 if not found:
                     member.setAsDep(txmbr.po)
 
-        for conflict in txmbr.po.returnPrco('conflicts'):
-            (r, f, v) = conflict
-            txmbrs = self.tsInfo.matchNaevr(name=r)
-            for tx in self.tsInfo.getMembersWithState(output_states = TS_INSTALL_STATES):
-                if tx.name != r and r not in tx.po.provides_names:
-                    continue
-                if tx.po.checkPrco('provides', (r, f, v)):
-                    ret.append( ((txmbr.name, txmbr.version, txmbr.release),
-                                 (r, version_tuple_to_string(v)), flags[f],
-                                 None, rpm.RPMDEP_SENSE_CONFLICTS) )
+        return ret
 
-            inst = self.rpmdb.whatProvides(r, None, None)
-            for pkgtup in inst:
-                txmbrs = self.tsInfo.getMembersWithState(pkgtup,
-                                                         TS_REMOVE_STATES)
-                if not txmbrs:
-                    po = self.getInstalledPackageObject(pkgtup)
-                    if po.checkPrco('provides', (r, f, v)):
-                        ret.append( ((txmbr.name, txmbr.version, txmbr.release),
-                                     (r, version_tuple_to_string(v)), flags[f],
-                                     None, rpm.RPMDEP_SENSE_CONFLICTS) )
-                    
+    flags = {"GT": rpm.RPMSENSE_GREATER,
+             "GE": rpm.RPMSENSE_EQUAL | rpm.RPMSENSE_GREATER,
+             "LT": rpm.RPMSENSE_LESS,
+             "LE": rpm.RPMSENSE_LESS | rpm.RPMSENSE_EQUAL,
+             "EQ": rpm.RPMSENSE_EQUAL,
+             None: 0 }
+
+    def _findNewConflict(self, po, r, f, v):
+        result = []
+        for tx in self.tsInfo.getMembersWithState(output_states = TS_INSTALL_STATES):
+            # no conflicts between same NEVR
+            if tx.po.pkgtup[0] == po.pkgtup[0] and tx.po.pkgtup[2:] == po.pkgtup[2:]:
+                continue            
+            if tx.name != r and r not in tx.po.provides_names:
+                continue
+            if tx.po.checkPrco('provides', (r, f, v)):
+                result.append( ((po.name, po.version, po.release),
+                                (r, version_tuple_to_string(v)), self.flags[f],
+                                None, rpm.RPMDEP_SENSE_CONFLICTS) )
+        return result
+
+    def _findOldConflict(self, po, r, f, v):
+        result = []
+        inst = self.rpmdb.whatProvides(r, None, None)
+        for pkgtup in inst:
+            # no conflicts between same NEVR
+            if pkgtup[0] == po.pkgtup[0] and pkgtup[2:] == po.pkgtup[2:]:
+                continue            
+            txmbrs = self.tsInfo.getMembersWithState(pkgtup,
+                TS_REMOVE_STATES)
+            if not txmbrs:
+                po = self.getInstalledPackageObject(pkgtup)
+                if po.checkPrco('provides', (r, f, v)):
+                    result.append( ((po.name, po.version, po.release), 
+                                    (r, version_tuple_to_string(v)), self.flags[f],
+                                    None, rpm.RPMDEP_SENSE_CONFLICTS) )
+        return result
+
+    def _checkConflicts(self):
+        ret = [ ]
+        for po in self.rpmdb.returnPackages():
+            if self.tsInfo.getMembersWithState(po.pkgtup, output_states=TS_REMOVE_STATES):
+                continue
+            for conflict in po.returnPrco('conflicts') + \
+                    po.returnPrco('obsoletes'):
+                ret.extend(self._findNewConflict(po, *conflict))
+                
+        for txmbr in self.tsInfo.getMembersWithState(output_states=TS_INSTALL_STATES):
+            po = txmbr.po
+            for conflict in txmbr.po.returnPrco('conflicts'):
+                ret.extend(self._findOldConflict(po, *conflict))
+                ret.extend(self._findNewConflict(po, *conflict))
         return ret
 
     def _checkRemove(self, txmbr):
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to