apt / downgrading back to current release

apt / downgrading back to current release

  • Written by
    Walter Doekes
  • Published on

If you're running an older Debian or Ubuntu, you may sometimes want to check out a newer version of a package, to see if a particular bug has been fixed.

I know, this is not supported, but this scheme Generally Works (*):

  • replace the current release name in /etc/apt/sources.list, with the next release — e.g. from bionic to focal
  • do an apt-get update
  • and an apt-get install SOME-PACKAGE

You can test the package while replacing the sources.list with the original so the rest of the system doesn't get upgraded by accident. (Don't forget this step.)

(*) Except for the rare case when it doesn't work, because of ABI changes in a library that were not properly recorded.

Once you know whether you want this newer package or not, you can decide to get your system back into original state. This is a matter of downgrading the appropriate package(s).

For example:

# apt-cache policy gdb
gdb:
  Installed: 9.2-0ubuntu1~20.04
  Candidate: 9.2-0ubuntu1~20.04
  Version table:
 *** 9.2-0ubuntu1~20.04 100
        100 /var/lib/dpkg/status
     8.1.1-0ubuntu1 500
        500 http://MIRROR/ubuntu bionic-updates/main amd64 Packages
     8.1-0ubuntu3 500
        500 http://MIRROR/ubuntu bionic/main amd64 Packages
# apt-get install gdb=8.1.1-0ubuntu1
The following packages will be DOWNGRADED:
  gdb
Do you want to continue? [Y/n]

If you use apt-find-foreign you might notice there are a bunch of packages that need downgrading back to the original state:

# apt-find-foreign
Lists with corresponding package counts:
  22  (local only)
  296 http://MIRROR/ubuntu

Lists with very few packages (or local only):
  (local only)
    - binutils
    - binutils-common
    - binutils-x86-64-linux-gnu
    - gcc-10-base
    - gdb
    - libbinutils
    - libc-bin
    - libc6
    - libc6-dbg
    - libcrypt1
    - libctf-nobfd0
    - libctf0
    - libffi7
    - libgcc-s1
    - libidn2-0
    - libncursesw6
    - libpython3.8
    - libpython3.8-minimal
    - libpython3.8-stdlib
    - libreadline8
    - libtinfo6
    - locales

Looking up the right versions for all those packages we just dragged in, sounds like tedious work.

Luckily we can convince apt to do this for us, using a temporary /etc/apt/preferences.d/force_downgrade_to_bionic.pref:

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

With priority 1000, apt will prefer the Bionic release so much that it suggests downgrades:

# apt-get dist-upgrade
The following packages will be REMOVED:
  libcrypt1 libctf0
The following packages will be DOWNGRADED:
  binutils binutils-common binutils-x86-64-linux-gnu gdb libbinutils
  libc-bin libc6 libc6-dbg libidn2-0 libpython3.8 libpython3.8-minimal
  libpython3.8-stdlib locales
Do you want to continue? [Y/n]

Make sure you remove force_downgrade_to_bionic.pref afterwards.


Back to overview Older post: k8s / lightweight redirect