'equery which' used to be very useful to find the ebuild for the package 'emerge' would install. However, this is no longer the case with app-portage/gentoolkit-0.2.0. An example: $ emerge -p sys-devel/gcc These are the packages that I would merge, in order: Calculating dependencies ...done! [ebuild R ] sys-devel/gcc-3.3.5-r1 $ equery which sys-devel/gcc /usr/portage/sys-devel/gcc/gcc-3.4.3.20050110.ebuild As it stands, this function is just about useless. A pity, as I used it in my scripts to automate the adding of custom tweaks to the ebuilds.
It's on line 901 in /usr/bin/equery: matches = gentoolkit.find_packages(query, True) discards all masking and matches every packet in the tree matches = gentoolkit.find_packages(query) would only match not masked packets
*** Bug 85237 has been marked as a duplicate of this bug. ***
Actually it's on line 202 of gentoolkit.py: 198 def find_packages(search_key, masked=False): 199 """Returns a list of Package objects that matched the search key.""" 200 try: 201 if masked: ==> 202 t=portage.portdb.xmatch("match-all", search_key) 203 else: 204 t=portage.portdb.match(search_key) It should not say "match-all" but "match-visible". I don't know weather that would interfere with other apps using the function. If yes, one should create a new function find_candidate which just returns the package that would be installed: def find_candidate(search_key): """Returns a Package object for the best available candidate that matched the search key.""" try: t=portage.portdb.xmatch("match-visible", search_key) # catch the "amgigous package" Exception # Copied from find_packages (DO WE NEED THAT ?) except ValueError, e: if type(e[0]) == types.ListType: t=[] for cp in e[0]: if masked: t += portage.portdb.xmatch("match-visible", cp) else: t += portage.portdb.match(cp) else: raise ValueError(e) return sort_package_list([Package(x) for x in t])[-1] This could then be used in equery: 900 ==> 901 matches = gentoolkit.find_candidate(query) 902 903 if matches: 904 print_info(0, os.path.normpath(matches.get_ebuild_path())) 905 else: 906 print_error("No masked or unmasked packages found for " + pp.pkgquery(query)) Patch attached. Another possibility might be to steal some code from eix which should make equery much faster.
Created attachment 62392 [details, diff] diff -Nu old/ new/ (on gentoolkit.py and equery)
AFAIK: match(search_key) does the same as xmatch("match-visible", search_key). If you change the "match-all" to "match-visible" in find_packages you would ignore the 'masked'-prameter. I don't understand why you want to create find_candiates if find_packages(masked=False, "findme") is just fine. eix is a mess and written in c++. It's broken by design because we currently rely on the cache to be up2date. We also need to (poorly) rewrite every portage-caching-module that we want to use. If you are a programmer, you don't want to go anywhere near eix!
As far as I understood match(search_key) just looks at stable packages - no matter what you have in package.keyword. xmatch("match-visible", search_key) gives you the package emerge would install (stable or not). I did not say defining find_candidate is the way to go. I would just replace 'match-all' by 'match-visible' in line 202. The current implementation IS DEFINITLY BROKEN.
Fix is in subversion
Fix is in gentoolkit-0.2.1_pre8
Fixed in gentoolkit-0.2.1