YUM (Yellow dog Updater, Modifier)

Introduction

With Redhat Enterprise Linux 5, a new utility has been introduced. This is a work of few programmers from Duke university.

Imagine that we have to apply an rpm and we dont have yum. In that case we will start applying the rpm using “rpm” command and it gives a dependency error saying that some other files and rpm needs to be installed in order to install this main rpm. Then we will search for dependent rpm and try to apply those. What if those dependent rpms gives dependecy error again saying that some more rpms are required. What if this chain grows long? end result is we will end up totally frustrated and will forget which is our main rpm.

To deal with this kind of issue, yum was introduced. The main advantage of yum is the depenency check. Lets see in more details how yum works and what setup is required for yum to work.

Installing YUM

Yum can be installed using following packages

yum-metadata-parser-1.0-8.fc6
yum-updatesd-3.0.1-5.el5
yum-3.0.1-5.el5
yum-security-1.0.4-3.el5
yum-rhn-plugin-0.5.2-3.el5

Once these packages are installed, we need to create repository for using YUM. YUM always use some repository for installing rpm. Repository is a directory containg all rpm packages. When we give install command to yum it checks if the package we are asking him to install is present in the repository or not. If present in repository, it will go ahead with different checks like public key of the rpm is verified in order to check if the rpm file is modified. It also checks and resolves dependencies. Example if an rpm requires other rpm then it will search for other rpm in the existing repositories (there can be more then 1 repository) and list complete dependencies. It will ask confirmation if we want to goahead, if we say yes, it will install all the rpms including dependent rpms.

Creating repository

Creating a repository is a 4 step process. I will give an example for creating a simple repository.

1) Create a directory and place all packages
2) install createrepo package
3) use  createrepo command to create repository
4) Create a .repo file in /etc/yum.repos.d/ location

Before going ahead, its better if we import the public key for rpm packages. In most of your OS, this step must have done before. Hoever you can do this again just to make sure.

[root@station5 Server]# rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

1) Create a directory and place all packages

[root@station5 Server]# cd /home/package/
[root@station5 package]# ls
zenity-2.16.0-2.el5.i386.rpm       zlib-1.2.3-3.i386.rpm        zsh-html-4.2.6-1.i386.rpm
zip-2.31-1.2.2.i386.rpm            zlib-devel-1.2.3-3.i386.rpm
zisofs-tools-1.0.6-3.2.2.i386.rpm  zsh-4.2.6-1.i386.rpm

2) install createrepo package

[root@station5 Server]# yum install createrepo-0.4.4-2.fc6.noarch.rpm
Loading “rhnplugin” plugin
Loading “installonlyn” plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
No Repositories Available to Set Up
Reading repository metadata in from local files
Parsing package install arguments
Examining createrepo-0.4.4-2.fc6.noarch.rpm: createrepo – 0.4.4-2.fc6.noarch
Marking createrepo-0.4.4-2.fc6.noarch.rpm to be installed
Setting up repositories
No Repositories Available to Set Up
Reading repository metadata in from local files
Resolving Dependencies
–> Populating transaction set with selected packages. Please wait.
—> Package createrepo.noarch 0:0.4.4-2.fc6 set to be updated
–> Running transaction check

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
createrepo              noarch     0.4.4-2.fc6      createrepo-0.4.4-2.fc6.noarch.rpm  141 k

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 141 k
Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: createrepo                   ######################### [1/1]

Installed: createrepo.noarch 0:0.4.4-2.fc6
Complete!

3) use createrepo command to create repository

[root@station5 package]# createrepo -v /home/package
1/7 – zlib-devel-1.2.3-3.i386.rpm
2/7 – zenity-2.16.0-2.el5.i386.rpm
3/7 – zlib-1.2.3-3.i386.rpm
4/7 – zsh-html-4.2.6-1.i386.rpm
5/7 – zisofs-tools-1.0.6-3.2.2.i386.rpm
6/7 – zip-2.31-1.2.2.i386.rpm
7/7 – zsh-4.2.6-1.i386.rpm

Saving Primary metadata
Saving file lists metadata
Saving other metadata

4) Create a .repo file in /etc/yum.repos.d/ location

you can create a simple file in /etc/yum.repos.d/ location.
Example station5.repo

The content of this file will look as shown below

[root@station5 yum.repos.d]# cat station5.repo
[station5]
name=new
baseurl=file:///home/package
enable=1
gpgcheck=1

where

[station5]  -> is the name of repository
name=new    -> is the description of repository
baseurl=file:///home/package -> This is the location for your repository. If the repository is on local file system, you have to use protocol “file”. You can also use “ftp” or “http” as protocol if repository is present remotely.
enable=1    -> This specify if yum should enable that repo server for installtion or not 1 is for enable and 0 is for disable
gpgcheck=1  -> check the signature of the rpm package before installation

Once above 4 steps are done, lets try to apply a package present in our repository (zsh-html-4.2.6-1.i386.rpm)

