Apt - preventing certain package updates

From lxadm | Linux administration tips, tutorials, HOWTOs and articles
Jump to: navigation, search

If you run apt-get dist-upgrade (or apt-get upgrade), but would like to exclude some packages from upgrades, you can use "dpkg --set-selections".

For example, we'd like to leave redis-server not upgraded:

# echo "redis-server hold" | dpkg --set-selections


To verify it's really on hold:

# dpkg --get-selections | grep redis-server
redis-server                                    hold


Then, try to run apt-get dist-upgrade. You should see that redis-server package has been kept back. Any related packages may also be kept back, for example:

The following packages have been kept back:
  redis-server redis-tools


To remove the hold and let apt/dpkg upgrade the packages again:

# echo "redis-server install" | dpkg --set-selections


To verify it's no longer on hold:

# dpkg --get-selections | grep redis-server
redis-server                                    install