Pin down the oficial Firefox version in Ubuntu

Today, I'll write an article about a more complicated administration tool: APTs pinning.

What is pinning?

Pinning is used to prevent your Ubuntu system to upgrade a package to a higher version through its automatic update system.

Why do you want to prevent an update?

Well, maybe the newer version of an application isn't working the way you want to or is buggy and you prefer to use the older version.

In my example, this happened to me with Firefox. The version 3.5 that ships with the official Ubuntu repositories works perfect.
But as I enabled the Mozilla-Daily repository from Launchpad to install the better Thunderbird 3.0 (see my article about installing it), that same repository also holds a newer version from Firefox. So my system all the time tries to upgrade to the version from Launchpad, which works worse for me.

How could I prevent upgrading Firefox from that repository, but still be able to use and update my Thunderbird 3.0 package from that one?

Obtain list of priorities

After searching through several articles and forum post, finally I found the tool I needed to setup the pinning.
apt-cache policy
apt-cache policy firefox-3.5

Whereas the first command shows a list of all your enabled repositories and their priorities, the second one gives you information about a concrete package.

In my case it shows:
Installed: 3.5.4+nobinonly-0ubuntu0.9.10.1
Candidate: 3.5.5+nobinonly-0ubuntu0.9.10.1
Version table:
3.5.6~hg20091129r26611+nobinonly-0ubuntu1~umd1~karmic 0
50 karmic/main Packages
3.5.5+nobinonly-0ubuntu0.9.10.1 0
500 karmic-updates/main Packages
500 karmic-security/main Packages
*** 3.5.4+nobinonly-0ubuntu0.9.10.1 0
100 /var/lib/dpkg/status
3.5.3+build1+nobinonly-0ubuntu6 0
500 karmic/main Packages

You can see the installed version is 3.5.4, there is a newer version 3.5.5 from the official Ubuntu repositories, and a newer version 3.5.6 from the Luanchpad repository.
Interesting to look at is the Candidate: line, which shows the version that will be installed next by the update mechanism. Normally, this would be 3.5.6, but in my case, I lowered the priority of the Launchpad repository to 50, which is lower than the default, so it is not selected any more.

You want to know how this is possible? Read on.

Use pinning to lower upgrade priorities

The trick lays inside the /etc/apt/preferences, use man apt_preferences to read more about it.
Just execute the following instruction:

sudo echo "Package: *
Pin: release o=LP-PPA-ubuntu-mozilla-daily
Pin-Priority: 50" > /etc/apt/preferences.d/Mozilla-Daily

## or if that doesn't work for you (tried it only on Karmic):
sudo echo "Package: *
Pin: release o=LP-PPA-ubuntu-mozilla-daily
Pin-Priority: 50" > /etc/apt/preferences

sudo apt-get update

How to obtain the correct values

Remember the apt-cache policy command? Searching its output, you find the information:
 500 karmic/main Packages
release v=9.10,o=LP-PPA-ubuntu-mozilla-daily,a=karmic,n=karmic,l=Ubuntu,c=main

From the release line I just selected the o=LP-PPA-ubuntu-mozilla-daily, enough to clearly select which packages will be pinned.

After the apt-get update, you will not be troubled any longer by the firefox updates from that repository, but the thunderbird-3.0 updates will still show up, because it doesn't exist in the official repositories.


I run into some trouble and will share the solutions here as well.

Can't find the o=LP-PPA-ubuntu-mozilla-daily entry

This happened in one of my machines, so at the end I had to pin down the whole Launchpad repositories, not only the Mozilla-Daily one.
sudo echo "Package: *
Pin: origin
Pin-Priority: 50" > /etc/apt/preferences.d/Mozilla-Daily
sudo apt-get update

Firefox and/or xulrunner still update from Mozilla-Daily

That happens when some packages have been updated from the Mozilla-Daily repository before. You'll need to downgrade them to a version from the official repositories.
Here an example (find the correct version with the apt-cache policy command):
sudo aptitude install firefox-gnome-support=3.5.5+nobinonly-0ubuntu0.9.10.1