summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/portageq35
1 files changed, 35 insertions, 0 deletions
diff --git a/bin/portageq b/bin/portageq
index 069ece238..d6d9c170a 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -43,6 +43,7 @@ except ImportError:
del pym_path
from portage import os
+from portage.dbapi._expand_new_virt import expand_new_virt
from portage.util import writemsg, writemsg_stdout
def eval_atom_use(atom):
@@ -492,6 +493,40 @@ def match(argv):
print(cpv)
match.uses_root = True
+def expand_virtual(argv):
+ """<root> <atom>
+ Returns a \\n separated list of atoms expanded from a
+ given virtual atom, excluding blocker atoms. Satisfied
+ virtual atoms are not included in the output, since
+ they are expanded to real atoms which are displayed.
+ Unsatisfied virtual atoms are displayed without
+ any expansion. The "match" command can be used to
+ resolve the returned atoms to specific installed
+ packages.
+ """
+ if len(argv) != 2:
+ writemsg("ERROR: expected 2 parameters, got %d!\n" % len(argv),
+ noiselevel=-1)
+ return 2
+
+ root, atom = argv
+
+ try:
+ results = list(expand_new_virt(
+ portage.db[root]["vartree"].dbapi, atom))
+ except portage.exception.InvalidAtom:
+ writemsg("ERROR: Invalid atom: '%s'\n" % atom,
+ noiselevel=-1)
+ return 2
+
+ results.sort()
+ for x in results:
+ if not x.blocker:
+ writemsg_stdout("%s\n" % (x,))
+
+ return os.EX_OK
+
+expand_virtual.uses_root = True
def vdb_path(argv):
"""