💻 syscmds.net

Restricting Packages in DNF Repositories

Sometimes it is necessary to use software repositories that contain the same software, but the versioning or the packaging is different. In this case it can be helpful to modify the repository configuration to restrict or exclude packages.

First find the repository that you want to modify. The configuration files for the different repositories can be found in /etc/yum.repos.d/

Including a specific package

Sometimes it is helpful to scope a repository to a specific package. This can be achieved with the includepkgs option. Here is an example for restricting elrepo to just the wireguard pacakges.

[elrepo]
name=ELRepo.org Community Enterprise Linux Repository - el8
baseurl=http://elrepo.org/linux/elrepo/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el8
enabled=1
includepkgs=*wireguard*
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

Excluding a package

The excludepkgs option can be used to exclude packages from a repository. Here is the sample example again, but this time excluding wireguard.

[elrepo]
name=ELRepo.org Community Enterprise Linux Repository - el8
baseurl=http://elrepo.org/linux/elrepo/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el8
enabled=1
excludepkgs=*wireguard*
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

Sometimes it might be that a package has been excluded to allow for manual controlled updates. In this case, it is not necessary to edit the config everytime an update is desired. Instead the disableexcludes switch can be used.

$ dnf --disableexcludes update wireshark

If the same package has been excluded across multiple repositories, then a manual update can still be achieved with only a specific repository enabled.

$ dnf --enablerepo=elrepo --disableexcludes update wireshark 

More Information

For further information on configuring repositories see the dnf man pages. Type man dnf.conf for repository configuration or man dnf for dnf usage.

Last Modified:
Tags: dnf, yum