相同的包 - 多个回购

7_R*_*R3X 13 package-management apt repository

Which repository will Ubuntu choose to download a package from if the same package is available in more than one repos? Suppose a package A was initially installed from repository X and later I added repo Y which also has package A. Which repo will be chosen to update the package? Also if I completely remove this package and try to reinstall then which repo would be preferred by Ubuntu to install the package?

fkr*_*iem 13

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.

但是,您可以通过根据各种标准为某些包分配不同的优先级来更改此设置。上一段在默认设置下是正确的,因为默认所有包的优先级都是500。但是如果包的不同版本有不同的优先级,那么将安装优先级最高的版本,并且版本号只会用作绑定如果多个版本具有相同(最高)优先级,则断路器。此外,如果最高优先级包的优先级至少为 1000,即使其版本低于当前安装的版本,它也会被安装。

优先级在 中管理/etc/apt/preferences和记录man apt_preferences。有关如何使用它们的示例,请在此处查看我的答案。