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?

2
  • See this post and its mention of "pinning": askubuntu.com/questions/27362/… Commented Sep 16, 2016 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... Commented Sep 16, 2016 at 7:00

1 Answer 1

8

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>.

2
  • 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. Commented Sep 25, 2016 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. Commented Sep 25, 2016 at 6:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.