--- emerge.org 2003-08-03 03:25:13.000000000 +0100 +++ emerge 2003-08-03 23:22:42.000000000 +0100 @@ -753,6 +753,7 @@ vardbapi=portage.db[myroot]["vartree"].dbapi myslot=portage.portdb.aux_get(pkgver,["SLOT"])[0] + pkg=portage.dep_getkey(pkg) alleb=portage.portdb.xmatch("match-all",pkg) while alleb: cand=portage.portdb.xmatch("bestmatch-list",pkg,mylist=alleb) @@ -780,7 +781,14 @@ mymerge=mycheck[1] else: #we're processing a command-line argument; unconditionally merge it even if it's already merged - mymerge=[depstring] + mymerge=portage.portdb.xmatch("slotmatch-visible",depstring) + if "--update" in myopts: + newmerge=[] + for x in mymerge: + myslot=portage.db["/"]["porttree"].dbapi.aux_get(x[1:],["SLOT"])[0] + if portage.db["/"]["vartree"].hasslot(x[1:], myslot): + newmerge.append(x) + mymerge=newmerge if "--debug" in myopts: print "Candidates:",mymerge for x in mymerge: @@ -929,6 +937,14 @@ for x in sysdict.keys(): mylist.append(sysdict[x]) + newlist=[] + for x in mylist: + for y in portage.portdb.xmatch("slotmatch-visible",x): + myslot=portage.db["/"]["porttree"].dbapi.aux_get(y[1:],["SLOT"])[0] + if portage.db["/"]["vartree"].hasslot(y[1:], myslot): + newlist.append(y) + mylist=newlist + for mydep in mylist: myeb=portage.portdb.xmatch("bestmatch-visible",mydep) if not myeb: @@ -1026,13 +1042,16 @@ if (not "--emptytree" in myopts) and portage.db[x[1]]["vartree"].exists_specific(x[2]): addl=" "+yellow("R")+fetch+" " elif (not "--emptytree" in myopts) and portage.db[x[1]]["vartree"].exists_specific_cat(x[2]): - myoldbest=portage.best(portage.db[x[1]]["vartree"].dbapi.match(portage.pkgsplit(x[2])[0])) - - try: - myoldslot=portage.db[portage.root]["vartree"].getslot(myoldbest) - except: - myoldslot=None mynewslot=portage.portdb.aux_get(x[2],["SLOT"])[0] + mypkg=portage.catpkgsplit(x[2]) + myoldbest=portage.slotmatch(portage.db[x[1]]["vartree"].dbapi.match(portage.pkgsplit(x[2])[0]),mynewslot) + if myoldbest: + try: + myoldslot=portage.db[portage.root]["vartree"].getslot(myoldbest) + except: + myoldslot=None + else: + myoldslot=None addl=" "+fetch if (myoldslot==mynewslot) and portage.pkgcmp(portage.pkgsplit(x[2]), portage.pkgsplit(myoldbest)) < 0: --- portage.py.org 2003-08-02 22:43:47.000000000 +0100 +++ portage.py 2003-08-03 23:24:10.000000000 +0100 @@ -2679,6 +2679,41 @@ p2=catpkgsplit(bestmatch)[1:] return bestmatch +def slotmatch(mymatches,slot=None): + "accepts None arguments; assumes matches are valid." + + if mymatches==None: + return "" + if not len(mymatches): + return "" + + tmpmatch={} + for x in mymatches: + if slot: + myslot=db["/"]["vartree"].getslot(x) + else: + myslot=db["/"]["porttree"].dbapi.aux_get(x,["SLOT"])[0] + if not tmpmatch.has_key(myslot): + tmpmatch[myslot]=x + else: + p1=catpkgsplit(x)[1:] + p2=catpkgsplit(tmpmatch[myslot])[1:] + if pkgcmp(p1,p2)>0: + tmpmatch[myslot]=x + + if slot: + if tmpmatch.has_key(slot): + return tmpmatch[slot] + else: + return "" + + slotmatch=[] + for x in tmpmatch: + slotmatch.append("="+tmpmatch[x]) + + slotmatch.sort() + return slotmatch + class portagetree: def __init__(self,root="/",virtual=None,clone=None): global portdb @@ -3248,6 +3283,20 @@ except: pass return "" + + def hasslot(self,mycatpkg,myslot): + "Has a slot for a catpkg; assume it exists." + mysplit=catpkgsplit(mycatpkg) + mydirlist=listdir(self.root+"var/db/pkg/"+mysplit[0]) + for x in mydirlist: + if x[:len(mysplit[1])+1]==mysplit[1]+"-": + slotfile=open(self.root+"var/db/pkg/"+mysplit[0]+"/"+x+"/SLOT","r") + slotvar=string.split(slotfile.readline())[0] + slotfile.close() + if (slotvar==myslot): + return 1 + + return 0 def hasnode(self,mykey): """Does the particular node (cat/pkg key) exist?""" @@ -3713,10 +3762,13 @@ elif level=="match-all": #match *all* visible *and* masked packages myval=self.match2(mydep,mykey,self.cp_list(mykey)) + elif level=="slotmatch-visible": + #match *all* visible each SLOT + myval=slotmatch(self.xmatch("match-visible",None,mydep,mykey)) else: print "ERROR: xmatch doesn't handle",level,"query!" raise KeyError - if self.frozen and (level not in ["match-list","bestmatch-list"]): + if self.frozen and (level not in ["match-list","bestmatch-list","slotmatch-visible"]): self.xcache[level][mydep]=myval return myval