Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 307947 - `PORTDIR_OVERLAY="" equery which` gives traceback
Summary: `PORTDIR_OVERLAY="" equery which` gives traceback
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage Tools Team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 237964
  Show dependency tree
 
Reported: 2010-03-05 22:46 UTC by Ryan Hill (RETIRED)
Modified: 2010-04-08 15:29 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
gentoolkit-0.3.0_rc9-installed.patch (gentoolkit-0.3.0_rc9-installed.patch,1.03 KB, patch)
2010-03-06 10:39 UTC, Harald van Dijk (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Hill (RETIRED) gentoo-dev 2010-03-05 22:46:14 UTC
`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.
Comment 1 Harald van Dijk (RETIRED) gentoo-dev 2010-03-05 23:19:57 UTC
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?
Comment 2 Ryan Hill (RETIRED) gentoo-dev 2010-03-06 00:01:59 UTC
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
Comment 3 Ryan Hill (RETIRED) gentoo-dev 2010-03-06 00:10:40 UTC
okay it works if the version in the overlay and in PORTDIR are the same.
Comment 4 Douglas Anderson 2010-03-06 00:26:43 UTC
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.
Comment 5 Harald van Dijk (RETIRED) gentoo-dev 2010-03-06 10:39:46 UTC
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.
Comment 6 Douglas Anderson 2010-03-06 11:38:53 UTC
(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.
Comment 7 Ryan Hill (RETIRED) gentoo-dev 2010-03-06 21:03:44 UTC
WFM, thanks.
Comment 8 Douglas Anderson 2010-03-12 02:50:46 UTC
(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.
Comment 9 Paul Varner (RETIRED) gentoo-dev 2010-04-08 15:29:54 UTC
This was released in gentoolkit-0.3.0_rc10