diff --git a/bin/portageq b/bin/portageq index 069ece2..73fe79d 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,31 @@ def match(argv): print(cpv) match.uses_root = True +def expand_virtual(argv): + """ + 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: + print("ERROR: expected 2 parameters, got %d!" % len(argv)) + sys.exit(2) + root, atom = argv + if atom_validate_strict and not portage.isvalidatom(atom): + portage.writemsg("ERROR: Invalid atom: '%s'\n" % atom, + noiselevel=-1) + return 2 + results = list(expand_new_virt(portage.db[root]["vartree"].dbapi, atom)) + results.sort() + for x in results: + if not x.blocker: + print(x) +expand_virtual.uses_root = True def vdb_path(argv): """