Managing Software Packages (aka RPMs) with Yum

Introduction

Yum (Yellow dog Updater, Modified) automatic updater and package installer/remover for rpm systems. It automatically computes dependencies and figures out what things should occur to install packages.

Packages also include a digital signature to identify their source. Software management utilities like yum and rpm verify these signatures using GPG public key. Yum and RPM share a common keyring that stores all public keys for approved sources.

What is a Package?

Package is nothing but a compressed archive file, which contains product information, programs, documentation, scripts, and etc.

What is a Repository?

A repository is a prepared directory or web site that contains software packages and index files. Software management utilities such as yum automatically locate and obtain the correct RPM packages from these repositories.

Repositories commonly classified into Base, Updates, and Extras. Base will contain software packages that are required to build a Linux system (mostly the packages that comes with the disk or in ISO). Updates will contain updated version of software packages that are provided in Base. Extras will contain additional software for the system.

Package naming conventions

Each package has a name, which provides several pieces of information. For example, full name of sample firefox package is firefox-1.0.7-1.4.1.centos4.i386.rpm

firefox – is a Package Name
1.0.7 – is the Version number
1.4.1 – is the release number
Centos4 – is the distribution
i386 – is intel architecture

[wfdosadmin@wfd-cos-cd1 ~]$ yum info firefox
Setting up repositories
Reading repository metadata in from local files
Installed Packages
Name : firefox
Arch : i386
Version: 1.0.7
Release: 1.4.1.centos4
Size : 29 M
Repo : installed
Summary: Mozilla Firefox Web browser.

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

Software Management Tools

RPM – Red Hat Package Manager, a powerful command line tool to install/update/remove software packages. RPM Package Manger does resolve and install dependencies.

UP2DATE – up2date is a tool used by Red Hat Enterprise Linux and Fedora Core that downloads and installs new software and upgrades to the operating system. UP2DATE resolves dependencies, and install.

Yum – Yum (Yellow dog Updater, Modified) automatic updater and package installer/remover for rpm systems. It automatically computes dependencies and figures out what things should occur to install packages. Yum imports repository public key if it is not installed in rpm keyring. Every completed transaction logged into /var/log/yum.log

Features of Yum

Multiple Repositories
Simple configuration file
Correct dependency calculation
Fast operation
Rpm-consistent behavior

For all su -c , you should enter the root password when prompted for Password:

Installing new package(s) with yum

  • To install a new package pango-devel
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum install pango-devel'
  • To install a package group MySQL Database
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum groupinstall "MySQL Database"'
  • To install a package from a local directory
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum localinstall pango-devel'

Note: If the package provides later version of software that is already installed on your system, yum will update the installed software.

Updating Package(s) with yum

  • To update pango-devel package
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum update pango-devel'
  • To update all the packages in group MySQL Database
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum groupinstall "MySQL Database"'

Removing Package(s) with yum

  • To remove pango-devel package
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum remove pango-devel'
  • To remove all the packages in group MySQL Database
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum groupremove "MySQL Database"'

Searching Package(s) with yum

  • To search a specific package, use the list option. For example, to search for pango-devel package
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum list pango-devel'
  • To search for pango-devel package version 1.6.0
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum list pango-devel-1.6.0'
  • To search of all the packages related to text web browser
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum search "web browser"'

Note: search option checks name, description, summary, and all the listed repositories to find the match.

  • To search for all the packages, that includes a name firefox
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum provides firefox'

Note: The provides function checks both the files included in the packages and the functions that the software provides. This option requires yum to download and read much larger index files than with the search option.

  • To list all the packages begin with lib
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum list lib*'

Note: yum with search/list options can be executed as a regular user.

Performing Full System update with yum

  • To check for updates on installed packages in the system
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum check-update'
  • To make full system update
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum update'
  • To enable automatic full system update everyday
[wfdosadmin@wfd-cos-cd1 ~]$ su -c '/sbin/chkconfig --level 345 yum on; /sbin/service yum start'

Adding new repository

To add an extra repository, copy a repository definition file into /etc/yum.repos.d/ directory. Package providers make the definition files available for their repositories on their web sites

