diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-10-05 05:24:42 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-10-05 05:24:42 +0000 |
commit | 02bc22df9ab2f5b40547d3aa4362247deeb98d80 (patch) | |
tree | c11408da6f14de44113b2be1342f3555b250ca34 | |
parent | 58559fb4ae65e6a8f367a735e533edb03dc16d11 (diff) | |
download | portage-02bc22df9ab2f5b40547d3aa4362247deeb98d80.tar.gz portage-02bc22df9ab2f5b40547d3aa4362247deeb98d80.tar.bz2 portage-02bc22df9ab2f5b40547d3aa4362247deeb98d80.zip |
Add support for slot based dep matching in all dbapi derived classes. The supported syntax is ${CATEGORY}/${PN}:${SLOT} (identical to that used by paludis and pkgcore).
svn path=/main/trunk/; revision=4594
-rw-r--r-- | pym/portage.py | 28 | ||||
-rw-r--r-- | pym/portage_dep.py | 21 |
2 files changed, 45 insertions, 4 deletions
diff --git a/pym/portage.py b/pym/portage.py index 7aa0e558b..403caa7ef 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -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 diff --git a/pym/portage_dep.py b/pym/portage_dep.py index 1f20b8ac3..af4a72501 100644 --- a/pym/portage_dep.py +++ b/pym/portage_dep.py @@ -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 |