reposyntax: Next try at fixing the package cache
authorSebastian Luther <SebastianLuther@gmx.de>
Tue, 21 Sep 2010 18:39:39 +0000 (20:39 +0200)
committerZac Medico <zmedico@gentoo.org>
Mon, 27 Sep 2010 06:50:14 +0000 (23:50 -0700)
pym/_emerge/FakeVartree.py
pym/_emerge/depgraph.py

index 64a39cf4d961b5fc69c153167ee488935f97d027..b7b0893382108c111e7289c0b7f0eebf77fc837a 100644 (file)
@@ -200,7 +200,11 @@ class FakeVartree(vartree):
                        mycounter = 0
                        pkg.metadata["COUNTER"] = str(mycounter)
 
-               self._pkg_cache[pkg] = pkg
+               #For installed (and binary) packages we don't care for the repo when it comes to
+               #caching, because there can only be one cpv. So overwrite the repo key with type_name.
+               #Make sure that .operation is computed.
+               pkg._get_hash_key()
+               self._pkg_cache[(pkg.type_name, pkg.root, pkg.cpv, pkg.operation, pkg.type_name)] = pkg
                return pkg
 
 def grab_global_updates(portdb):
index aa53ec35241157e95bdfa6ac585591ce7c77d84f..b28f2fe59a1ee6caf0230ea6d8bfda5644be47d1 100644 (file)
@@ -3250,6 +3250,11 @@ class depgraph(object):
                failures for some reason (package does not exist or is
                corrupt).
                """
+               if type_name == "ebuild" and myrepo is None:
+                       raise ValueError("Need repository to create Package for ebuild.")
+               elif myrepo is None:
+                       myrepo = type_name
+
                operation = "merge"
                if installed or onlydeps:
                        operation = "nomerge"
@@ -3275,7 +3280,16 @@ class depgraph(object):
                        pkg = Package(built=(type_name != "ebuild"), cpv=cpv,
                                installed=installed, metadata=metadata, onlydeps=onlydeps,
                                root_config=root_config, type_name=type_name)
-                       self._frozen_config._pkg_cache[pkg] = pkg
+
+                       if type_name == "ebuild":
+                               self._frozen_config._pkg_cache[pkg] = pkg
+                       else:
+                               #For installed and binary packages we don't care for the repo when it comes to
+                               #caching, because there can only be one cpv. So overwrite the repo key with type_name.
+                               #Make sure that .operation is computed.
+                               pkg._get_hash_key()
+                               self._frozen_config._pkg_cache[
+                                       (pkg.type_name, pkg.root, pkg.cpv, pkg.operation, pkg.type_name)] = pkg
 
                        if not self._pkg_visibility_check(pkg) and \
                                'LICENSE' in pkg.masks and len(pkg.masks) == 1: