How to exclude a package from a specific repository only in yum?
Posted on In QA, TutorialThis post https://www.systutorials.com/1661/making-dnf-yum-not-update-certain-packages/ introduces how to exclude a package from yum
.
But is it possible to exclude a package from a specific repository only?
For example, a repository R1 I am using contains an updated version of gdb
while I don’t want to use the gdb
from it as I trust the version (although older) from the official OS repository. How to make yum update
not update gdb
from the repository R1?
exclude=...
can also be used in each repository’s .repo
file under /etc/yum.repos.d
.
For the above example, you can add
exclude=gdb
to
/etc/yum.repos.d/R1.repo
under the enabled (enabled=1
) sections.
Example:
[epel] name=Extra Packages for Enterprise Linux 7 - $basearch metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 exclude=gdb
This doesn’t work for me in CentOS 7.4 All the entries in the repo file are key value pairs : . There aren’t any “=” signs in the repo files.
Can you show the content of any one file such as
cat /etc/yum.repos.d/CentOS-Base.repo
?The system is on my employers network , which I won’t be connected to for a few days. I have a CentOS 7.7 VM at home and repeated the steps to exclude a package ( this case postgresql ) and it worked as expected by excluding postgresql from base and updates packages ( see .repo file contents at the bottom of this post ) .
I also noted that my VM’s CentOS-Base.repo file had = formatting instead of my employer’s system’s : format .
My employer has a lot of customer internal repos and automation around configuration management. What might be happened is the .repo files yum.repos.d might either not be used, or if used, overridden by files in another location. I’ll check the yum.confg for the reposdir ( just learned that exists! ) parameter to see of that it the case.
My ( not my employers ) CentOS-Base.repo file contents –
[base]
name=CentOS-$releasever – Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
exclude=postgresql*
#released updates
[updates]
name=CentOS-$releasever – Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
exclude=postgresql*
#additional packages that may be useful
[extras]
name=CentOS-$releasever – Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever – Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
The parser messed up my post because I used greater than less than characters. Here it is again – My repo format: (key)=(value) . My employers repo format (key):(value) .