From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QS7bx-0005a6-2o for garchives@archives.gentoo.org; Thu, 02 Jun 2011 13:06:56 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 09D401C1BC; Thu, 2 Jun 2011 13:06:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id BFDFF1C1C1 for ; Thu, 2 Jun 2011 13:06:35 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3AD841B4018 for ; Thu, 2 Jun 2011 13:06:35 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 518F880506 for ; Thu, 2 Jun 2011 13:06:34 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1edf9e3bd37fede61a21d3b6a84542d29d8f3021.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/portageq X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 1edf9e3bd37fede61a21d3b6a84542d29d8f3021 Date: Thu, 2 Jun 2011 13:06:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 29540bede53b2437269d0133c894d726 commit: 1edf9e3bd37fede61a21d3b6a84542d29d8f3021 Author: Zac Medico gentoo org> AuthorDate: Thu Jun 2 12:50:54 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Thu Jun 2 12:50:54 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D1edf9e3b portageq: add new expand_virtual function Something like this was requested in bug #157357. Now that Gentoo has migrated all virtuals to GLEP 37 new-style virtuals, this kind of function may be helpful in order to resolve the currently installed provider of a particular virtual in scripts like bootstrap.sh. Usage: portageq expand_virtual 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. Example input/output: $ portageq expand_virtual / virtual/jre =3Ddev-java/sun-jdk-1.6.0* $ portageq expand_virtual / virtual/jre:1.5 dev-java/gcj-jdk $ portageq expand_virtual / virtual/package-manager sys-apps/portage $ portageq expand_virtual / virtual/libc sys-libs/glibc:2.2 $ portageq expand_virtual / virtual/os-headers sys-kernel/linux-headers:0 --- bin/portageq | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/bin/portageq b/bin/portageq index 069ece2..d6d9c17 100755 --- a/bin/portageq +++ b/bin/portageq @@ -43,6 +43,7 @@ except ImportError: del pym_path =20 from portage import os +from portage.dbapi._expand_new_virt import expand_new_virt from portage.util import writemsg, writemsg_stdout =20 def eval_atom_use(atom): @@ -492,6 +493,40 @@ def match(argv): print(cpv) match.uses_root =3D True =20 +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) !=3D 2: + writemsg("ERROR: expected 2 parameters, got %d!\n" % len(argv), + noiselevel=3D-1) + return 2 + + root, atom =3D argv + + try: + results =3D list(expand_new_virt( + portage.db[root]["vartree"].dbapi, atom)) + except portage.exception.InvalidAtom: + writemsg("ERROR: Invalid atom: '%s'\n" % atom, + noiselevel=3D-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 =3D True =20 def vdb_path(argv): """