Lock packages
This page was last updated on July 18, 2009.
Introduction
Sometimes you’d like to lock a package at a specific version and not allow it to be updated. This document shows how that can be done (and undone). The package will not be updated unless you manually unlock it, or update Ubuntu or Kubuntu to a new release.
Check the dependencies of the package
- Please be careful when deciding to lock a package. Do some research to be sure doing so won’t negatively impact the rest of the system. If other programs depend on the file, they may not run properly, or at all, with a file that isn’t current. To get detailed information about a package, including its dependencies and reverse dependencies, type this command in a terminal window, replacing XXX with the name (the version number is not needed) of the package:
-
apt-cache showpkg XXX
Check the status of the package
The “Status” line tells you whether the package is installed or not. It also tells you if the package is locked. An unlocked package will show as “Status: install ok installed” and a locked package will show as “Status: hold ok installed”.
- To check the status of a package, type this command in a terminal window, replacing XXX with the name (the version number is not needed) of the package you wish to lock:
dpkg -s XXX | grep Status
- Example
- Type this command:
dpkg -s amarok | grep Status
- The status line you’ll see if the package isn’t locked:
Status: install ok installed
Status: hold ok installed
Lock the package
- Type this command in a terminal window, replacing XXX with the name of the package you wish to lock:
-
echo "XXX hold" | sudo dpkg --set-selections
Unlock the package
- You can unlock any package you’ve locked when/if you decide you’d like to let it update to the latest version. Type this command in a terminal window, replacing XXX in this example with the name (the version number is not needed) of the package you wish to unlock:
-
echo "XXX install" | sudo dpkg --set-selections
Obligatory Happy Ending
And they all lived happily ever after. The end.
