Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Some packages, have a Provides: header. For example, the package postfix on Debian Wheezy has Provides: mail-transport-agent.

The package mail-transport-agent which doesn't exist physically is considered as a "virtual" package.

How can I know, on a Debian based system, if a given virtual package is "installed" (or "provided")? Can I list every "provided" virtual package?

Hint: to list every existing virtual package, installed or not, do: aptitude search "~v"

share|improve this question
    
I don't have a debian at the moment, but wouldn't a dry-run install do the job? –  jthill Nov 23 '13 at 0:45

4 Answers 4

up vote 4 down vote accepted

To list packages providing mail-transport-agent:

$ aptitude search '~Pmail-transport-agent'
p   citadel-mta                     - complete and feature-rich groupware server
p   courier-mta                     - Courier mail server - ESMTP daemon        
p   dma                             - lightweight mail transport agent          
p   esmtp-run                       - user configurable relay-only MTA - the reg
p   exim4-daemon-heavy              - Exim MTA (v4) daemon with extended feature
p   exim4-daemon-light              - lightweight Exim MTA (v4) daemon          
p   masqmail                        - mail transport agent for intermittently co
p   msmtp-mta                       - light SMTP client with support for server 
p   nullmailer                      - simple relay-only mail transport agent    
i   postfix                         - High-performance mail transport agent     
p   sendmail-bin                    - powerful, efficient, and scalable Mail Tra
p   ssmtp                           - extremely simple MTA to get mail off the s
p   xmail                           - advanced, fast and reliable ESMTP/POP3 mai

Make that aptitude search '~Pmail-transport-agent ~i' to only list installed packages (if any).

To list all virtual packages provided by currently installed packages:

aptitude search '~Rprovides:~i ~v'

See the aptitude manual for an explanation of the search patterns.

share|improve this answer
    
Accepting this answer because is uses standard aptitude. I like the explaination of @umläute though. –  Totor Dec 31 '13 at 14:41

the problem here is that there is a subtle difference between virtual packages and packages provided by other packages.

the difference is, that a package may provide a real package as well, not only a virtual package.

anyhow, the following will search for all packages that provide a package and will print both the package name and the packages it provides:

grep-available -sPackage  -sProvides -FProvides -e '^.'

to find whether any package is installed on your system that provides a given one (e.g. mail-transport-agent), use

grep-status -sPackage -sProvides -FProvides "mail-transport-agent"
share|improve this answer
2  
Note: the commands grep-available and grep-status are available once you installed the dctrl-tools package. –  Totor Oct 17 '13 at 14:17

Ok, virtual packages are alias name for a real package, or may be can say is a pointer to a package: mail-transport-agent : MTA , You can install postfix, sendmail , exim4 or every MTA for it.just one, They have conflict.

share|improve this answer
2  
This doesn't answer the question: OP is looking for a way to list all "provided" packages. Please use comments to clarify your understanding of what the questioner is seeking before answering. –  jasonwryan Oct 17 '13 at 0:18

You can get all of the virtual packages from the AUTHORITATIVE LIST OF VIRTUAL PACKAGE NAMES. As for determining if a virtual package is installed I use dpkg -l and the fact that it has an exit code of 0 if the package is installed and an exit code of 1 if it is not installed.

dpkg -l mail-transport-agent &> /dev/null; echo $?
share|improve this answer
    
No, this doesn't work. dpkg -l mail-transport-agent can return 0 even if there is no package providing it that is currently installed. I think it's based on presence in /var/dpkg/lib/available but I'm not sure. I did check that dpkg -l foo returns 1 for a package that I've never installed but 0 for a package that I just purged. –  Gilles Oct 17 '13 at 10:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.