To install a package, log in as
root
and issue the following command from a
shell prompt:
rpm -ivh
package
where package
specifies the name of the file
that contains the package. You can specify multiple packages, as long
as you include a space to separate each package name from its
neighbor. For example, the following command installs both the
pine
and elm
packages from
files in the current directory:
rpm -ivh pine-4.33-8.i386.rpm elm-2.5.3-11.i386.rpm
The options used with the rpm command include:
This option specifies that RPM should install the package or packages given as arguments.
This option specifies that RPM should print hash marks
(#
) as it installs the package as a visible
indication of progress.
The verbose option specifies that RPM should print messages that summarize its actions and progress.
Generally, RPM successfully installs the specified package. However, errors can occur. RPM may report:
That the package is already installed
That a package file conflicts with a file from another package
A failed dependency
The next three sections explain how to resolve these errors.
If a package has already been installed, RPM will not overwrite the package without your permission:
# rpm -ivh bad-1.0-1.i386.rpm
bad package bad-1.0-1 is already installed
If you want to overwrite the package, add the - -replacepkgs option to your command:
rpm -ivh --replacepkgs bad-1.0-1.i386.rpm
It may be more appropriate to update the package. Updating the package leaves its configuration files intact, whereas overwriting the package replaces the configuration files with files containing default options. An upcoming section shows you how to update a package.
Of course, it’s also possible that you should do nothing. You may have attempted to install the package without first checking whether it’s already installed and operational. In that case, you can use RPM to verify that the package is installed correctly and update or overwrite the package only if RPM reports problems.
To verify an installed package against a package file, issue the following command from a shell prompt:
rpm -Vp
package
In the command, package
specifies the name of
the file that contains the package; for example,
basesystem-7.0-2.rpm
. In verifying a package,
RPM compares the installed files with the original package contents.
If RPM detects no discrepancies, no output will appear. Otherwise,
RPM displays a line for each file that differs from the original
package contents. Figure 8-2 shows the structure of
such a line. The first eight characters of such a line report
discrepancies; each character has the meaning described in Table 8-1. Following the list of discrepancies, you may
see the letter c, which denotes that this is a
configuration file. Finally, the filename appears.
The configuration files associated with a package are generally modified during installation and use, so it’s not unusual for the content of configuration files to differ from that of the original files. You should generally ignore MD5 checksum and file size discrepancies that pertain to configuration files.
You can verify a package against the information recorded in the RPM database when the package was installed. To do so, issue a command of the form:
rpm -V
package
Here, package
specifies the name the package,
for example, basesystem
. Another form of the
rpm command lets you verify packages
that contain a specified file:
rpm -Vf
path
In this form, path
specifies the absolute
pathname of the file. The output of this command is the same as that
given earlier.
Conflict
is RPM’s term for a situation in
which two packages include one or more identically named files that
have different contents. For example, suppose that package a contains a file named
/etc/superconfig
having 12 lines and that
package b contains a file named
/etc/superconfig
having 13 lines. The two
packages conflict, because the two instances of
/etc/superconfig
are inconsistent.
In the event of a conflict, only one of the two conflicting packages is likely to work properly. If you instruct RPM to install a package and RPM finds that one or more of the package files conflict with existing files, RPM reports the conflict and terminates without installing the package:
# rpm -ivh bad-1.0-1.i386.rpm
bad /bin/badfile conflicts with file from good-1.0-1
In its report, RPM gives the name of the file and the name of the package that originally installed the file. You can use the —replacefiles option to force RPM to install the package:
rpm -ivh --replacefiles
package
In response, RPM saves and then replaces any conflicting configuration files; it overwrites other types of files. However, using the —replacefiles option is a bit like hitting a malfunctioning mechanical device with a hammer. Sometimes, it’s what you must do, but, more often, it merely causes damage. The better way to resolve a conflict is to decide which of the two conflicting packages you prefer. Then, delete the unwanted package and install the preferred one.
Packages are not always self-contained; some packages require that other packages be installed before they operate correctly. RPM can identify such dependencies. If you attempt to install a package before you install other packages it requires, RPM reports a “failed dependency” and terminates without installing the package:
# rpm -ivh bad-1.0-1.i386.rpm
failed dependencies:
mefirst is needed by bad-1.0-1
To resolve a failed dependency, you should install the missing
package (or packages) and then install the desired package. If you
prefer, you can force RPM
to install the
package; however, the package may not operate correctly. To force
package installation, specify the - -nodeps
option:
rpm -ivh --nodeps bad-1.0-1.i386.rpm
However, a forcibly installed package is unlikely to work correctly.
Determining the identity of the missing package responsible for the
failed dependency can be challenging. The best way to do so is to
install the Red Hat RPM database, contained in the package
rpmdb-redhat
that resides on Disc 2. To install
the package, insert Disc 2 (obtain CD material online at http://examples.oreilly.com/redhat2) into your system’s CD-ROM drive and
issue the following commands:
su - mount -t iso9660 /dev/cdrom /mnt/cdrom -o ro rpm --replacepkgs -Uvh /mnt/cdrom/RedHat/RPMS/rpmdb-redhat-*.rpm umount /mnt/cdrom exit
The Red Hat RPM database describes every package included in Red Hat
Linux 7.2. Once you’ve installed the package containing the Red
Hat RPM database, you can query the database to discover the name of
a package that satisfies a given dependency. For example, suppose
you’re trying to install the package
gnorpm
and RPM fails to do so, complaining that
the library file librpm.so.0
is needed but not
installed. To discover the name of the related package, issue the
command:
rpm --redhatprovides librpm.so.0
The RPM facility will print a message telling you that the needed
file is found in the package rpm-4.0.2-8
. Simply
install that package and then try again to install
gnorpm
.
3.12.123.2