To upgrade nearly all packages with apt-get but “hold” some of them at the current version, you can use dpkg.
Let’s say I would like to upgrade my Debian or Ubuntu system with apt-get and here is what I’m getting:
% sudo apt-get upgrade
[...]
apt apt-transport-https apt-utils ghostscript ghostscript-cups ghostscript-x google-chrome-beta hal indicator-applet
nvidia-current-modaliases php-pear php5 php5-cli
If I don’t want to upgrade php5 package I can “hold” it:
- Switch to root (su or sudo -s)
- Execute:
echo php5 hold | sudo dpkg --set-selections
That’s it – after running apt-get upgrade again, the package will be “kept back”:
% sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
php5
To make the package installable again:
echo php5 hold | sudo dpkg --set-selections