Add support for slot based dep matching in all dbapi derived classes. The supported...
authorZac Medico <zmedico@gentoo.org>
Thu, 5 Oct 2006 05:24:42 +0000 (05:24 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 5 Oct 2006 05:24:42 +0000 (05:24 -0000)
svn path=/main/trunk/; revision=4594

pym/portage.py
pym/portage_dep.py

index 7aa0e558b0748c5ccccba034aa84a7d5f126ecc0..403caa7efb7f96f18bac49b1556b4eb5cdda4207 100644 (file)
@@ -3517,6 +3517,10 @@ def dep_expand(mydep, mydb=None, use_cache=1, settings=None):
        elif mydep[:1] in "=<>~!":
                prefix=mydep[:1]
                mydep=mydep[1:]
+       colon = mydep.rfind(":")
+       if colon != -1:
+               postfix = mydep[colon:]
+               mydep = mydep[:colon]
        return prefix + cpv_expand(
                mydep, mydb=mydb, use_cache=use_cache, settings=settings) + postfix
 
@@ -3981,8 +3985,12 @@ class dbapi:
        def match(self,origdep,use_cache=1):
                mydep = dep_expand(origdep, mydb=self, settings=self.settings)
                mykey=dep_getkey(mydep)
-               mycat=mykey.split("/")[0]
-               return match_from_list(mydep,self.cp_list(mykey,use_cache=use_cache))
+               mylist = match_from_list(mydep,self.cp_list(mykey,use_cache=use_cache))
+               myslot = portage_dep.dep_getslot(mydep)
+               if myslot is not None:
+                       mylist = [cpv for cpv in mylist \
+                               if self.aux_get(cpv, ["SLOT"])[0] == myslot]
+               return mylist
 
        def match2(self,mydep,mykey,mylist):
                writemsg("DEPRECATED: dbapi.match2\n")
@@ -4379,7 +4387,13 @@ class vardbapi(dbapi):
                        if self.matchcache.has_key(mycat):
                                del self.mtdircache[mycat]
                                del self.matchcache[mycat]
-                       return match_from_list(mydep,self.cp_list(mykey,use_cache=use_cache))
+                       mymatch = match_from_list(mydep,
+                               self.cp_list(mykey, use_cache=use_cache))
+                       myslot = portage_dep.dep_getslot(mydep)
+                       if myslot is not None:
+                               mymatch = [cpv for cpv in mymatch \
+                                       if self.aux_get(cpv, ["SLOT"])[0] == myslot]
+                       return mymatch
                try:
                        curmtime=os.stat(self.root+VDB_PATH+"/"+mycat)[stat.ST_MTIME]
                except SystemExit, e:
@@ -4393,6 +4407,10 @@ class vardbapi(dbapi):
                        self.matchcache[mycat]={}
                if not self.matchcache[mycat].has_key(mydep):
                        mymatch=match_from_list(mydep,self.cp_list(mykey,use_cache=use_cache))
+                       myslot = portage_dep.dep_getslot(mydep)
+                       if myslot is not None:
+                               mymatch = [cpv for cpv in mymatch \
+                                       if self.aux_get(cpv, ["SLOT"])[0] == myslot]
                        self.matchcache[mycat][mydep]=mymatch
                return self.matchcache[mycat][mydep][:]
 
@@ -5200,6 +5218,10 @@ class portdbapi(dbapi):
                else:
                        print "ERROR: xmatch doesn't handle",level,"query!"
                        raise KeyError
+               myslot = portage_dep.dep_getslot(mydep)
+               if myslot is not None:
+                       myval = [cpv for cpv in myval \
+                               if self.aux_get(cpv, ["SLOT"])[0] == myslot]
                if self.frozen and (level not in ["match-list","bestmatch-list"]):
                        self.xcache[level][mydep]=myval
                return myval
index 1f20b8ac33d43508a89b1cead46bf6ede123539f..af4a72501e4bed9ba520f639f8762e46aa43a4fb 100644 (file)
@@ -195,8 +195,17 @@ def dep_getcpv(mydep):
                mydep = mydep[2:]
        elif mydep[:1] in "=<>~":
                mydep = mydep[1:]
+       colon = mydep.rfind(":")
+       if colon != -1:
+               return mydep[:colon]
        return mydep
 
+def dep_getslot(mydep):
+       colon = mydep.rfind(":")
+       if colon != -1:
+               return mydep[colon+1:]
+       return None
+
 def isvalidatom(atom):
        mycpv_cps = catpkgsplit(dep_getcpv(atom))
        operator = get_operator(atom)
@@ -283,11 +292,13 @@ def match_from_list(mydep, candidate_list):
 
        mycpv     = dep_getcpv(mydep)
        mycpv_cps = catpkgsplit(mycpv) # Can be None if not specific
+       slot      = None
 
        if not mycpv_cps:
                cat, pkg = catsplit(mycpv)
                ver      = None
                rev      = None
+               slot = dep_getslot(mydep)
        else:
                cat, pkg, ver, rev = mycpv_cps
                if mydep == mycpv:
@@ -308,7 +319,15 @@ def match_from_list(mydep, candidate_list):
                for x in candidate_list:
                        xs = pkgsplit(x)
                        if xs is None:
-                               if x != mycpv:
+                               xcpv = dep_getcpv(x)
+                               if slot is not None:
+                                       xslot = dep_getslot(x)
+                                       if xslot is not None and xslot != slot:
+                                               """  This function isn't given enough information to
+                                               reject atoms based on slot unless *both* compared atoms
+                                               specify slots."""
+                                               continue
+                               if xcpv != mycpv:
                                        continue
                        elif xs[0] != mycpv:
                                continue