[General] Linux Software Management with yum
Eng. Sabah Al-Sabah
sabah at techsys.net
Sat Mar 31 01:21:51 +03 2007
Linux Software Management with yum
Friday, February 16th, 2007By <http://www.linux-mag.com/author/74> Roderick
W. Smith
In the Linux world, package management systems such as the RPM Package
Manager (RPM) and Debian packages have become standard features with most
distributions. Package management systems enable easy installs, de-installs,
upgrades, and verification of both simple and complex software packages.
The basic tools for both RPM and Debian packages, though, work on individual
package files. As Linux distributions have become larger and more complex
and as the need for frequent and even automated updates has grown, the
limitations of RPM and Debian packages have become apparent.
To fill this void, distribution maintainers have developed tools that either
build on existing package systems or scrap them entirely in favor of new
systems. Gentoo looked to FreeBSD for the inspiration for its Portage
package management, which is network- and source code-based. Debian
developers created the Advanced Package Tools (APT) to add network
capabilities to Debian packages. In addition to an RPM port of APT, the RPM
world has the Yellow Dog Updater, Modified, or Yum, which is similar to APT
in basic features and design goals, although it differs in many details.
If you have an RPM-based system, investigating Yum (or APT, if you prefer)
is worthwhile. Yum allows you to quickly and easily update the software on
your system using network repositories or install entirely new packages.
Like APT and Portage, Yum is a network-based package management system. You
give it the network address of a repository that holds RPMs for your
distribution along with appropriate Yum metadata. Thereafter, Yum can
quickly check for new and upgraded packages, install packages by name
without tedious CD-shuffling, and even update your entire system. Updating
from one version of your distribution to another is also possible, but can
be tricky.
Obtaining and Installing Yum
The first challenge, of course, is to obtain and install Yum. You can
download the software from http://linux.duke.edu/projects/yum/. You can
also, of course, check the packages that ship with your distribution. (In
fact, using a Yum package provided with your distribution is preferable, if
one is available. A distribution-provided package is likely to be at least
partially configured already and may include distribution-specific tweaks
and fixes.)
The Yum site provides links to several different versions the software. As
the magazine goes to press, the latest unstable version is 2.9.1, while the
latest stable version is 2.6.1. Using the latest stable version is highly
recommended. (If you're using an older distribution, though, you might need
to use an earlier version. Yum depends on other software, which might not be
recent enough if you're using an older distribution.)
If you need to use the package provided on the Yum site, be aware that it
ships as a tarball (with a .tar.gz filename extension) and as a source RPM
(with a .src.rpm filename extension). Binary packages aren't available.
Thus, to install Yum, you must first create a binary RPM (assuming you want
to use RPM to manage the Yum package itself). You can do this with rpmbuild:
# rpmbuild --rebuild yum-2.6.1-1.src.rpm
Of course, change the version number if you download another version of Yum.
The result should be a package in the /usr/src/redhat/RPMS/noarch directory,
or something similar. (The redhat directory name will most likely be
something else on distributions other than Red Hat or Fedora Core.) Yum is a
set of Python scripts, so it's not architecture-dependent - hence the noarch
in the directory path. The final RPM also contains a noarch code in its
filename, such as yum-2.6.1-1.noarch.rpm.
Install the package using RPM in the usual way:
# rpm -Uvh yum-2.6.1-1.noarch.rpm
If all goes well, the Yum utility is now installed. If you see "failed
dependencies" or other errors, you should probably track down the missing
packages and install them. Package-location sites such as
http://www.rpmfind.net can be very helpful in locating missing packages. You
may also run into installation errors if you try to install the latest
version of Yum on a less-than-recent distribution. In that case, it may be
easier to install an older version of Yum rather than try to track down the
missing dependencies.
Configuring Yum
Yum uses the /etc/yum.conf file for configuration. This file contains
configuration blocks, each of which begins with a name in brackets, such as
[main] or [base]. After the block name come lines that consist of
configuration option names, equal signs, and the options themselves, as in:
cachedir=/var/cache/yum
keepcache=1
As with configuration files that use a similar format, you can change
options by editing the option values following the equal signs. In most
cases, you shouldn't need to edit the entries in the [main] section of the
file, which set global configuration options such as the location of working
directories, the debug level, and so on.
One possible exception is the distroverpkg option, which sets the name of a
package that contains the distribution version information and additional
configuration files (described shortly). This option defaults to
redhat-release, but you may need to change this value to suit your
distribution. For instance, if you're running Fedora, it should be set to
fedora-release, and for SuSE, it should be suse-release.
In order for the distroverpkg option to be of any use, of course, you must
have an appropriate package installed. This package must be for your
distribution! If you try to use, say, a SuSE distribution version package on
a Mandrake system, you could damage your system so badly that you'll need to
re-install the operating system from scratch. Thus, it's imperative that you
locate an appropriate package. If your distribution ships with Yum, try
looking for a package whose name ends (before the version number) in
-release. If your distribution didn't ship with Yum, you'll have a harder
time with this task. Your best bet may be a Web search; try searching on
your distribution's name and "Yum."
Additional sections of the yum.conf file provide information on Yum
repositories that hold packages for the base distribution (that is, the
distribution as originally installed) and updates to the distribution
(mainly bug fixes). These entries are often shunted into files with .repo
filename extensions in the /etc/yum.repos.d directory. This directory often
holds multiple files, each devoted to a particular subset of packages, such
as the main package set and packages without official support. These files,
if they're present, typically come as part of the package pointed to by the
distroverpkg option.
Try checking the /etc/yum.repos.d directory and perusing the files there.
The files should contain baseurl and perhaps mirrorlist options, which point
to URLs that in turn enable Yum to find files. These URLs often include the
variable $releasever in their names, which enables Yum to find your files
even when you upgrade your distribution to a new version. You'll also see
enabled lines, with values of 0 to tell Yum not to use a repository or 1 to
tell Yum to use it. The default configuration should work well in most
cases, but if you want to have Yum check extra repositories, you might need
to change the enabled option for some of them.
Upgrading Software with Yum
With Yum installed and configured, you can begin using it. You might want to
begin by typing the following command:
# yum check-update
This command checks your system against the Yum repositories configured in
/etc/yum.conf and /etc/yum.repos.d/. The output of this command can be quite
verbose. The command's speed depends on the speed of your network connection
and the load at the Yum repository sites. If your system needs no updates,
the command returns a value of 0; if any packages need updates, the return
value is 100 and the program displays a list of the packages that require
updates. This command doesn't actually download or install any packages,
though.
yum check-update is a safe way to begin using yum; it shows you what the
program will do when you use it to perform a system upgrade, but without
actually modifying any installed packages. If you see error messages or spot
upgrades you didn't anticipate or don't want, you can take measures to avoid
the problems. For instance, you can upgrade individual packages rather than
your whole system, as described shortly.
To upgrade all the packages on your system, you can type either of the
following commands:
# yum -y update
# yum -y upgrade
These commands have identical effects, except that the upgrade command
activates logic in Yum for handling obsolete packages. (This same feature
can be activated by using the --obsoletes option along with update.) This
obsolete package handling is most important when you're performing a major
upgrade, such as upgrading from one version of your distribution to the next
one.
These examples use the -y option, which tells Yum to automatically provide a
y ("yes") response to questions asked by Yum. Because "yes" is normally the
response you'd give, this can speed up the process of using Yum, but it does
increase the risk of problems arising as a result of incorrect automatic
"yes" responses. You can change the default by editing the assume-yes option
in /etc/yum.conf.
Be aware that system updates and upgrades can download many packages, and
some of them can be quite big. Thus, you might want to be careful about
performing such updates if you've got a slow network connection or if you
have little time to spare nursing Yum through the update process. With luck,
there will be no problems, but you can never really be sure of that -
packages can fail to download or install for any number of reasons, so you
might need to re-run the command, remove conflicting packages, or otherwise
fix problems.
If you don't want to update all the packages on your system, you can update
just one, as well as any dependencies that need updating, by specifying its
name:
# yum update target-package
This command updates target-package and its dependencies, but nothing else.
If you want to see what dependencies might be updated, use check-update
rather than update to have Yum report all the packages it will update. You
can update multiple packages by specifying them all on one command line.
Installing Software with Yum
As Linux distributions have grown in size, one of the annoyances that's
grown with them is the need to swap CD-ROM's to locate packages for
upgrades. You can avoid this problem by using Yum to grab new packages from
Yum repositories on the Internet. To do so, use the install subcommand and
name your package:
# yum install target-package
This command installs target-package on your computer, provided that a
package by that name is present in the Yum repositories specified in your
Yum configuration file.
In addition to the target package itself, this command installs any packages
upon which it depends, if they're not already installed. Thus, this command
can end up installing quite a few packages. You should be aware of this
possibility, particularly if your network link is slow.
Yum and x86-64 Systems
If you're using an x86-64 system rather than a PowerPC, 32-bit x86, or other
platform, you should be aware of an extra factor with Yum: By default, Yum
install both 32-bit and 64-bit versions of a package, if both are available.
In other words, if you type yum install target-package, Yum will look for
and install both target-package- version.i386.rpm and target-package-
version.x86_64.rpm.
If you know that you only need the 64-bit version of the package, you can
force Yum to install only that version by appending the platform
specification after a dot, as in yum install target-package.x86_64.
Most distributions make 32-bit versions of packages available for x86-64
versions of their distributions for just a few packages. Thus, you shouldn't
need to specify the architecture very often. Indeed, you should think hard
before doing so; chances are if both versions are in the repository, it's
because the package is a library or other package that's depended upon by
other packages that are available only in 32-bit form.
Cleaning Up After Yum
Yum works, in part, by downloading RPMs from repository sites and then
installing those packages. By design, though, Yum doesn't clean up after
itself-- after installation, the package files remain behind in the Yum
directory tree, /var/cache/yum. This enables you to quickly re-install a
package if you delete it and then change your mind; however, tit also
consumes a great deal of disk space. If you need to get that disk space
back, you can do so by telling Yum to do some housecleaning:
# yum clean packages
This command cleans out the package files, which are generally the biggest
disk space hogs. Yum also maintains package header files and other data,
though. If Yum begins behaving strangely, you might want to use headers,
metadata, cache, or dbcache in place of packages in the preceding command.
These options clean the specified types of data, in case they become
corrupted or bloated.
Summing Up
All in all, Yum is a great tool for simplifying maintenance of RPM-based
systems. By adopting a network-based package management tool, you can more
easily keep up with bug fixes (especially security-related bug fixes),
install new software, and so on.
This column has described the most important and useful Yum features;
however, it supports additional options. You might want to consult the Yum
man page, as well as the man page for /etc/yum.conf, to learn more about
this useful tool.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://oskw.org/pipermail/general_oskw.org/attachments/20070331/4563953a/attachment.html>
More information about the General
mailing list