-->
Previous Table of Contents Next


RPM

RPM is not restricted to Red Hat Linux; it has appeared in several different versions of Linux. RPM is a character-based system that allows you to build, install, query, verify, update, and uninstall software packages. (A software package in Linux terms consists of an archive of files and information about that package, such as the package name, version number, and a brief description.) RPM has ten modes of operation, each with a different set of options. This can make RPM a little confusing to work with, although most of the uses are straightforward. RPM’s modes and their purposes are shown in Table 5.1.

Table 5.1. RPM’s modes and what they are used for.

Mode name Command line Used for

Build rpm -[b|t]O Build a package
Fix permissions rpm --setperms Fix the permissions on a package
Install rpm -i Adding new software
Query rpm -q Check to see what packages and files are installed
Rebuild Database rpm --rebuilddb Rebuild the package database
Set owners and groups rpm --setugids Set the owner and group of a package
Show RC rpm --showrc
Signature check rpm --checksig Check the package to ensure there are no errors
Uninstall rpm -e Remove a package
Verify rpm -V|-y| --verify Verify that a package is installed properly (all files installed)

We won’t bother with a lot of detail about all these options because most are self-explanatory and covered in the documentation, but a few common-usage examples will help you become more familiar with RPM. To install software with RPM, you need to specify the package name that you want to install. The syntax of the install command is as follows:


rpm -i [install-options] <package_filename>

There are dozens of installation options possible, most of which don’t do very much except modify the behavior of RPM slightly. A few of the more useful installation options for RPM are

  allfiles. Installs or upgrades all the files in the package.
  force. The same as using replacepkgs, replacefiles, and oldpackage together.
  h or --hash. Displays 50 hash marks as the package archive is unpacked to show the system is working (use with the -v option for a nicely formatted status display).
  includedocs. Installs documentation files (usually done by default).
  ignoreos. Forces installation or upgrading if the operating systems of the RPM and the host are not the same.
  keep-temps. Keeps temporary files created during the installation process, useful for debugging installation problems.
  percent. Displays progress percentages as files are unpacked (intended to make RPM easy to run from scripts).
  quiet. Displays a minimal set of messages (but all error messages).
  replacefiles. Installs the package even if new files replace files from already installed packages.
  replacepkgs. Installs the package(s) even if they are already installed.
  test. Does not install but checks for conflicts.

Check the man page for a full list of options. The packagee name to be added is usually given as a complete path, although a URL is also possible with many versions of RPM. To install a package called Xgames, the command would be given like this:


rpm -i /mnt/cdrom/col/install/Xgames.rpm

In this case, the package is called Xgames.rpm, and the full path to the package is given (this one is on a CD-ROM in the col—collections—directory).

The verify mode of the RPM command is handy for making certain that all portions of a package have been installed and still exist on your system. This is sometimes necessary after installing other packages that may overwrite part of an existing package. When you verify a package, RPM compares information about the installed files in the package with information about the files taken from the original package and stored in the RPM database. Among other things, verifying compares the filename, size, check sum, permissions, type, owner, and group of each file. Any discrepancies in the comparison are displayed on the screen.

To use the verify mode of RPM, use the command with the -w option and the package name. RPM will use one of these eight characters to show a failure of one of the tests:

5 MD5 sum (checksum)
S File size incorrect
L Symbolic link incorrect
T Time incorrect
D Device incorrect
U User owner incorrect
G Group owner incorrect
M Mode incorrect (includes permissions and file types)

If you find errors in a package, it is usually easiest to reinstall the package.

installpkg

The installpkg utility is a hold-over from UNIX, where it has been around for years. The installpkg utility can be used to install a package in much the same way as RPM. The command to install the package Xgames would be


installpkg /usr/col/Xgames

By default installpkg looks for packages with .tgz file extensions. If you have a different extension and know that installpkg can handle it, specify the full package name including the extension on the command line. In the case of the above command, the installpkg tool extracts any files in the package /usr/col/Xgames.tgz, unpacking them as it goes.

The directory used by installpkg as the base for its installation is the current one, so in the case of the above example, whatever directory we are in when we issue the installpkg command is where the Xgames package is installed.


Previous Table of Contents Next