With the pending release of RHEL 5, Red Hat is moving from up2date to yum. Learn the ins-and-outs of your next command line software manager.
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.
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:
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.
Next: Let’s Update Something.