diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-07-15 19:46:43 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-07-15 19:46:43 +0000 |
commit | 02380f9201ef95657f76c74a87403133fbd0587d (patch) | |
tree | f2436bf0a87274e7dee07ea5d6f5b8b43318991d | |
parent | 35e09c1a73bd5865a708a4c45c9c48e5f70a6f13 (diff) | |
download | portage-02380f9201ef95657f76c74a87403133fbd0587d.tar.gz portage-02380f9201ef95657f76c74a87403133fbd0587d.tar.bz2 portage-02380f9201ef95657f76c74a87403133fbd0587d.zip |
Add a new portageq metadata function that wraps dbapi.aux_get() so that things like built_with_use in eutils.eclass can retrieve metadata in manner that is independent of the installed package database implementation.
svn path=/main/trunk/; revision=3893
-rwxr-xr-x | bin/portageq | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/portageq b/bin/portageq index b8e12c5fa..ef05a28d7 100755 --- a/bin/portageq +++ b/bin/portageq @@ -80,6 +80,36 @@ def mass_best_version(argv): sys.exit(1) mass_best_version.uses_root = True +def metadata(argv): + """<root> <pkgtype> <category/package> [<key>]+ + Returns metadata values for the specified package. + """ + if (len(argv) < 4): + print >> sys.stderr, "ERROR: insufficient parameters!" + sys.exit(2) + + root, pkgtype, pkgspec = argv[0:3] + metakeys = argv[3:] + type_map = { + "ebuild":"porttree", + "binary":"bintree", + "installed":"vartree"} + if pkgtype not in type_map: + print >> sys.stderr, "Unrecognized package type: '%s'" % pkgtype + sys.exit(1) + trees = portage.db + if os.path.realpath(root) == os.path.realpath(portage.settings["ROOT"]): + root = portage.settings["ROOT"] # contains the normalized $ROOT + try: + values = trees[root][type_map[pkgtype]].dbapi.aux_get( + pkgspec, metakeys) + for value in values: + print value + except KeyError: + print >> sys.stderr, "Package not found: '%s'" % pkgspec + sys.exit(1) + +metadata.uses_root = True def best_visible(argv): """<root> [<category/package>]+ |