Ubuntu 16.04: Exclude package from update

You might want to keep package version because updating it brokes something.

This article will describe how to exclude package from update.

There are two ways of "apt-mark hold" and "dpkg –set-selections".

 

1 apt-mark hold/unhold

apt-mark enables to hold package. This means that package does not be updated.

Hold package as below.

$ sudo apt-mark hold <package>

Release hold package as below.

$ sudo apt-mark unhold <package>

Check hold package as below.

$ apt-mark showhold
llvm

2 dpkg –set-selections/–get-selections

dpkg –set-selections can do same hold as apt-mark.

Hold package as below.

$ echo "llvm hold" | sudo dpkg --set-selections

Release hold package as below.

$ echo "llvm install" | sudo dpkg --set-selections

Check hold package as below.

$ dpkg --get-selections | grep 'hold$'
llvm                                            hold

3 Execution result

Hold llvm package.

$ sudo apt-mark hold llvm
$ apt-mark showhold
llvm

Upgradable packages includes llvm package.

$ apt list --upgradable
<snip>
linux-libc-dev/xenial-updates,xenial-security 4.4.0-28.47 amd64 [upgradable from: 4.4.0-24.43]
llvm/xenial-updates 1:3.8-33ubuntu3.1 amd64 [upgradable from:1:3.8-33ubuntu3]
llvm-dev/xenial-updates 1:3.8-33ubuntu3.1 amd64 [upgradable from:1:3.8-33ubuntu3]
llvm-runtime/xenial-updates 1:3.8-33ubuntu3.1 amd64 [upgradable from: 1:3.8-33ubuntu3]
lsb-base/xenial-updates,xenial-updates 9.20160110ubuntu0.1 all [upgradable from: 9.20160110]
<snip>

Upgrade packages.

$ sudo apt upgrade -y

Though upgrade was run, llvm is still included in upgradable packages.

$ apt list --upgradable
Listing... Done
llvm/xenial-updates 1:3.8-33ubuntu3.1 amd64 [upgradable from: 1:3.8-33ubuntu3]
llvm-dev/xenial-updates 1:3.8-33ubuntu3.1 amd64 [upgradable from: 1:3.8-33ubuntu3]
llvm-runtime/xenial-updates 1:3.8-33ubuntu3.1 amd64 [upgradable from: 1:3.8-33ubuntu3]
$