self.outdatedpackages=[]
self.mydbapi={}
self.mydbapi["/"] = portage.fakedbapi(settings=settings)
- self.pkg_slots={"/" : {}}
- allcpv = self.trees["/"]["vartree"].getallcpv()
+ vardb = self.trees["/"]["vartree"].dbapi
+ fakedb = self.mydbapi["/"]
if "empty" not in self.myparams or self.target_root != "/":
- for pkg in allcpv:
- self.mydbapi["/"].cpv_inject(pkg)
- for pkg in allcpv:
- myslot = self.trees["/"]["vartree"].dbapi.aux_get(pkg, ["SLOT"])[0]
- mykey = portage.dep_getkey(pkg)
- if mykey in self.pkg_slots["/"]:
- self.pkg_slots["/"][mykey][myslot] = pkg
- else:
- self.pkg_slots["/"][mykey] = {myslot:pkg}
+ for pkg in vardb.cpv_all():
+ myslot = vardb.aux_get(pkg, ["SLOT"])[0]
+ fakedb.cpv_inject(pkg, myslot=myslot)
if self.target_root != "/":
- self.pkg_slots[self.target_root] = {}
- allcpv = self.trees[self.target_root]["vartree"].getallcpv()
self.mydbapi[self.target_root] = \
portage.fakedbapi(settings=settings)
+ vardb = self.trees[self.target_root]["vartree"].dbapi
+ fakedb = self.mydbapi[self.target_root]
if "empty" not in self.myparams:
- for pkg in allcpv:
- self.mydbapi[self.target_root].cpv_inject(pkg)
- for pkg in allcpv:
- myslot = self.trees[self.target_root]["vartree"].dbapi.aux_get(
- pkg, ["SLOT"])[0]
- mykey = portage.dep_getkey(pkg)
- if mykey in self.pkg_slots[self.target_root]:
- self.pkg_slots[self.target_root][mykey][myslot] = pkg
- else:
- self.pkg_slots[self.target_root][mykey] = {myslot:pkg}
+ for pkg in vardb.cpv_all():
+ myslot = vardb.aux_get(pkg, ["SLOT"])[0]
+ fakedb.cpv_inject(pkg, myslot=myslot)
if "--usepkg" in self.myopts:
trees["/"]["bintree"].populate(
"--getbinpkg" in self.myopts, "--getbinpkgonly" in self.myopts)
return 1
else:
mydbapi = self.trees[myroot][self.pkg_tree_map[mytype]].dbapi
- if addme:
- myslot = mydbapi.aux_get(mykey, ["SLOT"])[0]
- depkey = portage.dep_getkey(mykey)
- if depkey in self.pkg_slots:
- self.pkg_slots[myroot][depkey][myslot] = mykey
- else:
- self.pkg_slots[myroot][depkey] = {myslot : mykey}
if myuse is None:
self.pkgsettings[myroot].setcpv(mykey)
if p_status == "merge":
""" This fakedbapi data is used in dep_check calls to determine
satisfied deps via dep_wordreduce"""
- self.mydbapi[p_root].cpv_inject(p_key)
+ myslot = self.trees[p_root][
+ self.pkg_tree_map[p_type]].dbapi.aux_get(
+ p_key, ["SLOT"])[0]
+ self.mydbapi[p_root].cpv_inject(p_key, myslot=myslot)
# Update old-style virtuals if this package provides any.
# These are needed for dep_virtual calls inside dep_check.
"""Prior to being added to the digraph, any blockers against
old-style virtuals have been expanded to real packages via
dep_virtual calls inside dep_check."""
- mykey = portage.dep_getkey(mydep)
- valid = False
- pkgs = self.pkg_slots[myroot].get(mykey, None)
- if pkgs and portage.match_from_list(mydep,
- [pkgs[myslot] for myslot in pkgs]):
- valid = True
- if not valid:
+ if not self.mydbapi[myroot].match(mydep):
self.digraph.remove(blocker)
def altlist(self, reversed=False):
return 1
def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None,
- return_all_deps=False):
+ fakedb=None, return_all_deps=False):
"""Takes an unreduced and reduced deplist and removes satisfied dependencies.
Returned deplist contains steps that must be taken to satisfy dependencies."""
if trees is None:
if isinstance(dep, list):
unresolved += dep_zapdeps(dep, satisfied, myroot,
use_binaries=use_binaries, trees=trees,
- return_all_deps=return_all_deps)
+ fakedb=fakedb, return_all_deps=return_all_deps)
elif not satisfied or return_all_deps:
unresolved.append(dep)
return unresolved
other = []
# Alias the trees we'll be checking availability against
- vardb = trees[myroot]["vartree"].dbapi
+ if fakedb:
+ vardb = fakedb
+ else:
+ vardb = trees[myroot]["vartree"].dbapi
if use_binaries:
mydbapi = trees[myroot]["bintree"].dbapi
else:
for (dep, satisfied) in zip(deps, satisfieds):
if isinstance(dep, list):
atoms = dep_zapdeps(dep, satisfied, myroot,
- use_binaries=use_binaries, trees=trees)
+ use_binaries=use_binaries, trees=trees,
+ fakedb=fakedb, return_all_deps=return_all_deps)
else:
atoms = [dep]
writemsg("mysplit: %s\n" % (mysplit), 1)
writemsg("mysplit2: %s\n" % (mysplit2), 1)
+ fakedb = None
+ if return_all_deps:
+ fakedb = mydbapi
myzaps = dep_zapdeps(mysplit, mysplit2, myroot,
- use_binaries=use_binaries, trees=trees, return_all_deps=return_all_deps)
+ use_binaries=use_binaries, trees=trees,
+ fakedb=fakedb, return_all_deps=return_all_deps)
mylist = flatten(myzaps)
writemsg("myzaps: %s\n" % (myzaps), 1)
writemsg("mylist: %s\n" % (mylist), 1)
def cpv_all(self):
return self.cpvdict.keys()
- def cpv_inject(self,mycpv):
+ def cpv_inject(self, mycpv, myslot=None):
"""Adds a cpv from the list of available packages."""
mycp=cpv_getkey(mycpv)
- self.cpvdict[mycpv]=1
- if not self.cpdict.has_key(mycp):
- self.cpdict[mycp]=[]
+ self.cpvdict[mycpv] = myslot
+ if myslot and mycp in self.cpdict:
+ # If necessary, remove another package in the same SLOT.
+ for cpv in self.cpdict[mycp]:
+ if mycpv != cpv and myslot == self.cpvdict[cpv]:
+ self.cpv_remove(cpv)
+ break
+ if mycp not in self.cpdict:
+ self.cpdict[mycp] = []
if not mycpv in self.cpdict[mycp]:
self.cpdict[mycp].append(mycpv)
if not len(self.cpdict[mycp]):
del self.cpdict[mycp]
+ def aux_get(self, mycpv, wants):
+ if not self.cpv_exists(mycpv):
+ raise KeyError(mycpv)
+ values = []
+ for x in wants:
+ if x == "SLOT":
+ values.append(self.cpvdict[mycpv])
+ else:
+ values.append("")
+ return values
+
class bindbapi(fakedbapi):
def __init__(self, mybintree=None, settings=None):
self.bintree = mybintree