Same Package - Multiple Repos
Solution 1:
By default, the package with the highest version number is installed, regardless of which repository it comes from, unless its version number is lower than the currently installed version of the package (this can happen, for example, if you downloaded a higher version as a .deb
package and installed it manually). In the very unlikely case that several repositories have the same (highest) version of a package, the package is installed from the one which appears first in the sources.list
file.
You can change this, however, by assigning a different priority to some packages based on various criteria. The previous paragraph is true with the default settings because by default all packages have priority 500. If different versions of the package have different priorities, however, the version with the highest priority will be installed, and version numbers will only be used as tie-breakers if several versions have the same (highest) priority. Also, if the highest-priority package has priority at least 1000, it will be installed even if its version is lower than the version currently installed.
Priorities are managed in /etc/apt/preferences
and documented in man apt_preferences
. See my answer here for an example of how they can be used.