How to prevent updating of a specific package?

Because of bug #693758 I'd like to prevent apt-get upgrade and Update Manager from updating the "libgtk2.0-0" package.

How can this be achieved?


Solution 1:

Holding

There are different ways of holding back packages: with dpkg, apt, dselect, aptitude or Synaptic.

dpkg

Put a package on hold:

echo "<package-name> hold" | sudo dpkg --set-selections

Remove the hold:

echo "<package-name> install" | sudo dpkg --set-selections

Display the status of all your packages:

dpkg --get-selections

Display the status of a single package:

dpkg --get-selections <package-name>

Show all packages on hold:

dpkg --get-selections | grep "\<hold$"

apt

Hold a package:

sudo apt-mark hold <package-name>

Remove the hold:

sudo apt-mark unhold <package-name>

Show all packages on hold:

sudo apt-mark showhold

dselect

With dselect, enter the [S]elect screen, find the package you wish to hold in its present state and press = or H. The changes will take effect immediately after exiting the [S]elect screen.


The following approaches are limited in that locking/holding a package within aptitude or synaptic doesn't affect apt-get/apt.

aptitude

Hold a package:

sudo aptitude hold <package-name>

Remove the hold:

sudo aptitude unhold <package-name>

Locking with Synaptic Package Manager

Go to Synaptic Package Manager (System > Administration > Synaptic Package Manager).

Click the search button and type the package name.

When you find the package, select it and go to the Package menu and select Lock Version.

Synaptic menu

That package will now not show in the update manager and will not be updated.

Solution 2:

I was looking for the same thing and after a lot of research I found that using the following syntax you can forbid one specific version but allow the next update:

Package: compiz-plugins-main
Pin: version 1:0.9.7.0~bzr19-0ubuntu10.1
Pin-Priority: -1

This goes into the /etc/apt/preferences file.

Solution 3:

To put a package "foo" on hold:

echo "foo hold" | dpkg --set-selections

In your case we are going to put wine on hold:

sudo -i
echo "wine hold" | dpkg --set-selections

To remove the hold:

sudo -i
echo "wine install" | dpkg --set-selections

Solution 4:

Install synaptic using sudo apt-get install synaptic.

Run using gksudo synaptic and on the search box locate the package you want to lock, ie: gedit

enter image description here

From the package menu select Lock version:

enter image description here

And that is all, the version currently installed at the time of the lock will stay installed even during upgrades.