7.3. Using RPM
RPM, the Red Hat Package Manager, is a tool that automates the installation of software binaries and remembers what files are needed so that you can be assured the software will run properly. Despite the name, RPM is not Red Hat-specific, but is used in many other distributions nowadays, including SuSE and Caldera. Using RPM makes installing and uninstalling software a lot easier.
The basic idea of RPM is that you have a database of packages and the files that belong to a package. When you install a new package, the information about this package is recorded in the database. Then, when you want to uninstall the package, for every file of the package, RPM checks whether there are other packages installed using this file, too. If this is the case, the file in question is not deleted.
In addition, RPM tracks dependencies. Each package can be dependent on one or more other packages. When you install a package, RPM checks whether the packages the new package is dependent on are already installed. If not, it informs you about the dependency and refuses to install the package.
The dependencies are also used for removing packages: when you want to uninstall a package that other packages are still dependent upon, RPM tells you about this, too, and refuses to execute the task.
The increased convenience of using RPM packages comes at a price, however: First, as a developer, it is significantly more difficult to make a RPM package than to simply pack everything in a tar archive. And second, it is not possible to retrieve just one file from a RPM package; you have to install everything or nothing.
If you already have an RPM system, installing RPM packages is very easy. Let's say that you have a RPM package called SuperFrob-4.i386.rpm (RPM package always have the extension .rpm; the i386 indicates that this is a binary package compiled for Intel machines). You could then install it with:
tigger # rpm -i SuperFrob-4.i386.rpm
Instead of -i, you can also use the long-named version of this option; choose whatever you like better:
tigger # rpm --install SuperFrob-4.i386.rpm
If everything goes well, there will be no output. If you want RPM to be more verbose, you can try:
tigger # rpm -ivh SuperFrob-4.i386.rpm
This prints the name of the package plus a number of hash marks, so that you can see how the installation progresses.
If the package you want to install needs another package that is not yet installed, you will get something like the following:
tigger # rpm -i SuperFrob-4.i386.rpm failed dependencies: frobnik-2 is needed by SuperFrob-4
If you see this, you have to hunt for the package frobnik-2 and install this first. Of course, this package can itself be dependent on other packages again.
If you want to update a package, use the -U or - -update option (which is just the -i option combined with a few more implied options):
tigger # rpm -U SuperFrob-5.i386.rpm
Uninstalling a package is done with the -e or --erase option. In this case, you do not specify the package file (you might not have that around any longer), but the package name and version number:
tigger # rpm -e SuperFrob-5
Besides the options described so far that alter the state of your system, the -q option provides various kinds of informations about everything that is recorded in the RPM database as well as package files. Here are some useful things you can do with -q:
What we've just finished showing are the basic modes of operation, which are supplemented by a large number of additional options. You can check those in the manual page for the rpm command.
If you are faced with a RPM package that you want to install, but have a system like Slackware or Debian that is not based on RPM, things get a little bit more difficult.
You can either use the fairly self-explanatory command alien that can convert between various package formats and comes with most distributions, or you can build the RPM database from scratch.
The first thing you have to do in this latter case is to get the rpm program itself. You can download it from http://www.rpm.org. Follow the installation instructions to build and install it; if you have the C compiler gcc installed on your system, there should be no problems with this.
The next task is to initialize the RPM database. Distributions that come with RPM do the initialization automatically, but on other systems you will have to issue the command:
tigger # rpm --initdb
This command creates several files in the directory /var/lib/rpm. The directory /var/lib should already exist; if it doesn't, create it with the mkdir command first.
Now you can install RPM packages the normal way, but since you have not installed the basic parts of the system like the C library with RPM, you will get errors like the following:
tigger # rpm -i SuperFrob-4.i386.rpm failed dependencies: libm.so.5 is needed by SuperFrob-4 libdl.so.1 is needed by SuperFrob-4 libc.so.5 is needed by SuperFrob-4
because those files are not recorded in the RPM database. Of course, you really do have those files on your system; otherwise most programs wouldn't run. For RPM to work, you must tell it not to care about any dependencies. You do this by specifying the command-line option - -nodeps:
tigger # rpm -i --nodeps SuperFrob-4.i386.rpm
Now, RPM will install the package without complaining.
With this information, you should be able to administer your RPM-based system. If you want to know more, read the manual page for the rpm command or check out http://www.rpm.org.
Copyright © 2001 O'Reilly & Associates. All rights reserved.