diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-09-27 06:22:44 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-09-27 06:22:44 +0000 |
commit | cd3d635d03ebebcd5c30abf45c8c921cb86bcd34 (patch) | |
tree | ccb0eb877c061cc774876befcdbf59b5ca302a04 | |
parent | fd76b435d5ce953e91a0efa8f6706aa3bd505f62 (diff) | |
download | portage-cd3d635d03ebebcd5c30abf45c8c921cb86bcd34.tar.gz portage-cd3d635d03ebebcd5c30abf45c8c921cb86bcd34.tar.bz2 portage-cd3d635d03ebebcd5c30abf45c8c921cb86bcd34.zip |
Add SLOT support to fakedbapi then use it for depgraph blocker handling and dep_zapdeps preference selection.
svn path=/main/trunk/; revision=4539
-rwxr-xr-x | bin/emerge | 53 | ||||
-rw-r--r-- | pym/portage.py | 43 |
2 files changed, 49 insertions, 47 deletions
diff --git a/bin/emerge b/bin/emerge index cbc89940e..2f35603a9 100755 --- a/bin/emerge +++ b/bin/emerge @@ -654,34 +654,21 @@ class depgraph: 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) @@ -750,13 +737,6 @@ class depgraph: 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) @@ -1082,7 +1062,10 @@ class depgraph: 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. @@ -1253,13 +1236,7 @@ class depgraph: """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): diff --git a/pym/portage.py b/pym/portage.py index 0ea10737d..474be3b84 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -3367,7 +3367,7 @@ def dep_eval(deplist): 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: @@ -3384,7 +3384,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=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 @@ -3403,7 +3403,10 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None, 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: @@ -3414,7 +3417,8 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None, 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] @@ -3555,8 +3559,12 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None, 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) @@ -3998,12 +4006,18 @@ class fakedbapi(dbapi): 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) @@ -4029,6 +4043,17 @@ class fakedbapi(dbapi): 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 |