Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 757897

Summary: app-portage/gentoolkit - "equery m git" shows one of 3 packages on each run, instead of reporting "Ambiguous package name." like "equery m glib" does.
Product: Gentoo Linux Reporter: flippynelle <flippynelle>
Component: Current packagesAssignee: Portage Tools Team <tools-portage>
Status: CONFIRMED ---    
Severity: normal CC: flippynelle, pacho
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=691798
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: "equery m git" collision fixxage

Description flippynelle 2020-12-01 15:54:57 UTC
The problem is in: /usr/lib/python3.7/site-packages/portage/dbapi/cpv_expand.py
this code here:
        if len(matches) > 1:
            virtual_name_collision = False
            if len(matches) > 1:
                for x in matches:
                    print("m", mycpv, x)
                    if not x.startswith(("acct-group/", "acct-user/", "virtual/")):
                        # Assume that the non-virtual is desired.  This helps
                        # avoid the ValueError for invalid deps that come from
                        # installed packages (during reverse blocker detection,
                        # for example).
                        mykey = x
                        print("n", mycpv, x)                                    
                    else:
                        print("o", mycpv, x)
                        virtual_name_collision = True
            if not virtual_name_collision:
                # AmbiguousPackageName inherits from ValueError,
                # for backward compatibility with calling code
                # that already handles ValueError.
                raise AmbiguousPackageName(matches)
        elif matches:
            mykey=matches[0]

I added the 3 print() statements.

Reproducible: Always

Steps to Reproduce:
1. equery m git
2. equery m glib

Actual Results:  
1.
# equery m git
m git acct-group/git
o git acct-group/git
m git acct-user/git
o git acct-user/git
m git dev-vcs/git
n git dev-vcs/git
m git dev-haskell/git
n git dev-haskell/git
m git dev-ruby/git
n git dev-ruby/git
gentoolkit/query.py  git dev-ruby/git-1.7.0
m git acct-group/git
o git acct-group/git
m git acct-user/git
o git acct-user/git
m git dev-vcs/git
n git dev-vcs/git
m git dev-haskell/git
n git dev-haskell/git
m git dev-ruby/git
n git dev-ruby/git
 * dev-ruby/git [gentoo]
Maintainer:  ruby@gentoo.org (Gentoo Ruby Project)
Upstream:    Remote-ID:   schacon/ruby-git ID: github
Homepage:    https://github.com/schacon/ruby-git
Location:    /var/db/repos/gentoo/dev-ruby/git
Keywords:    1.7.0:0: amd64
Keywords:    2.29.2:0: ~alpha ~amd64 ~amd64-linux ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc-aix ~ppc-macos
                       ~ppc64 ~riscv ~s390 ~sparc ~sparc-solaris ~sparc64-solaris ~x64-cygwin ~x64-macos
                       ~x64-solaris ~x86 ~x86-linux ~x86-macos ~x86-solaris
License:     MIT

1. (next run) different git package shown:
# equery m git
m git dev-vcs/git
n git dev-vcs/git
m git acct-group/git
o git acct-group/git
m git dev-ruby/git
n git dev-ruby/git
m git dev-haskell/git
n git dev-haskell/git
m git acct-user/git
o git acct-user/git
gentoolkit/query.py  git dev-haskell/git-0.3.0
m git dev-vcs/git
n git dev-vcs/git
m git acct-group/git
o git acct-group/git
m git dev-ruby/git
n git dev-ruby/git
m git dev-haskell/git
n git dev-haskell/git
m git acct-user/git
o git acct-user/git
 * dev-haskell/git [gentoo]
Maintainer:  haskell@gentoo.org (Gentoo Haskell)
Upstream:    None specified
Homepage:    https://github.com/vincenthz/hs-git
Location:    /var/db/repos/gentoo/dev-haskell/git
Keywords:    0.3.0:0/0.3.0: ~amd64 ~x86
Keywords:    2.29.2:0: ~alpha ~amd64 ~amd64-linux ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc-aix ~ppc-macos
                       ~ppc64 ~riscv ~s390 ~sparc ~sparc-solaris ~sparc64-solaris ~x64-cygwin ~x64-macos
                       ~x64-solaris ~x86 ~x86-linux ~x86-macos ~x86-solaris
License:     BSD


2. this one is correct:
# equery m glib
m glib dev-haskell/glib
m glib dev-libs/glib
!!! Ambiguous package name. Choose from:
  dev-haskell/glib
  dev-libs/glib


Expected Results:  
"equery m git" should show:
!!! Ambiguous package name. Choose from:
acct-group/git
acct-user/git
dev-vcs/git
dev-haskell/git
dev-ruby/git


or maybe not show the "acct" ones in the list, not sure.

Portage 3.0.11
Comment 1 flippynelle 2020-12-01 16:05:30 UTC
Correction, this block:

2. this one is correct:
# equery m glib
m glib dev-haskell/glib
m glib dev-libs/glib
!!! Ambiguous package name. Choose from:
  dev-haskell/glib
  dev-libs/glib

Should've been this:

2. this one is correct:
# equery m glib
m glib dev-haskell/glib
n glib dev-haskell/glib
m glib dev-libs/glib
n glib dev-libs/glib
!!! Ambiguous package name. Choose from:
  dev-haskell/glib
  dev-libs/glib
Comment 2 flippynelle 2020-12-02 13:39:15 UTC
Created attachment 676210 [details, diff]
"equery m git" collision fixxage

I'll be using this temp-patch until an official one is made, since I cannot wait until then.

Results:

# equery m git
!!! Ambiguous package name. Choose from:
  dev-haskell/git
  acct-group/git
  dev-vcs/git
  acct-user/git
  dev-ruby/git

# equery m git
!!! Ambiguous package name. Choose from:
  dev-vcs/git
  acct-group/git
  acct-user/git
  dev-ruby/git
  dev-haskell/git
Comment 3 Pacho Ramos gentoo-dev 2022-05-12 16:38:08 UTC
It happens to other equery commands as equery uses too
Comment 4 cyrillic 2022-05-14 22:51:24 UTC
(In reply to flippynelle from comment #1)
> 2. this one is correct:
> # equery m glib
> m glib dev-haskell/glib
> m glib dev-libs/glib
> !!! Ambiguous package name. Choose from:
>   dev-haskell/glib
>   dev-libs/glib
> 

I think this is a really assinine response from gentoolkit. When more than one package matches the query, all results should be displayed.

Another way to fix this would be to get rid of dev-haskell/* from the main gentoo repo, and stick it in an overlay.
Comment 5 Brian Dolbec (RETIRED) gentoo-dev 2022-05-27 18:48:23 UTC
(In reply to cyrillic from comment #4)
> (In reply to flippynelle from comment #1)
> > 2. this one is correct:
> > # equery m glib
> > m glib dev-haskell/glib
> > m glib dev-libs/glib
> > !!! Ambiguous package name. Choose from:
> >   dev-haskell/glib
> >   dev-libs/glib
> > 
> 
> I think this is a really assinine response from gentoolkit. When more than
> one package matches the query, all results should be displayed.
> 
> Another way to fix this would be to get rid of dev-haskell/* from the main
> gentoo repo, and stick it in an overlay.

Pacho, the problem is with changes in portage code that spits out the "!!! Ambiguous package name. Choose from:..." stuff.

@zmedico, could cpv_expand get an extra parameter (default False) that gentoolkit could pass to kill the Ambiguos error and return all matches instead?