-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi everyone,
It's come to my attention that the built_with_use function in eutils.eclass accesses the installed package database directly. This is a major problem because it prevents us from being able to have an alternative installed package database implementation without breaking that function. How about if we add a new portageq function that simply acts as a wrapper to the dbapi.aux_get() function? If we provide this function, then eutils.eclass can simply use the package that is returned from best_version to do another call that gets the USE flags. Here's an example of the usage: portageq metadata / installed sys-apps/portage-2.1-r1 USE That command would print 1 line with all the USE flags. If additional metadata keys are specified, it will print each value on a new line. Does the behavior described above seem good or are there any suggestions to improve it? Please see the attached patch. Zac -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.4 (GNU/Linux) iD8DBQFEtxf+/ejvha5XGaMRAkaKAKCAi/WHt6GIIoW0HqyaFbTmKLHTeQCeIN/d rJUMKUs7OK9Z3tS9Ms0f0a4= =3+Gh -----END PGP SIGNATURE-----
Index: bin/portageq =================================================================== --- bin/portageq (revision 3854) +++ bin/portageq (working copy) @@ -80,7 +80,34 @@ sys.exit(1) mass_best_version.uses_root = True +def metadata(argv): + """<root> <pkgtype> <category/package> [<key>]+ + Returns a metadata value 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) + try: + values = portage.db[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>]+ Returns category/package-version (without .ebuild).