summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-10-25 02:52:54 +0000
committerZac Medico <zmedico@gentoo.org>2007-10-25 02:52:54 +0000
commit22993c9ce57e2557ad4792f4f078ba3078b273e1 (patch)
tree6c2f09522919e1b8a55a2e1565bb951e2ead3a34
parent8b99755ab61e64a1b5aea3ca5ce530715e91034d (diff)
downloadportage-22993c9ce57e2557ad4792f4f078ba3078b273e1.tar.gz
portage-22993c9ce57e2557ad4792f4f078ba3078b273e1.tar.bz2
portage-22993c9ce57e2557ad4792f4f078ba3078b273e1.zip
Spit out a depgraph._get_existing_pkg() method for getting an
existing Package instance added to the graph for a given SLOT. svn path=/main/trunk/; revision=8286
-rw-r--r--pym/_emerge/__init__.py45
1 files changed, 26 insertions, 19 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index bcd15cc21..49a97d077 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -2031,6 +2031,26 @@ class depgraph(object):
print xfrom
print
+ def _get_existing_pkg(self, root, slot_atom):
+ """
+ @rtype: Package
+ @returns: An existing Package instance added to the graph for the
+ given SLOT, or None if no matching package has been added yet.
+ """
+ existing_node = self._slot_node_map[root].get(slot_atom)
+ if not existing_node:
+ return None
+ e_type, root, e_cpv, e_status = existing_node
+ metadata = dict(izip(self._mydbapi_keys,
+ self.mydbapi[root].aux_get(e_cpv, self._mydbapi_keys)))
+ e_installed = e_type == "installed"
+ e_built = e_type != "ebuild"
+ e_onlydeps = not e_installed and \
+ e_status == "nomerge"
+ return Package(cpv=e_cpv, built=e_built,
+ installed=e_installed, type_name=e_type,
+ metadata=metadata, onlydeps=e_onlydeps, root=root)
+
def _select_package(self, root, atom, onlydeps=False):
pkgsettings = self.pkgsettings[root]
dbs = self._filtered_trees[root]["dbs"]
@@ -2111,27 +2131,14 @@ class depgraph(object):
if find_existing_node:
slot_atom = "%s:%s" % (
portage.cpv_getkey(cpv), metadata["SLOT"])
- existing_node = self._slot_node_map[root].get(
- slot_atom)
- if not existing_node:
+ e_pkg = self._get_existing_pkg(root, slot_atom)
+ if not e_pkg:
break
- e_type, root, e_cpv, e_status = existing_node
- metadata = dict(izip(self._mydbapi_keys,
- self.mydbapi[root].aux_get(
- e_cpv, self._mydbapi_keys)))
- cpv_slot = "%s:%s" % (e_cpv, metadata["SLOT"])
+ cpv_slot = "%s:%s" % \
+ (e_pkg.cpv, e_pkg.metadata["SLOT"])
if portage.dep.match_from_list(atom, [cpv_slot]):
- e_installed = e_type == "installed"
- e_built = e_type != "ebuild"
- e_onlydeps = not e_installed and \
- e_status == "nomerge"
- matched_packages.append(
- Package(type_name=e_type, root=root,
- cpv=e_cpv, metadata=metadata,
- built=e_built, installed=e_installed,
- onlydeps=e_onlydeps))
- else:
- existing_node = None
+ matched_packages.append(e_pkg)
+ existing_node = e_pkg.digraph_node
break
# Compare built package to current config and
# reject the built package if necessary.