I have Debian Jessie and have added backports (according to these instructions):

echo "deb http://http.debian.net/debian jessie-backports main contrib non-free" | sudo tee /etc/apt/sources.list.d/backports.list

(I did this to get a newer kernel, as I needed it, of for some hardware in my laptop.)

The instructions say that nothing should happen, unless I explicitly ask for a backported package. e.g. apt-get -t jessie-backports install "package".

However I now seem to have a whole load of my system from backports, and one package has un-installed, because it depends on an exact version, of something that was updated to back-ports.

So my question:

  • How do I first stop it, so that no more backports are installed?
  • How do I remove the existing backports?

Note: this gets a list of installed packages that are from backports (and in format that can be passed to apt-get install, for some reason putting sudo apt-get install in place of echo at end of pipeline does not work ):

cat /var/log/dpkg.log.1 |grep -v linux | grep -v xserver | grep -v firmware | grep "status installed" | grep bpo | cut -d" " -f 5 | cut -d: -f 1 | xargs -i{} -n1 bash -c "dpkg-query -s {} >/dev/null && echo {}" | sed -r -e "s~.*~\0/jessie~" | xargs echo


Some of the packages are automatically installed, so if you reinstall them all, then these automatically installed packages will be marked as manually installed. Thus not removed when not needed.

Any one have any ideas as to how to solve this?

3 Answers 3

  1. Try adding the following to either /etc/apt/apt.conf or a file under /etc/apt/apt.conf.d:

    APT::Default-Release "jessie";

  2. To remove the existing backports, you'll need to get a list of which ones were installed, and what version they replaced. Fortunately, this information can be extracted very easily from /var/log/dpkg.log

e.g. grep ' upgrade ' /var/log/dpkg.log will give you many lines like the following:

2016-02-15 11:06:32 upgrade python-numpy:amd64 1:1.11.0~b2-1 1:1.11.0~b3-1

This says that at 11:06am on 15th Feb, I upgraded python-numpy from version 1:1.11.0~b2-1 to version 1:1.11.0~b3-1

If I wanted to downgrade to the previous version, then I would run:

apt-get install python-numpy=1:1.11.0~b2-1

NOTE: in this particular case, it probably won't work because I run debian sid aka unstable so the old version is probably no longer available in the deb repository. If you're running jessie and are re-installing a jessie version of a package as a downgrade to the jessie-backports version, it will work as expected.

Similarly, if a package has been removed you can find it and its exact version by grepping for remove in /var/log/dpkg.log.

Bulk downgrading of many packages can be largely automated using standard tools like awk and grep. For example, If you know that the jessie-backports upgrades you installed were all done on a particular day (e.g. 2016-02-15), then you can downgrade to the previous versions with something like:

 apt-get -d -u install $(awk '/2016-02-15 ..:..:.. upgrade / {print $4 "=" $5}'

(line-feed and indentation added to avoid horizontal scroll-bar)

NOTE the use of the -d (--download-only) option. Re-run the command and remove that option after you've verified that the apt-get install will do what you want, and ONLY what you want.

I would also recommend running only the awk portion of that command by itself first so you can see a list of exactly which packages and versions will be re-installed.

  • 1
    by 'largely automated' I mean that while it will mostly work without problems, it doesn't/won't always run perfectly (depending on the exact packages involved and their depends/recommends/conflicts/etc lines). There may be one or two packages you have to manually install or uninstall with either apt-get or dpkg. As long as you don't panic, there is nothing to worry about. Most problems with packaging systems are caused by people panicking and reacting without thinking....take it slowly and think before you act.
    – cas
    Commented Feb 16, 2016 at 2:18
  • Should not he pin the new kernel packages to backports @cas? Commented Feb 16, 2016 at 3:24
  • It wouldn't hurt but it's not necessary, and pinning is quite a bit more complicated and difficult to get right than just setting the Apt::Default-Release. apt-get won't downgrade an already installed package unless you explicitly tell it to. And @richard said he wanted to install jessie packages by default unless he explicitly specified jessie-backports - i assume that wish applies to kernel packages too.
    – cas
    Commented Feb 16, 2016 at 3:35
  • he said he included backports to have a new kernel, probably like me, to have kernel 4 in jessie. Commented Feb 16, 2016 at 3:37
  • 1
    I guess that people who use stable + stable-backports probably care a lot more about pinning than I do and have put in the effort to learn more about it. I tend to run unstable and keep my systems synced up the latest sid fairly regularly (with occasional extras from experimental), so have little need for pinning. The only time I used it heavily was years ago during the transition to gnome3, when I didn't want my gnome2 packages being replaced - i remember that maintaining the constantly changing list of packages to pin was a PITA. I've since switched to xfce and purged gnome.
    – cas
    Commented Feb 16, 2016 at 3:53

It sounds like you have not properly setup /etc/apt/preferences. The following will prevent anything from being installed from jessie-backports expect what tell it to install (such as the backported kernel). You will still have issues if the specified packages require other packages from backports that are not listed.

Package: *
Pin: release n=jessie-backports
Pin-Priority: -1

Package: *
Pin: release n=jessie
Pin-Priority: 1000

# this will allow you to not have to use '-t jessie-backports install'
Package: linux-doc linux-headers-amd64 linux-image-amd64 linux-source
Pin: release n=jessie-backports
Pin-Priority: 1000

If you wish to get a list of backported packages installed you can use the following script (or parts of it):

chmod a+x name_of_script ./name_of_script > name_of_output_file


echo  "Searching for installed packages from" >&2
echo $RELEASES | sed s/^/" * "/ | sed s/\|/"\n * "/g >&2

for package in $(dpkg -l | grep -i ^ii | awk '{print $2}')
check=$( apt-cache policy $package 2>&1 | grep -i -A 1 "[*]" | egrep $RELEASES )
if [ "$check" == "" ] ; then
 echo -ne "." >&2
 echo -ne "#" >&2
 apt-cache policy $package
echo >&2

If you want to downgrade any packages listed by the above script append the following to /etc/apt/preferences:

Package: package1 package2 package3
Pin: release n=jessie
Pin-Priority: 1000

Then run:

sudo apt-get upgrade

Check your pinning configuration for apt in /etc/apt/preferences and /etc/apt/preferences.d/

Is it possible you might have added a custom pinning configuration and forgotten about it? That's the only way I can think of that would make apt prefer backports as it seems to be doing to you. Otherwise, it's just pulling dependencies - which the packages you specified require.

Official backports are already pinned lower (100) than jessie in the backported packages Release file in the backports repo. You should not have to do any apt configuration to make apt prefer jessie over jessie-backports.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .