Howto: Install New Yum Repositories in Fedora/Redhat

Please note the below also works for Centos.Redhat Logo

There are a acouple of ways of adding repositories in Fedora/Red Hat. All repositories are stored in the /etc/yum.repos.d directory in Fedora/Redhat.
For well known repositories it is best and more simpler to install a .rpm package to add the repositories to your system. Such as below, which will add the livna-release repositories to your system. You would substitute the URL with one you have found on the internet.

rpm -Uvh http://ftp-stud.fht-esslingen.de/pub/Mirrors/rpm.livna.org/livna-release.rpm

For repositories that need to be installed manually it is a little bit different we have to create a .repo file as found in the /etc/yum.repos.d directory. For the below example lets make it that you found and want to install a repository from samplerepo.joshuarasnier.com following would be the steps needed to carry this out:

# cd /etc/yum.repos.d 
# vi samplerepo.repo

Append the following in the samplerepo.repo file.

[samplerepo.repo]
name=Samplerepo $releasever - $basearch
#baseurl=http://samplerepo.joshuarasnier.com/fedora/$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-samplerepo-$basearch

Save and close the file.

See below information on the options used in the .repo file. Where,

  • [samplerepo] – The Repository name
  • name=Samplerepo $releasever – $basearch – A human readable description of the repo.
  • baseurl=http://samplerepo.joshuarasnier.com/fedora/$releasever/$basearch/ – Must be a URL to the directory where the yum repository’s ‘repodata’ directory lives
  • enabled=1 – Enabled or disabled repo. To disable the repository temporarily, set enabled to 0
  • gpgcheck=1 – Security feature, use GPG key
  • gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-samplerepo-$basearch – GPG license location

You also need to import the GPG keys for the repository. The GPG key is used as a signature, so that you and the system can check the authenticity of the repository. As follows is how to get the GPG key:

# rpm --import http://samplerepo.joshuarasnier.com/RPM-GPG-KEY.txt

Your repository should now be installed. If you have enabled the repository you can check with:

# yum repolist enabled

If you have it disabled, you can check with:

# yum repolist disabled

Be First to Comment

    Leave a Reply