Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

if a same software (different version) are present in two repos both added in

sources.list

then which one will get installed when I run install command

apt-get install x

?

Also how can I choice one repo over another if both provide application with same name ?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

(This answer is based on the default setup of Ubuntu, with default repository preference)

If the same software has different versions, Apt will always try to use the most recent version of the software subject to dependency constraints.

*Please note that, Apt also look at the priority of a repository, if a higher priority of a repository has lower version, Apt won't upgrade the package. In default Ubuntu installation, all enabled repository has priority 500 except the backport repository, which has priority 100. So, if a software has higher versioned package in backport repository, that software will not be upgraded with sudo apt-get install x command. You need to explicitly tell apt to use that repository by using command like this: sudo apt-get install x/precise-backports. *

But, if two repo provide the same software with the same version, then Apt will install software from the repository which comes first in the sources.list file.

I'm quoting from apt_preference manual page:

   Several instances of the same version of a package may be available
   when the sources.list(5) file contains references to more than one
   source. In this case apt-get downloads the instance listed earliest in
   the sources.list(5) file. The APT preferences file does not affect the
   choice of instance, only the choice of version.
share|improve this answer

It depends on which version is available where. To see which version will be installed, with the repositories in question added, you can run apt-cache policy x, to follow your example, and it will show you the installed version, and the candidate (which is the version which would be installed, if you install or upgrade).

share|improve this answer
    
how can I chose/change candidate which is selected by default ? I think default selection is based on version number ? –  beginner Sep 13 '12 at 17:13
    
The candidate is always the newest version. As mentioned in the other answer, it will pick the first in the list if versions match. However, you shouldn't add extra sources to sources.list directly, but to new files in /etc/apt/sources.list.d/ instead; for cleanliness and maintainability. If you're trying to use another repository with the same version as Ubuntu, and the software isn't the same, then you should complain to the owner of that repository, with a bug report or something. –  dobey Sep 13 '12 at 19:40

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.