[root@station5 ~]# yum install zsh-html
Loading “rhnplugin” plugin
Loading “installonlyn” plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
–> Populating transaction set with selected packages. Please wait.
—> Downloading header for zsh-html to pack into transaction set.
zsh-html-4.2.6-1.i386.rpm 100% |=========================|  15 kB    00:00
—> Package zsh-html.i386 0:4.2.6-1 set to be updated
–> Running transaction check

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
zsh-html                i386       4.2.6-1          station5          372 k

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 372 k
Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: zsh-html                     ######################### [1/1]

Installed: zsh-html.i386 0:4.2.6-1
Complete!

YUM Options

Different options are available in YUM similar to rpm. Following describes frequently used options.

1) To check if package is installed or not

yum list <package_name>

[root@10.176.87.179]# yum list zsh
Loading “installonlyn” plugin
Loading “rhnplugin” plugin
Loading “security” plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up repositories
Reading repository metadata in from local files
Available Packages
zsh.i386                                 4.2.6-1                DVD

here DVD is the name of repository (Since this package is not installed, its giving the location of package). If the patch is installed, it says “Installed”

yum list will give complete list of packages (installed and also available in repository)

2) To list rpms which are not installed and available in

yum list available

3) To list rpms which are installed

yum list installed

4) To install an rpm

[root@station5 yum.repos.d]# yum install telnet-server
Loading “rhnplugin” plugin
Loading “installonlyn” plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
–> Populating transaction set with selected packages. Please wait.
—> Downloading header for telnet-server to pack into transaction set.
telnet-server-0.17-38.el5 100% |=========================| 8.4 kB    00:00
—> Package telnet-server.i386 1:0.17-38.el5 set to be updated
–> Running transaction check
–> Processing Dependency: xinetd for package: telnet-server
–> Restarting Dependency Resolution with new changes.
–> Populating transaction set with selected packages. Please wait.
—> Downloading header for xinetd to pack into transaction set.
xinetd-2.3.14-10.el5.i386 100% |=========================| 7.7 kB    00:00
—> Package xinetd.i386 2:2.3.14-10.el5 set to be updated
–> Running transaction check

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
telnet-server           i386       1:0.17-38.el5    base               35 k
Installing for dependencies:
xinetd                  i386       2:2.3.14-10.el5  base              124 k

Transaction Summary
=============================================================================
Install      2 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 159 k
Is this ok [y/N]:

So it will ask if we want to install all the dependent packages as well

If we say yes it will install all dependent package as well

5) To remove rpm

yum remove <package_name>

note that we should not put the .rpm extention which installing or removing the rpm. Yum does not accept .rpm extension.

6) To update new version of rpm

yum update <package_name>

7) To search a package

yum search <searchterm>

8) To get information about any package

yum info <package_name>

[root@10.176.87.179]# yum info zsh
Loading “installonlyn” plugin
Loading “rhnplugin” plugin
Loading “security” plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up repositories
Reading repository metadata in from local files
Available Packages
Name   : zsh
Arch   : i386
Version: 4.2.6
Release: 1
Size   : 1.7 M
Repo   : DVD
Summary: A powerful interactive shell
Description:
The zsh shell is a command interpreter usable as an interactive login
shell and as a shell script command processor.  Zsh resembles the ksh
shell (the Korn shell), but includes many enhancements.  Zsh supports
command line editing, built-in spelling correction, programmable
command completion, shell functions (with autoloading), a history
mechanism, and more.

yum accept wild characters as well. Make sure to use single quotes.
Example

[root@10.176.87.179]# yum info ‘*irefo*’
Loading “installonlyn” plugin
Loading “rhnplugin” plugin
Loading “security” plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up repositories
Reading repository metadata in from local files
Installed Packages
Name   : firefox
Arch   : i386
Version: 1.5.0.12
Release: 3.el5
Size   : 37 M
Repo   : installed
Summary: Mozilla Firefox Web browser.

Description:
Mozilla Firefox is an open-source web browser, designed for standards
compliance, performance and portability.

Available Packages
Name   : firefox-devel
Arch   : i386
Version: 1.5.0.12
Release: 3.el5
Size   : 3.1 M
Repo   : DVD
Summary: Development files for Firefox
Description:
Development files for Firefox.  This package exists temporarily.
When xulrunner has reached version 1.0, firefox-devel will be
removed in favor of xulrunner-devel.

9) To check which rpm provides the file

[root@10.176.87.179]# yum whatprovides /bin/bash
Loading “installonlyn” plugin
Loading “rhnplugin” plugin
Loading “security” plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up repositories
Reading repository metadata in from local files

bash.i386                                3.1-16.1               DVD
Matched from:
/bin/bash
filelists.xml.gz          100% |=========================| 2.2 MB    00:00

bash.i386                                3.1-16.1               DVD
Matched from:
/bin/bash

Hope this helps !!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s