[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'cp sample.repo /etc/yum.repos.d/'
  • To add public key to rpm keyring
    • from local file
[wfdosadmin@wfd-cos-cd1 ~]$ su - c 'rpm --import RPM-GPG-KEY-centos4'

or

[root@wfd-cos-cd1 ~]# rpm --import RPM-GPG-KEY-centos4
    • from url
[wfdosadmin@wfd-cos-cd1 ~]$ su - c 'rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-centos4'

or

[root@wfd-cos-cd1 ~]# rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-centos4

Deleting Repository

If enable is set to 0 in a yum repository definition file then the yum utility will ignores the file with this setting.

To completely remove a repository, delete the relevant file from /etc/yum.repos.d/ and delete the cache directory from /var/cache/yum/

Clearing the Caches (Frees Disk Space)

  • To purge/clean up package header/data files;
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum clean headers'
Password: {enter root password}
Cleaning up Headers
294 headers removed
  • To purge/delete all the packages (actual binary rpms) from the cache
[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum clean packages'
Password:
Cleaning up Packages
294 packages removed

Sample Transactions using yum

the below is an example of transaction for installing pango-devel

[wfdosadmin@wfd-cos-cd1 ~]$ su -c 'yum install pango-devel'
Password: {enter root password}
Setting up Install Process
Setting up repositories
update 100% |=========================| 951 B 00:00
base 100% |=========================| 1.1 kB 00:00
addons 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package pango-devel.i386 0:1.6.0-9 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
pango-devel i386 1.6.0-9 base 173 k

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 173 k
Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: pango-devel ######################### [1/1] 

Installed: pango-devel.i386 0:1.6.0-9
Complete!

the below is an example of transaction for groupinstall “MySQL Database”

[rperumal@wfd-cos-cd1 ~]$ su -c 'yum groupinstall "MySQL Database"'
Password: {enter root password}
Setting up Group Process
Setting up repositories
update 100% |=========================| 951 B 00:00
base 100% |=========================| 1.1 kB 00:00
addons 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
Setting up repositories
Reading repository metadata in from local files
Passing package list to Install Process
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for libdbi-dbd-mysql to pack into transaction set.
libdbi-dbd-mysql-0.6.5-10 100% |=========================| 3.3 kB 00:00
---> Package libdbi-dbd-mysql.i386 0:0.6.5-10.RHEL4.1 set to be updated
---> Downloading header for unixODBC to pack into transaction set.
unixODBC-2.2.9-1.i386.rpm 100% |=========================| 26 kB 00:00
---> Package unixODBC.i386 0:2.2.9-1 set to be updated
---> Package mysql-devel.i386 0:4.1.12-3.RHEL4.1 set to be updated
---> Downloading header for MyODBC to pack into transaction set.
MyODBC-2.50.39-21.RHEL4.1 100% |=========================| 4.6 kB 00:00
---> Package MyODBC.i386 0:2.50.39-21.RHEL4.1 set to be updated
---> Downloading header for mysqlclient10 to pack into transaction set.
mysqlclient10-3.23.58-4.R 100% |=========================| 4.1 kB 00:00
---> Package mysqlclient10.i386 0:3.23.58-4.RHEL4.1 set to be updated
---> Downloading header for MySQL-python to pack into transaction set.
MySQL-python-1.0.0-1.RHEL 100% |=========================| 8.6 kB 00:00
---> Package MySQL-python.i386 0:1.0.0-1.RHEL4.1 set to be updated
---> Package mysql.i386 0:4.1.12-3.RHEL4.1 set to be updated
---> Downloading header for perl-DBD-MySQL to pack into transaction set.
perl-DBD-MySQL-2.9004-3.1 100% |=========================| 5.4 kB 00:00
---> Package perl-DBD-MySQL.i386 0:2.9004-3.1 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
MyODBC i386 2.50.39-21.RHEL4.1 base 58 k
MySQL-python i386 1.0.0-1.RHEL4.1 base 77 k
libdbi-dbd-mysql i386 0.6.5-10.RHEL4.1 base 14 k
mysql i386 4.1.12-3.RHEL4.1 base 2.8 M
mysql-devel i386 4.1.12-3.RHEL4.1 base 2.1 M
mysqlclient10 i386 3.23.58-4.RHEL4.1 base 223 k
perl-DBD-MySQL i386 2.9004-3.1 base 111 k
unixODBC i386 2.2.9-1 base 772 k

Transaction Summary
=============================================================================
Install 8 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 6.1 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): libdbi-dbd-mysql-0 100% |=========================| 14 kB 00:00
(2/6): unixODBC-2.2.9-1.i 100% |=========================| 772 kB 00:01
(3/6): MyODBC-2.50.39-21. 100% |=========================| 58 kB 00:00
(4/6): mysqlclient10-3.23 100% |=========================| 223 kB 00:00
(5/6): MySQL-python-1.0.0 100% |=========================| 77 kB 00:00
(6/6): perl-DBD-MySQL-2.9 100% |=========================| 111 kB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: mysqlclient10 ######################### [1/8]
Installing: mysql ######################### [2/8]
Installing: unixODBC ######################### [3/8]
Installing: libdbi-dbd-mysql ######################### [4/8]
Installing: mysql-devel ######################### [5/8]
Installing: MyODBC ######################### [6/8]
Installing: MySQL-python ######################### [7/8]
Installing: perl-DBD-MySQL ######################### [8/8] 

Installed: MyODBC.i386 0:2.50.39-21.RHEL4.1 MySQL-python.i386 0:1.0.0-1.RHEL4.1 libdbi-dbd-mysql.i386 0:0.6.5-10.RHEL4.1 mysql.i386 0:4.1.12-3.RHEL4.1 mysql-devel.i386 0:4.1.12-3.RHEL4.1 mysqlclient10.i386 0:3.23.58-4.RHEL4.1 perl-DBD-MySQL.i386 0:2.9004-3.1 unixODBC.i386 0:2.2.9-1
Complete!

below is the sample repository definition

[root@wfd-cos-cd1 ~]# cat /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4

#released updates
[update]
name=CentOS-$releasever - Updates
baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4

#packages in testing
[testing]
name=CentOS-$releasever - Testing
baseurl=http://mirror.centos.org/centos/$releasever/testing/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
[root@wfd-cos-cd1 ~]#

Leave a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.