Score:0

Multiple outputs for "apt-cache policy "

cn flag

From what I understand, apt-cache policy <package name> displays the pinning order and thus the releases of package name available in the apt repositories along with their priority orders.

So, if for an uninstalled package, the output consists of various versions (with same priority of 500) which one will be the one to be installed?

For example, $ apt-cache policy git yields me:

 Installed: (none)
 Candidate: 1:2.25.1-1ubuntu3.2
 Version table:
    1:2.25.1-1ubuntu3.2 500
       500 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
       500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
    1:2.25.1-1ubuntu3 500
       500 http://in.archive.ubuntu.com/ubuntu focal/main amd64 Packages

So, running $ sudo apt install git will install which of the versions in my system?

user535733 avatar
cn flag
The `focal-update` and `focal-security
Score:1
cn flag

Choose between the two versions:

1:2.25.1-1ubuntu3.2
1:2.25.1-1ubuntu3

Version x3.2 is higher than x3, so 1:2.25.1-1ubuntu3.2 will be installed...unless something on your system requires version x3.


Choose between different pockets that offer the same version:

500 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages

Ha -- it's a trick question: The repositories are structured so that all packages sit in one directory (/pool). Both lines point to the same package in the pool.

Luce avatar
cn flag
"unless something on your system requires version x3" Will that not be displayed by the priority number or the entries in ``/etc/apt/preferences`` to determine the one to be installed?
user535733 avatar
cn flag
Dependencies do not establish priority. Dependencies come first. If multiple packages satisfy dependencies, then version number. If the same version is available from multiple sources, then priority.
Score:1
us flag

"Candidate" indicates the version that will be installed.

It's always the highest version if different ones are available from different repositories. In the specific case of your question it comes from the "focal-updates/main" repository that you manually enabled. Disable it if you want to current version instead of the backport.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.