Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 78687 - 'equery which' always selects the latest ebuild, even when it's masked
Summary: 'equery which' always selects the latest ebuild, even when it's masked
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Tools (show other bugs)
Hardware: All All
: High normal
Assignee: Portage Tools Team
URL:
Whiteboard:
Keywords: InVCS
: 85237 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-01-19 08:16 UTC by Peter Jensen
Modified: 2006-01-17 19:11 UTC (History)
3 users (show)

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


Attachments
diff -Nu old/ new/ (on gentoolkit.py and equery) (patch,1.62 KB, patch)
2005-07-01 03:06 UTC, Ingo Bormuth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Jensen 2005-01-19 08:16:25 UTC
'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.
Comment 1 Emil Beinroth 2005-01-19 11:47:21 UTC
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
Comment 2 Marius Mauch (RETIRED) gentoo-dev 2005-03-14 10:09:25 UTC
*** Bug 85237 has been marked as a duplicate of this bug. ***
Comment 3 Ingo Bormuth 2005-07-01 03:05:17 UTC
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.
Comment 4 Ingo Bormuth 2005-07-01 03:06:38 UTC
Created attachment 62392 [details, diff]
diff -Nu old/ new/   (on gentoolkit.py and equery)
Comment 5 Emil Beinroth 2005-07-01 09:30:26 UTC
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!
Comment 6 Ingo Bormuth 2005-07-27 02:30:54 UTC
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.
Comment 7 Paul Varner (RETIRED) gentoo-dev 2005-09-22 13:37:23 UTC
Fix is in subversion
Comment 8 Paul Varner (RETIRED) gentoo-dev 2005-09-23 15:48:51 UTC
Fix is in gentoolkit-0.2.1_pre8
Comment 9 Paul Varner (RETIRED) gentoo-dev 2006-01-17 19:11:53 UTC
Fixed in gentoolkit-0.2.1