`equery which` does everything I need to replace my own home-grown (ie. shitty) script except one thing. I'd like the ability to ignore overlays and only pick ebuilds from the main tree. I tried PORTDIR_OVERLAY="" equery which <pkg> but that gets me a traceback.
As far as I can tell, PORTDIR_OVERLAY="" equery which works, except for the traceback on reporting that a package is unavailable in the main tree, when a clean error message should be given. That should be fixed, of course, but in its current state it should work for you for a script. $ equery which gpc /var/cvs/gentoo-x86/dev-lang/gpc/gpc-20070904.ebuild $ PORTDIR_OVERLAY= equery which gpc /usr/portage/dev-lang/gpc/gpc-20070904.ebuild $ equery which sys-devel/gcc:4.5 /etc/portage/layman/toolchain/sys-devel/gcc/gcc-4.5.0_alpha20100225.ebuild $ PORTDIR_OVERLAY= equery which sys-devel/gcc:4.5 Traceback (most recent call last): File "/usr/bin/equery-2.6", line 35, in <module> equery.main() File "/usr/lib64/python2.6/site-packages/gentoolkit/equery/__init__.py", line 343, in main loaded_module.main(module_args) File "/usr/lib64/python2.6/site-packages/gentoolkit/equery/which.py", line 97, in main pp.warn("No ebuilds to satisfy %s" % pkg.cpv.name) AttributeError: 'unicode' object has no attribute 'name' Changing pkg.cpv.name to pkg.cpv would improve this by printing: $ PORTDIR_OVERLAY= equery which sys-devel/gcc:4.5 !!! No ebuilds to satisfy sys-devel/gcc-4.5.0_alpha20100225 However, it causes the non-zero exit status from the traceback to become a zero exit status. Should that be changed as well?
dirtyepic@halo ~ $ equery w wxGTK /home/dirtyepic/svn/dirtyepic/x11-libs/wxGTK/wxGTK-2.9.1_pre9999.ebuild dirtyepic@halo ~ $ PORTDIR_OVERLAY="" equery w wxGTK Traceback (most recent call last): File "/usr/bin/equery-2.6", line 35, in <module> equery.main() File "/usr/lib64/python2.6/site-packages/gentoolkit/equery/__init__.py", line 343, in main loaded_module.main(module_args) File "/usr/lib64/python2.6/site-packages/gentoolkit/equery/which.py", line 97, in main pp.warn("No ebuilds to satisfy %s" % pkg.cpv.name) AttributeError: 'unicode' object has no attribute 'name that should return /usr/portage/x11-libs/wxGTK-2.8.10.1-r5.ebuild
okay it works if the version in the overlay and in PORTDIR are the same.
g$ svn ci -m "Fixes traceback in equery.which (bug #307947)" Sending gentoolkit/equery/which.py Transmitting file data . Committed revision 246. The reason, and maybe it's not a good one, that the exit status is zero even if an ebuild wasn't found is because all equery modules now take multiple input, and if it runs into an "non-fatal" error with the first input, it'll try and go on to the next. Should probably try harder to make it return a correct exit status.
Created attachment 222253 [details, diff] gentoolkit-0.3.0_rc9-installed.patch (In reply to comment #2) > that should return /usr/portage/x11-libs/wxGTK-2.8.10.1-r5.ebuild Ah, so something like this would do what you want.
(In reply to comment #5) > (In reply to comment #2) > > that should return /usr/portage/x11-libs/wxGTK-2.8.10.1-r5.ebuild > > Ah, so something like this would do what you want. $ svn ci -m "Adds patch from Harald van Dijk to allow helpers.find_packages to exclude packages which are in the VARDB but not the PORTDB, useful in which.py; bug #307947." Sending gentoolkit/equery/which.py Sending gentoolkit/helpers.py Transmitting file data .. Committed revision 260. I just changed the name of the keyword arg to 'in_vartree', because if you notice the function directly below find_packages, include_installed=False actually returns the _difference_ of the set of portdb packages and the set of installed packages. "in_vartree" is used quite a bit in package.py. I don't have any overlays installed to test this, so you will either need to check out genscripts.googlecode.com or wait for FuzzyRay to pull this change into gentoolkit svn, and let me know if it works for you.
WFM, thanks.
(In reply to comment #1) > However, it causes the non-zero exit status from the traceback to become a zero > exit status. Should that be changed as well? $ svn ci -m "Makes Query.smart_find raise errors.GentoolkitNoMatches if no matches were found and 'no_matches_fatal=True', which is now default. To avoid unnecessary bug reports, all exceptions now have an 'is_serious' keyword param set to a sane default for each error type. If err.is_serious=False, equery will not display the 'Add --debug to see traceback' statement after the error; if True, it will. GentoolkitNoMatches and friends are considered 'not serious' as are routinely used for user feedback." Sending gentoolkit/bin/equery Sending gentoolkit/pym/gentoolkit/errors.py Sending gentoolkit/pym/gentoolkit/query.py Transmitting file data ... Committed revision 377. Basically, no matches should raise by default and exit status should be 1 now.
This was released in gentoolkit-0.3.0_rc10