Bug #310947 - When expanding categories for atoms inside select_files,
authorZac Medico <zmedico@gentoo.org>
Thu, 27 May 2010 10:43:21 +0000 (03:43 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 27 May 2010 10:43:21 +0000 (03:43 -0700)
make sure packages are available besides the installed one when preferring
the category of an installed package.

pym/_emerge/depgraph.py

index 1c69076690a77911c77fa7b42503ed5b73e0832d..5a7d2b7616c26efe780960fec7e19d099333c81c 100644 (file)
@@ -1705,8 +1705,18 @@ class depgraph(object):
 
                                if len(expanded_atoms) > 1 and len(installed_cp_set) == 1:
                                        installed_cp = next(iter(installed_cp_set))
-                                       expanded_atoms = [atom for atom in expanded_atoms \
-                                               if atom.cp == installed_cp]
+                                       for atom in expanded_atoms:
+                                               if atom.cp == installed_cp:
+                                                       available = False
+                                                       for pkg in self._iter_match_pkgs_any(
+                                                               root_config, atom.without_use,
+                                                               onlydeps=onlydeps):
+                                                               if not pkg.installed:
+                                                                       available = True
+                                                                       break
+                                                       if available:
+                                                               expanded_atoms = [atom]
+                                                               break
 
                                # If a non-virtual package and one or more virtual packages
                                # are in expanded_atoms, use the non-virtual package.
@@ -2372,6 +2382,13 @@ class depgraph(object):
                        show_mask_docs()
                        print()
 
+       def _iter_match_pkgs_any(self, root_config, atom, onlydeps=False):
+               for db, pkg_type, built, installed, db_keys in \
+                       self._dynamic_config._filtered_trees[root_config.root]["dbs"]:
+                       for pkg in self._iter_match_pkgs(root_config,
+                               pkg_type, atom, onlydeps=onlydeps):
+                               yield pkg
+
        def _iter_match_pkgs(self, root_config, pkg_type, atom, onlydeps=False):
                """
                Iterate over Package instances of pkg_type matching the given atom.