-->

Previous | Table of Contents | Next

Page 306

The version mode, invoked as


rpm --version

prints out a line containing version information, similar to this:


RPM version 2.3.11

The help mode out an extensive help message and is invoked as follows:


rpm --help

Because the message is long, it is handy to have a large xterm or to pipe the output to more. To get a shorter help message, just type


rpm

This prints out a usage message. The showrc mode


rpm --showrc

prints out a list of variables that can be set in the files /etc/rpmrc and $HOME/.rpmrc. The default values are adequate for most installations.

The rebuilddb option is used to rebuild the database that RPM uses to keep track of which packages are installed on a system. It is invoked as follows:


rpm --rebuilddb

The database files are usually stored in /var/lib/rpm/. In most cases the database files do not need to be rebuilt very often.

Installing Packages

One of the major uses of RPM is to install software packages. The general syntax of an rpm install command is


rpm -i [options] [packages]

where options can be one of the common options given earlier or one of the install options covered in the following list, and packages is the name of one or more RPM package files. Some of the install options are as follows:

-v Prints out what RPM is doing.
-h or --hash Prints out 50 hash marks (#) as the package is installed.
--percent Prints out percentages as files are extracted from the package.
--test Goes through a package install, but does not install anything; mainly used to catch conflicts.

Page 307

--excludedocs Prevents the installation of files marked as documentation, such as man pages.
--includedocs Forces files marked as documentation to be installed; this is the default.
--nodeps No dependency checks are performed before installing a package.
--replacefiles Allows for installed files to be replaced with files from the package being installed.
--replacepkgs Allows for installed packages to be replaced with the packages being installed.
--oldpackage Allows for a newer version of an installed package to be replaced with an older version.
--force Forces a package to be installed.

When giving options to RPM, regardless of the mode, all the single-letter options can be lumped together in one block. For example, the command


rpm -i -v -h kernel-2.0.30-3.i386.rpm

is equivalent to


rpm -ivh kernel-2.0.30-3.i386.rpm

All options starting with -- must be given separately, however.

Now let's look at a couple of examples of installing RPM packages. The first example installs vim (the improved version of vi) from the package:


vim-4.5-2.i386.rpm

This package follows the standard naming convention for RPM packages, which is


name-version-release.arch.rpm

where name is the package's name, version is the package's version, release is the package's release level, arch is the hardware architecture the package is for, and rpm is the default extension. This naming scheme is quite handy because some of the essential information about a particular package can be determined from just looking at its name.

For the vim package, say you are installing vim version 4.5, release 2 for a computer with the i386 architecture. Let's go ahead and install this package. With the Red Hat CD-ROM on
/mnt/cdrom, the package you want is


/mnt/cdrom/RedHat/RPMS/vim-4.5-2.i386.rpm

First, cd into the appropriate directory; then to install it type the following at the prompt (#):

Page 308


# rpm -ivh vim-4.5-2.i386.rpm

As the package is installed, the output will look like the following:


vim                         ################

When the install is finished, 50 hash marks will be displayed.

In this example I used the hash character (#) to indicate the root prompt because only root can properly install packages for an entire system. If you try to install this package as a user other than root, an error similar to the following will be generated:


failed to open //var/lib/rpm/packages.rpm

error: cannot open //var/lib/rpm/packages.rpm

Now to install the X11 version of vim from the package:


/mnt/cdrom/RedHat/RPMS/vim-X11-4.2-8.i386.rpm

If you try using


rpm -ivh vim-X11-4.2-8.i386.rpm

you will get the following error:


package vim-X11-4.2-8 is already installed

error: vim-X11-4.2-8.i386.rpm cannot be installed

To install this package, use the --replacepkgs option:


rpm -ivh --replacepkgs vim-X11-4.5-2.i386.rpm

Occasionally, the files that one package installs conflicts with the files of a previously installed package. If you had vim version 4.2 installed, the following message would have been generated:


/bin/vim conflicts with file from vim-4.2-8

/usr/share/vim/vim_tips.txt conflicts with file from vim-4.2-8

error: vim-4.5-2.i386.rpm cannot be installed

If you wanted to install these files anyway, the --replacefiles option could be added to the command.

Another type of conflict that is sometimes encountered is a dependency conflict. This happens when a package that is being installed requires certain other packages to function correctly. For example, when I try to install the package


# rpm -ivh dosemu-0.66.2-1.i386.rpm

I get the following dependency errors:


failed dependencies:

kernel >= 2.0.28 is needed by dosemu-0.66.2-1

dosemu = 0.64.1 is needed by xdosemu-0.64.1-1

Previous | Table of Contents | Next