Linux – apt-get upgrade with exceptions

aptlinuxUbuntuupdateupgrade

I am running Ubuntu 14.04 and have let it get quite out of date with packages that need updating.

There are a couple of packages I don't want to upgrade like tomcat, php etc.. but I am not sure how I can run a blanket apt-get upgrade to upgrade everything except those packages. Most of the documentation and suggestions I can find only explain how to update specific packages, not the other way around..?

Thanks

Best Answer

What you want is "package pinning" -- essentially, telling apt, "I want to keep this package at this version". For a simple single-package pin, add this to /etc/apt/preferences (or in a new file in /etc/apt/preferences.d):

Package: tomcat8
Pin: version 8.0.14-1
Pin-Priority: 1001

Specify the package name you want, and the version you want to pin it to, and make sure the Pin-Priority is over 1000. Then the package will basically never, ever move from its current version.

You can do trickier things, like pinning to a release (trusty rather than trusty-updates, for example), selecting lots of packages with a glob pattern, and only letting packages update if they're security updates. See apt_preferences(5) for all the gory details.