How to install packages from newer Ubuntu releases

Posted . Visible to the public.

We're usually running Ubuntu LTS versions. Sometimes newer hardware requires packages from more recent Ubuntu releases that only come with 6 months of support. If there is really no other way, it's possible to install packages from later Ubuntu releases

Caution: Pay really close attention to what you're doing. Depending on the package, this process may require upgrading a lot of dependencies, possibly breaking the system! You really should not do this unless you've carefully calculated the impact on your system

Preparation

First, do a system update to make sure there's not going to be confusion later as to what are regular updates and what is package installation from another release: sudo apt-get update && sudo apt-get dist-upgrade -u.

Create a new sources.list.d entry for a newer Ubuntu release. At the time of writing this, the current LTS version is 16.04 (xenial).

  • yakkety (16.10)
  • zesty (17.04)
  • artful (17.10)
  • don't bother with artful because that's going to be an LTS release and it might be safer to just upgrade your whole system or wait for an updated HWE stack to come to xenial.

Example for /etc/apt/sources.list.d/yakkety.list:

deb http://de.archive.ubuntu.com/ubuntu/ yakkety main restricted universe multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety main restricted universe multiverse
deb http://de.archive.ubuntu.com/ubuntu/ yakkety-updates main restricted universe multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety-updates main restricted universe multiverse
deb http://de.archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu yakkety-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu yakkety-security main restricted universe multiverse

Next, create /etc/apt/preferences.d/yakkety to set up Apt-Pinning, i.e. setting your system to give packages from yakkety a lower score when considering package upgrades, so you have to manually specify you want to install packages from there:

Package: *
Pin: release v=16.10, -l=Ubuntu
Pin-Priority: 10

Next, run sudo apt-get update to re-load your package management database and check if your setup worked. Running sudo apt-get dist-upgrade -u should yield no pending upgrades if you ran an upgrade during the initial steps of this card.

You may check if the new sources are recognized, though: apt-cache policy vim:

vim:
  Installed: 2:7.4.1689-3ubuntu1.2
  Candidate: 2:7.4.1689-3ubuntu1.2
  Version table:
     2:7.4.1829-1ubuntu2.1 10
         10 http://de.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 Packages
         10 http://security.ubuntu.com/ubuntu yakkety-security/main amd64 Packages
     2:7.4.1829-1ubuntu2 10
         10 http://de.archive.ubuntu.com/ubuntu yakkety/main amd64 Packages
 *** 2:7.4.1689-3ubuntu1.2 500
        500 http://de.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
        100 /var/lib/dpkg/status
     2:7.4.1689-3ubuntu1 500
        500 http://de.archive.ubuntu.com/ubuntu xenial/main amd64 Packages

As you can see, the latest version 7.4.1829 is on top but it's prefixed with a 10 for its score. The package prefixed with the *** has a lower version number but a higher score of 500 and comes from xenial-updates.

Planning the upgrade

I recommend using aptitude for dealing with upgraded packages since it allows for easier dependency handling and conflict resolution. If you don't have it, install it: sudo apt-get install aptitude.

  • Run sudo aptitude
  • Search for the package you want to upgrade by pressing / (search hotkey( and entering the package name, e.g. modemmanager.
  • When it's highlighted, press Enter to view its details and scroll all the way to the bottom to Versions of modemmanager.
  • The one prefixed with i is currently installed, p means purged, i.e. not installed and no config files on the system. You should see one package version below the currently installed one that has a higher version number.
  • Scroll to the version with the highest number and press +. Most likely, it will light up red because of version conflicts. This is to be expected.
  • aptitude has calculated possible resolutions to the version conflicts. Press e to enter conflict resolution mode.
  • Check out the different solutions by reviewing what's shown on top and pressing . to view the next resolution and , for viewing the current resolution. If you're satisfied with one resolution, press ! when viewing it.
  • As a rule, you should pick the resolution that does the minimum amount of changes to your system while still achieving the desired result.
  • Note: it's not always possible to reach an acceptable resolution of version dependencies! Too many upgrades or package removals may very well damage your current installation, requiring manual fixing of the resulting mess.

Doing the upgrade

If you're done reviewing different solutions and have picked one with !, the next step is to press g for performing scheduled actions. You'll get another chance to review what's about to be done on your system. If you're satisfied with that, press g. If you want out, press q and q again to exit aptitude.

After the upgrade procedure has ran, depending on which and how many packages you upgraded, it might be a wise idea to reboot, to make sure all the upgraded libraries are loaded, to avoid conflicts between old versions still in memory because they're used by daemons and new versions on disk. This is not usually a big problem with upgrades because it's only minor changes but when installing major upgrades it's a good idea.

Test your system after the upgrade! If you want back for some reason, you'll have to dig in /var/log/apt/history.log, pick out which packages got updated and downgrade those manually in aptitude.

Emma Heinle
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Emma Heinle to makandra dev (2017-10-06 07:44)