This article will show you how to set up repositories in YUM (Yellodog Updater Modified), the default package manager for Red Hat based Linux distributions. We will also discuss what the repositories are and why we need to set them up.
Dependencies among packages
Software packages in Linux often depend upon other packages to run correctly. For example, the gzip package, a compression/decompression utility, requires at least a shell (like ‘sh’ or ‘bash’) and the libc library to be installed. There are many gnome utilities, like gnome-terminal, gnome-system-monitor, gnome-panel and others that need gnome (the default graphical environment in many Linux, including RHEL).
So how does it affect anything? In the example above, gnome-terminal package will not be installed until all of its dependencies are installed (or resolved). These dependencies may have their own dependencies which may in turn have some more dependencies, and so on following a hierarchy of dependencies. Resolving these dependencies manually will take a lot of time and effort.
So where does YUM fit into the big picture? YUM resolves these dependencies for you, so installation of new packages is fast and easy.
The Software repositories
The repositories are a large collection or pool of software packages. YUM needs repositories to resolve dependencies and install packages. Many repositories are available on the internet. You may have your own repositories on your network. The repository information is contained in the xml files. These files are contained in a directory named 'repodata'. You don't need to bother about them as long as you are concerned with configuring YUM for these repositories. Updating these repository files is the task of the administrator. YUM uses these files for caching the repository information.
For the purpose of this article, RHEL-5.6-server is used.
The YUM configuration files are located in "/etc/yum.repos.d/" directory. The current files in the repository are:
[[email protected] ~]# ls -l /etc/yum.repos.d/
-rw-r--r-- 1 root root 561 Dec 14 2010 rhel-debuginfo.repo
-rw-r--r-- 1 root root 222 Dec 14 2010 rhel-source.repo
The repository configuration files must end with '.repo' as with the above two files. Let us check the layout of one of these files:
[[email protected] ~]# cat /etc/yum.repos.d/rhel-source.repo
[rhel-source] name=Red Hat Enterprise Linux $releasever - Source
• [repositoryid] : The first line, in square brackets is the unique ID for a repository. It must be different for each repository, and be of one word only.
• name: This is the description of the repository.
• baseurl: This is the location url to the repository. This is the path to 'repodata' directory. The repository can be an 'ftp' or 'http' repository. It can also be located on the machine itself (local repository).
• enabled: '1' value enables and '0' disables the repository.
• gpgcheck: Whether or not should yum check the gpg signature of the packages.
• gpgkey: Url to the gpg key file for repository. This option has no meaning if the above value of gpgcheck is '0' or if that entry is missing.
Adding your own repository
To add a yum repository, let us create a file named 'rhel-local.repo'. My repository is located in "/dump” directory locally.
[[email protected] ~]# cat > /etc/yum.repos.d/rhel-local.repo
[rhel-ftp] name=Local repository
[[email protected] ~]#
Here, we don't want to check the signature, so gpgcheck is '0'. If your repository is located at ftp or http or any other server, you just need to change the base url accordingly.
Now, to be sure that this repository is set up properly, you can run ‘yum list’ command which will list installed as well as available packages from the repository. The output of this command is very huge, so in the following command, results are filtered using ‘grep’ and ‘head’:
[[email protected] ~]# yum list | grep rhel-ftp | head
This system is not registered with RHN.
RHN support will be disabled.
Deployment_Guide-as-IN.noarch 5.2-11 rhel-ftp
Deployment_Guide-bn-IN.noarch 5.2-11 rhel-ftp
Deployment_Guide-de-DE.noarch 5.2-11 rhel-ftp
Deployment_Guide-es-ES.noarch 5.2-11 rhel-ftp
Deployment_Guide-fr-FR.noarch 5.2-11 rhel-ftp
Deployment_Guide-gu-IN.noarch 5.2-11 rhel-ftp
Deployment_Guide-hi-IN.noarch 5.2-11 rhel-ftp
Deployment_Guide-it-IT.noarch 5.2-11 rhel-ftp
Deployment_Guide-ja-JP.noarch 5.2-11 rhel-ftp
Deployment_Guide-kn-IN.noarch 5.2-11 rhel-ftp
Adding more repositories to Yum
Make your Yum more robust by adding more repositories like DAG, UPDATE and RPMforge. For adding extra repositories to yum perform the steps below:
#vi dag.repo // the add the following lines in that file//
[dag] name=Dag RPM Repository for Red Hat Enterprise Linux
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
After this, save the file and run the following command:
# yum check-update
Working with repositories in CentOS 7
You can find some of the most useful repositories on the list provided on the Available Repositories for CentOS webpage, with instructions on how to install them. For some of the repositories you will have to follow the instructions above and for others you will have to install a package like below:
For example, to install the most popular third-party repository, the EPEL (Extra Packages for Enterprise Linux), you can simply run the following command:
# yum install epel-release
And then the packages in the EPEL will be available on your system.
Keep in mind that you can always see a list of repositories used by your system by running the following command:
# yum repolist
Also, if you wish to search for a package in a particular repository you can use the following command:
# yum --disablerepo="*" --enablerepo="epel" search znc