How to backport packages on Ubuntu Linux

Backporting is a process to get new package releases to run on non-latest Linux distribution versions. A very common backporting use case is to enable the latest version of application or software library on a server running the older version of the operating system.

Ubuntu has a default backports repository where community maintained backports go. However if you do not find the package you are looking for there creating your own backported package is easy.

1. Rationale for doing backports

Old stuff is old

I did not know how relative pain free it was backporting packages on Ubuntu. This clearly increases my preference for doing backports instead of hand crafted software builds when putting together my software stack.

For backports:

  • They integrate well with the OS package manager – you can update and uninstall backported packages with the package manager.
  • Ubuntu has one-liner command which will do the backporting for you after you have registered in launchpad.net community. It’s even less effort than make install.
  • Backports come with distribution specific patches, start-up files and file locations.
  • Common good windfall will follow as others can use the package you have backported.

I wrote this blog post as notes when I did my first backport for nullmailer which is a lightweight SMTP slave and mail command backend. Ubuntu 12.04 LTS ships with nullmailer version 1.05 and support for SSL servers was added in version 1.10. (For more context please ee my previous blog post of how I have been using nullmailer with Gmail).

Note that in this blog post I only consider backports which compile as is. If the package needs source code changes then your road will be more bumpy.

2. Starting backporting process

Launchpad is the infrastructure tool orchestrating Ubuntus together. First register an account at launchpad.net. Then, on your personal page Click Create new PPA on your launchpad.net account page. PPA archive is the online repository where the resulting backported package will be placed.

Login to the box running the old target release of Ubuntu (12.04 Server LTS in my case).

Install Ubuntu development tools ubuntu-dev-tools package which comes with various automatication scripts, including backporttool. Note: hefty 100 MB with dependencies.

sudo apt-get install ubuntu-dev-tools gnupg-agent

3. Creating a PGP key using GNUPG in terminal

Launchpad infrastructure uses PGP / GNUPG keys for signing releases. Unfortunately I am not running Ubuntu on my desktop computer, so I couldn’t use easy desktop tools to work with PGP. Instead, I had to work within a terminal in ssh session to a Ubuntu server.

First create a PGP key, unless you have one already, to be used to sign the package releases on launchpad.net. You can do this in terminal on the server. I protected my key with a passphrase which I stored in KeePassX archive in Dropbox:

# Note: The RNG trick here is needed when doing
# thison the server because key generation
# needs entropy and Ubuntu server does not have rng
# daemon enable by default 

apt-get install rng-tools
gpg --gen-key # Use defaults
# Wait until gpg command asks for "more entropy"
# Press CTRL+Z
bg # Leave gpg on background
sudo rngd -r /dev/urandom

# GPG reports its done
# Interrupt rngd with CTRL+C

# A lot of files gets generated in ~/.gnupg folder

# Start GPG agent, so it will be asking the passpharse only once
eval $(gpg-agent --daemon)

# Get your key id (looks like ABC1234)
gpg --fingerprint

# Make backportpackage command to use your key
echo DEBSIGN_KEYID=AEA22323 >> ~/.devscripts

# Register your key with Ubuntu key server 
gpg --send-keys --keyserver keyserver.ubuntu.com AEA22323

Now, go to your launchpad.net account and Edit PGP keys section. In Import an OpenPGP key give they key fingerprint as printed above by gpg –fingerprint. launchpad.net will send you a confirmation email with content like below:

-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.10 (GNU/Linux)

hQEMAyYFaWv6mn/LAQf/cRHso6ps1yArBFGW5Z29/xmPwf70mRdzkLtKQdfVBuQh
* snip *
QgxREGLU/Gi4kGRaHF/KmG7d0kPmVUNZk9OLD/jwQUXQtXQWPvRthyI=
=+Syx
-----END PGP MESSAGE-----

In Terminal, which is still running your GPG agent, run the command:

gpg -d

Paste in the message, including — — lines. You will be asked your key passphrase. Press CTRL+D to terminate the input. Now the secret confirmation link is printed to your terminal:

...
Please go here to finish adding the key to your Launchpad account:

    https://launchpad.net/token/xyz

4. Running backportpackage command

Now you can run backportpackage command. It is fully automated tool to create a backport .deb archive for any existing Ubuntu package. Below I run the command for nullmailer package.

# Set your personal details (go into the package)
export DEBFULLNAME="Mikko Ohtamaa"
export DEBEMAIL="mikko@opensourcehacker.com"
export UBUMAIL="mikko@opensourcehacker.com" 

# Backport my package please!
# PPA was created in launchpad.net web interface beforehand
backportpackage -u ppa:mikko-red-innovation/ppa nullmailer

backportpackage will

  • download the latest version of the package from Ubuntu archives. The latest version must exist in the some newer Ubuntu releases – backporting process does not consider upstream releases
  • attempts to build it
  • uploads the resulting .deb to your personal PPA archive on launchpad.net

In the end here is the sign of the success:

Uploading nullmailer_1.11-2~precise1~ppa1_source.changes: done.
Successfully uploaded packages.

If you are doing this for the first time it will take some time (under ~30 minutes in my case) to get your package accepted in your PPA. You’ll get an automatic notification email when it happens. If it doesn’t happen see the troubleshooting links below.

5. Using and testing your backported package

After you have backported the package successful it is good to go for other your servers as is. You can install the package on the same server you did the backporting or some another server (of same Ubuntu version).

Register your own PPA as the package source for your server:

sudo apt-add-repository ppa:mikko-red-innovation/ppa
apt-get update

Check that your own package with a custom version become available:

apt-cache show nullmailer

Package: nullmailer
Priority: extra
Version: 1:1.11-2~precise1~ppa1
...

Package: nullmailer
Version: 1:1.05-1
....

Install the package you just backported with a specific version string

apt-get install nullmailer=1:1.11-2~precise1~ppa1

… and your server now has the latest version.

6. More information

Information bits needed to pull this together

 

 Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

4 thoughts on “How to backport packages on Ubuntu Linux

  1. Pingback: Using Nullmailer and Mandrill for your Ubuntu Linux server outboud mail

  2. Pingback: 把 Open vSwitch 1.10 backport 到 Ubuntu Raring (13.04) | 攻城雜記

  3. Hi,

    Thanks for this.

    I’m trying to use a local pbuilder not a ppa one and continue to failed!

    Maybe you could tell me what I’m doing wrong here?

    The problem is that the pkg I need is coming from version 14.04 and i run 12.04
    So I dget the foo.dsc and try to build it using pbuilder, but the foo.dsc needs some other pkgs version which are no exits in the verion 12.04,
    so it failed.
    I started to download each required pkg (bar.dsc, zoo.dsc, etc…) that foo was depend on, but then got to a endless loop, since bar.dsc also wanted some pkg that where missing in the 12.04.

    So I play a little with the control file of the foo pkg, and got to a point where I had only 4 pkg that need to come from version 14.04 to version 12.04.
    I manage to build them, and also create a local repo, so the base image of pbuilder will be aware of them.

    Then try to build the foo.dsc and failed again.
    What am I’m doing wrong?

    It’s being a week already without any sleep – and I just can’t figure it out.

    Help will be most welcome!

    Thank
    Sassy

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>