How to install a single package from a newer distribution on Ubuntu

Short answer: apt pining

In the following example, I will install jdupes from Focal on Eoan.

  1. edit source.list ​​sudo gedit /etc/apt/sources.list and add focal repository

  2. add pining policy sudo gedit /etc/apt/preferences.d/fetchupdate-or-any-other-name.pref

Package: *
Pin: release n=focal
Pin-Priority: 10

Package: jdupes
Pin: release n=focal
Pin-Priority: 500

3. sudo apt-get update

4. Check if pining works apt-cache policy jdupes

~$ apt-cache policy jdupes
jdupes:
  Installed: 1.13.2-1
  Candidate: 1.14.0-2
  Version table:
     1.14.0-2 500
          1 https://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
 *** 1.13.2-1 500
        500 https://archive.ubuntu.com/ubuntu eoan/universe amd64 Packages
        100 /var/lib/dpkg/status

Note that *** marks the currently installed package and "1" before the url is not final. It seems the number after the version number is the final pin-priority and "Candidate" is the final select.

Please also check another package, for example tracker, to verify that other package from focal repository is not selected.

5. sudo apt install jdupes

Last updated