unmerge: use expand_new_virt for sys pkg warnings
authorZac Medico <zmedico@gentoo.org>
Mon, 9 May 2011 05:13:52 +0000 (22:13 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 12 May 2011 05:08:59 +0000 (22:08 -0700)
pym/_emerge/actions.py
pym/_emerge/unmerge.py
pym/portage/dbapi/_expand_new_virt.py [new file with mode: 0644]

index 3ab97028fd475f70246b173e860cfa9248c78abc..3710f7f87b041aa5d51a4de21d7ddbaebb8c0ed6 100644 (file)
@@ -31,7 +31,8 @@ from portage.cache.cache_errors import CacheError
 from portage.const import GLOBAL_CONFIG_PATH, NEWS_LIB_PATH
 from portage.const import _ENABLE_DYN_LINK_MAP
 from portage.dbapi.dep_expand import dep_expand
-from portage.dep import Atom, extended_cp_match, _get_useflag_re
+from portage.dbapi._expand_new_virt import expand_new_virt
+from portage.dep import Atom, extended_cp_match
 from portage.exception import InvalidAtom
 from portage.output import blue, bold, colorize, create_color_func, darkgreen, \
        red, yellow
@@ -1281,67 +1282,6 @@ def action_deselect(settings, trees, opts, atoms):
                        world_set.unlock()
        return os.EX_OK
 
-def expand_new_virt(vardb, atom):
-       """
-       Iterate over the recursively expanded RDEPEND atoms of
-       a new-style virtual. If atom is not a new-style virtual
-       or it does not match an installed package then it is
-       yielded without any expansion.
-       """
-       if not isinstance(atom, Atom):
-               atom = Atom(atom)
-       traversed = set()
-       stack = [atom]
-
-       while stack:
-               atom = stack.pop()
-               if atom.blocker:
-                       yield atom
-                       continue
-
-               matches = vardb.match(atom)
-               if not (matches and matches[-1].startswith("virtual/")):
-                       yield atom
-                       continue
-
-               virt_cpv = matches[-1]
-               if virt_cpv in traversed:
-                       continue
-
-               traversed.add(virt_cpv)
-               eapi, iuse, rdepend, use = vardb.aux_get(virt_cpv,
-                       ["EAPI", "IUSE", "RDEPEND", "USE"])
-               if not portage.eapi_is_supported(eapi):
-                       yield atom
-                       continue
-
-               # Validate IUSE and IUSE, for early detection of vardb corruption.
-               useflag_re = _get_useflag_re(eapi)
-               valid_iuse = []
-               for x in iuse.split():
-                       if x[:1] in ("+", "-"):
-                               x = x[1:]
-                       if useflag_re.match(x) is not None:
-                               valid_iuse.append(x)
-               valid_iuse = frozenset(valid_iuse)
-
-               iuse_implicit_match = vardb.settings._iuse_implicit_match
-               valid_use = []
-               for x in use.split():
-                       if x in valid_iuse or iuse_implicit_match(x):
-                               valid_use.append(x)
-               valid_use = frozenset(valid_use)
-
-               success, atoms = portage.dep_check(rdepend,
-                       None, vardb.settings, myuse=valid_use,
-                       myroot=vardb.root, trees={vardb.root:{"porttree":vardb.vartree,
-                       "vartree":vardb.vartree}})
-
-               if success:
-                       stack.extend(atoms)
-               else:
-                       yield atom
-
 class _info_pkgs_ver(object):
        def __init__(self, ver, repo_suffix, provide_suffix):
                self.ver = ver
index 68b61edc2d5a8038254755ba2f541c0a4336e311..7e66ff9fb7500d6dff1ca8631655921f37d35f8d 100644 (file)
@@ -8,6 +8,7 @@ import sys
 import textwrap
 import portage
 from portage import os
+from portage.dbapi._expand_new_virt import expand_new_virt
 from portage.output import bold, colorize, darkgreen, green
 from portage._sets import SETPREFIX
 from portage.util import cmp_sort_key
@@ -57,7 +58,13 @@ def unmerge(root_config, myopts, unmerge_action,
        try:
                if os.access(vdb_path, os.W_OK):
                        vdb_lock = portage.locks.lockdir(vdb_path)
-               realsyslist = sets["system"].getAtoms()
+
+               realsyslist = []
+               for x in sets["system"].getAtoms():
+                       for atom in expand_new_virt(vartree.dbapi, x):
+                               if not atom.blocker:
+                                       realsyslist.append(atom)
+
                syslist = []
                for x in realsyslist:
                        mycp = portage.dep_getkey(x)
diff --git a/pym/portage/dbapi/_expand_new_virt.py b/pym/portage/dbapi/_expand_new_virt.py
new file mode 100644 (file)
index 0000000..7a233f1
--- /dev/null
@@ -0,0 +1,66 @@
+# Copyright 2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import portage
+from portage.dep import Atom, _get_useflag_re
+
+def expand_new_virt(vardb, atom):
+       """
+       Iterate over the recursively expanded RDEPEND atoms of
+       a new-style virtual. If atom is not a new-style virtual
+       or it does not match an installed package then it is
+       yielded without any expansion.
+       """
+       if not isinstance(atom, Atom):
+               atom = Atom(atom)
+       traversed = set()
+       stack = [atom]
+
+       while stack:
+               atom = stack.pop()
+               if atom.blocker:
+                       yield atom
+                       continue
+
+               matches = vardb.match(atom)
+               if not (matches and matches[-1].startswith("virtual/")):
+                       yield atom
+                       continue
+
+               virt_cpv = matches[-1]
+               if virt_cpv in traversed:
+                       continue
+
+               traversed.add(virt_cpv)
+               eapi, iuse, rdepend, use = vardb.aux_get(virt_cpv,
+                       ["EAPI", "IUSE", "RDEPEND", "USE"])
+               if not portage.eapi_is_supported(eapi):
+                       yield atom
+                       continue
+
+               # Validate IUSE and IUSE, for early detection of vardb corruption.
+               useflag_re = _get_useflag_re(eapi)
+               valid_iuse = []
+               for x in iuse.split():
+                       if x[:1] in ("+", "-"):
+                               x = x[1:]
+                       if useflag_re.match(x) is not None:
+                               valid_iuse.append(x)
+               valid_iuse = frozenset(valid_iuse)
+
+               iuse_implicit_match = vardb.settings._iuse_implicit_match
+               valid_use = []
+               for x in use.split():
+                       if x in valid_iuse or iuse_implicit_match(x):
+                               valid_use.append(x)
+               valid_use = frozenset(valid_use)
+
+               success, atoms = portage.dep_check(rdepend,
+                       None, vardb.settings, myuse=valid_use,
+                       myroot=vardb.root, trees={vardb.root:{"porttree":vardb.vartree,
+                       "vartree":vardb.vartree}})
+
+               if success:
+                       stack.extend(atoms)
+               else:
+                       yield atom