Fedora 24: 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 "dnf –exclude" and /etc/dnf/dnf.conf.

 

1 dnf –exclude

Set excluded package to dnf –exclude option. You can set multiple packages with double quotes. To exclude mc and emacs is as below.

$ # sudo dnf update --exclude="<package> [<package>...]"
$ sudo dnf update --exclude="mc emacs"

2 /etc/dnf.conf

Set excluded package to exlucde directive in etc/dnf/dnf.conf. You cannot use double quotes.

[main]
<snip>
exclude=<package> [<package>...]

To exclude mc and emacs is as below.

$ diff -uprN /etc/dnf/dnf.conf{.org,}
--- /etc/dnf/dnf.conf.org       2016-06-30 19:45:37.876541410 +0900
+++ /etc/dnf/dnf.conf   2016-06-30 19:53:29.486621755 +0900
@@ -2,3 +2,4 @@
 gpgcheck=1
 installonly_limit=3
 clean_requirements_on_remove=True
+exclude=mc emacs

3 Execution result

There is no excluded package in /etc/dnf/dnf.conf.

$ cat /etc/dnf/dnf.conf
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True

mc package is included in upgradable packages.

$ dnf check-update | grep "^mc"
mc.x86_64                                   1:4.8.15-2.fc24             fedora

Exclude mc package in /etc/dnf/dnf.conf.

$ sudo su -c 'echo exclude=mc >> /etc/dnf/dnf.conf'
$ cat /etc/dnf/dnf.conf
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
exclude=mc

A mc package is removed from upgradable packages.

$ dnf check-update | grep "^mc"
$ # mc is not included in update packages.