Search code examples
linuxshellubuntupackageaptitude

Which shell command can find all packages providing a certain full virtual package?


As the title suggests, I want to get a list of all packages that provide a certain virtual package. A way of doing this would be to write a shell script that parses all output of

apt-cache search -f .*

and outputs all packages that have the virtual package in the provides section. The problem with this approach is that it takes an awful long amount of time to execute. I guess that there should be a simple command that does this in an efficient manner, but which I wasn't able to find.


Solution

  • If you have aptitude installed, it provides a lot of patterns that can be used for searching.

    In particular, for the case of looking for packages that provide a given virtual package name, you can use this:

    $ aptitude search '?provides(pattern)'
    

    where pattern can be set to the virtual package name you're looking for.

    For example:

    $ aptitude search -F %p '?provides(mail-reader)'
    balsa                                                                           
    bsd-mailx                                                                       
    claws-mail                                                                      
    cone                                                                            
    emacs                                                                           
    emacs23                                                                         
    emacs23-lucid                                                                   
    emacs23-nox                                                                     
    evolution                                                                       
    gnus                                                                            
    im                                                                              
    jed                                                                             
    kmail                                                                           
    kmail-mobile                                                                    
    mailutils                                                                       
    mailutils-mh                                                                    
    mew                                                                             
    mew-beta                                                                        
    mew-beta-bin                                                                    
    mew-bin                                                                         
    mutt                                                                            
    nmh                                                                             
    opera                                                                           
    opera-next                                                                      
    seamonkey-mailnews                                                              
    sylpheed                                                                        
    thunderbird                                                                     
    tkrat                                                                           
    vm                                                                              
    wl                                                                              
    wl-beta                                                                         
    xemacs21-mule                                                                   
    xemacs21-mule-canna-wnn                                                         
    xemacs21-nomule                                                                 
    xjed                                                                            
    xul-ext-lightning