|
|
# since our blocks doesn't match any installed packages, | # since our blocks doesn't match any installed packages, |
# it doesn't apply to us and we can ignore it. | # it doesn't apply to us and we can ignore it. |
return 1 | return 1 |
|
if mytype=="multi": |
|
self.digraph.addnode(string.join(mybigkey),myparent) |
|
return 1 |
if not myparent: | if not myparent: |
# command-line specified or part of a world list... | # command-line specified or part of a world list... |
if ("self" not in myparams) or (("selective" in myparams) and vardbapi.cpv_exists(mykey)): | if ("self" not in myparams) or (("selective" in myparams) and vardbapi.cpv_exists(mykey)): |
|
|
if edepend.has_key("PDEPEND") and edepend["PDEPEND"]: | if edepend.has_key("PDEPEND") and edepend["PDEPEND"]: |
# Post Depend -- Add to the list without a parent, as it depends | # Post Depend -- Add to the list without a parent, as it depends |
# on a package being present AND must be built after that package. | # on a package being present AND must be built after that package. |
if not self.select_dep(myroot,edepend["PDEPEND"]): |
if not self.select_dep(myroot,edepend["PDEPEND"],pdepend=True): |
return 0 | return 0 |
| |
return 1 | return 1 |
|
|
vardbapi=portage.db[myroot]["vartree"].dbapi | vardbapi=portage.db[myroot]["vartree"].dbapi |
| |
myslot=portage.portdb.aux_get(pkgver,["SLOT"])[0] | myslot=portage.portdb.aux_get(pkgver,["SLOT"])[0] |
|
pkg=portage.dep_getkey(pkg) |
alleb=portage.portdb.xmatch("match-all",pkg) | alleb=portage.portdb.xmatch("match-all",pkg) |
while alleb: | while alleb: |
cand=portage.portdb.xmatch("bestmatch-list",pkg,mylist=alleb) | cand=portage.portdb.xmatch("bestmatch-list",pkg,mylist=alleb) |
|
|
break | break |
alleb.remove(cand) | alleb.remove(cand) |
| |
def select_dep(self,myroot,depstring,myparent=None,arg=None): |
def select_dep(self,myroot,depstring,myparent=None,arg=None,pdepend=None): |
"given a dependency string, create the appropriate depgraph and return 1 on success and 0 on failure" | "given a dependency string, create the appropriate depgraph and return 1 on success and 0 on failure" |
if "--debug" in myopts: | if "--debug" in myopts: |
print | print |
print "Parent: ",myparent | print "Parent: ",myparent |
print "Depstring:",depstring | print "Depstring:",depstring |
|
multiflg=False |
if not arg: | if not arg: |
#processing dependencies | #processing dependencies |
mycheck=portage.dep_check(depstring,self.mydbapi[myroot]) | mycheck=portage.dep_check(depstring,self.mydbapi[myroot]) |
|
|
mymerge=mycheck[1] | mymerge=mycheck[1] |
else: | else: |
#we're processing a command-line argument; unconditionally merge it even if it's already merged | #we're processing a command-line argument; unconditionally merge it even if it's already merged |
mymerge=[depstring] |
if depstring[0] in ['>','<','=']: |
|
mymerge=[depstring] |
|
else: |
|
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 "--update" not in myopts: |
|
if len(mymerge)>1 and not myparent: |
|
multiflg=True |
|
|
if "--debug" in myopts: | if "--debug" in myopts: |
print "Candidates:",mymerge | print "Candidates:",mymerge |
|
|
|
if not mymerge and not myparent and not pdepend: |
|
print "\nemerge: there are no masked or unmasked ebuilds to satisfy "+arg+"." |
|
return 0 |
|
|
for x in mymerge: | for x in mymerge: |
if x[0]=="!": | if x[0]=="!": |
#add our blocker; it will be ignored later if necessary (if we are remerging the same pkg, for example) | #add our blocker; it will be ignored later if necessary (if we are remerging the same pkg, for example) |
myk=["blocks",myroot,x[1:]] | myk=["blocks",myroot,x[1:]] |
|
elif multiflg: |
|
myk=["multi",myroot,x[1:]] |
else: | else: |
#We are not processing a blocker but a normal dependency | #We are not processing a blocker but a normal dependency |
myeb_pkg=None | myeb_pkg=None |
|
|
for x in sysdict.keys(): | for x in sysdict.keys(): |
mylist.append(sysdict[x]) | 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: | for mydep in mylist: |
myeb=portage.portdb.xmatch("bestmatch-visible",mydep) | myeb=portage.portdb.xmatch("bestmatch-visible",mydep) |
if not myeb: | if not myeb: |
|
|
| |
def display(self,mylist): | def display(self,mylist): |
changelogs=[] | changelogs=[] |
|
error=None |
for x in mylist: | for x in mylist: |
#print x | #print x |
fetch=" " | fetch=" " |
|
|
print red("(from pkg "+x[3]+")") | print red("(from pkg "+x[3]+")") |
else: | else: |
print | print |
|
elif x[0]=="multi": |
|
error="multi" |
|
addl=""+red("B")+" "+fetch+" " |
|
resolved=portage.db[x[1]]["vartree"].resolve_key(x[2]) |
|
myslot=portage.portdb.aux_get(x[2],["SLOT"])[0] |
|
print "["+x[0]+" "+addl+"]",red(resolved),"["+myslot+"]" |
else: | else: |
if x[3]=="nomerge": | if x[3]=="nomerge": |
continue | continue |
|
|
if (not "--emptytree" in myopts) and portage.db[x[1]]["vartree"].exists_specific(x[2]): | if (not "--emptytree" in myopts) and portage.db[x[1]]["vartree"].exists_specific(x[2]): |
addl=" "+yellow("R")+fetch+" " | addl=" "+yellow("R")+fetch+" " |
elif (not "--emptytree" in myopts) and portage.db[x[1]]["vartree"].exists_specific_cat(x[2]): | 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] | 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 | addl=" "+fetch |
if (myoldslot==mynewslot) and portage.pkgcmp(portage.pkgsplit(x[2]), portage.pkgsplit(myoldbest)) < 0: | if (myoldslot==mynewslot) and portage.pkgcmp(portage.pkgsplit(x[2]), portage.pkgsplit(myoldbest)) < 0: |
|
|
myoldbest=blue("["+myoldbest+"]") | myoldbest=blue("["+myoldbest+"]") |
| |
iuse="" | iuse="" |
|
slot='' |
if "--verbose" in myopts: | if "--verbose" in myopts: |
|
slot="S["+portage.portdb.aux_get(x[2],["SLOT"])[0]+"]" |
for ebuild_iuse in string.split(portage.portdb.aux_get(x[2],["IUSE"])[0], " "): | for ebuild_iuse in string.split(portage.portdb.aux_get(x[2],["IUSE"])[0], " "): |
try: | try: |
if (portage.usesplit.index(ebuild_iuse) >= 0) : | if (portage.usesplit.index(ebuild_iuse) >= 0) : |
|
|
if (oldlp-len(myprint)) > 0: | if (oldlp-len(myprint)) > 0: |
myprint=myprint+" "*(oldlp-len(myprint)) | myprint=myprint+" "*(oldlp-len(myprint)) |
myprint=myprint+myoldbest | myprint=myprint+myoldbest |
myprint=myprint+darkgreen(" to "+x[1])+" "+iuse |
myprint=myprint+darkgreen(" to "+x[1])+" "+slot+" "+iuse |
else: | else: |
myprint="["+x[0]+" "+addl+"] "+darkgreen(x[2])+" "+myoldbest+" "+darkgreen("to "+x[1])+" "+iuse |
myprint="["+x[0]+" "+addl+"] "+darkgreen(x[2])+" "+myoldbest+" "+darkgreen("to "+x[1])+" "+slot+" "+iuse |
else: | else: |
if "--columns" in myopts: | if "--columns" in myopts: |
myprint="["+x[0]+" "+addl+"] "+darkgreen(xs[0]) | myprint="["+x[0]+" "+addl+"] "+darkgreen(xs[0]) |
|
|
myprint=myprint+green(" ["+xs[1]+xs[2]+"] ") | myprint=myprint+green(" ["+xs[1]+xs[2]+"] ") |
if (oldlp-len(myprint)) > 0: | if (oldlp-len(myprint)) > 0: |
myprint=myprint+(" "*(oldlp-len(myprint))) | myprint=myprint+(" "*(oldlp-len(myprint))) |
myprint=myprint+myoldbest+" "+iuse |
myprint=myprint+myoldbest+" "+slot+" "+iuse |
else: | else: |
myprint="["+x[0]+" "+addl+"] "+darkgreen(x[2])+" "+myoldbest+" "+iuse |
myprint="["+x[0]+" "+addl+"] "+darkgreen(x[2])+" "+myoldbest+" "+slot+" "+iuse |
print myprint | print myprint |
| |
mysplit=portage.pkgsplit(x[2]) | mysplit=portage.pkgsplit(x[2]) |
|
|
print | print |
del mysplit | del mysplit |
| |
|
if error: |
|
if error=="multi": |
|
print |
|
print "You need to select one version" |
|
print "Example, \"emerge ="+x[2]+"\"" |
|
print "You can install both of them, if you emerge twice." |
|
|
|
|
if "--changelog" in myopts: | if "--changelog" in myopts: |
print | print |
for revision,text in changelogs: | for revision,text in changelogs: |
|
|
if ("--pretend" not in myopts): | if ("--pretend" not in myopts): |
sys.exit(1) | sys.exit(1) |
| |
|
if x[0]=="multi": |
|
print "\n!!! Error: the "+x[2]+" package conflicts with another package." |
|
print "!!! It is necessary to specify a version." |
|
print "!!! Example, \"emerge ="+x[2]+"\"" |
|
print "!!! Please use 'emerge --pretend' to determine packages." |
|
print |
|
if ("--pretend" not in myopts): |
|
sys.exit(1) |
|
|
if ("--resume" in myopts): | if ("--resume" in myopts): |
# We're resuming. | # We're resuming. |
print green("*** Resuming merge...") | print green("*** Resuming merge...") |
|
|
p2=catpkgsplit(bestmatch)[1:] | p2=catpkgsplit(bestmatch)[1:] |
return bestmatch | 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: | class portagetree: |
def __init__(self,root="/",virtual=None,clone=None): | def __init__(self,root="/",virtual=None,clone=None): |
global portdb | global portdb |
|
|
except: | except: |
pass | pass |
return "" | 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): | def hasnode(self,mykey): |
"""Does the particular node (cat/pkg key) exist?""" | """Does the particular node (cat/pkg key) exist?""" |
|
|
elif level=="match-all": | elif level=="match-all": |
#match *all* visible *and* masked packages | #match *all* visible *and* masked packages |
myval=self.match2(mydep,mykey,self.cp_list(mykey)) | 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: | else: |
print "ERROR: xmatch doesn't handle",level,"query!" | print "ERROR: xmatch doesn't handle",level,"query!" |
raise KeyError | 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 | self.xcache[level][mydep]=myval |
return myval | return myval |
| |