4

I put jessie-backports in my /etc/apt/sources.list, but it seems that apt will not automatically use the packages from backports but older packages.

However, if I use apt-cache show to check the version it shows the latest, and I am able to use apt install xxx=<latest-version> to install it.

How to tell apt always use the latest package by default?

  • See this post and its mention of "pinning": askubuntu.com/questions/27362/… – cutrightjm Sep 16 '16 at 3:19
  • 2
    Before doing this, it's worth wondering why we specifically set the backports repositories up so that they don't get picked by default... – Stephen Kitt Sep 16 '16 at 7:00
7

As @cutrightjm has mentioned apt-pinning is the solution.

If you create a file /etc/apt/preferences.d/backports with the following content

Package: *
Pin: release a=stretch-backports
Pin-Priority: 800

apt will always install packages from stretch-backports, except when you pin another package source with a priority higher than 800.

If you want to see all available versions of a package, their priority and which one will be installed, you can use apt-cache policy <packagename>.

  • One more question: when I have multiple versions of one package from multiple sources, how do I tell apt to use the latest version? The preference doesn't seem to be able to do that. – t123yh Sep 25 '16 at 1:59
  • It's really not recommended to mix many package sources. Debian is intended as a distribution which prefers stability over stability. So if you add another package source, you should only pin the packages you want to install to a higher Priority. – lw1.at Sep 25 '16 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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