8.5 Installing a Package

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 mutt packages from files in the current directory:

rpm -ivh pine-4.44-13.i386.rpm mutt-1.4-4.i386.rpm

The options used with the rpm command include:

-i

This option specifies that RPM should install the package or packages given as arguments.

-h

This option specifies that RPM should print hash marks (#) as it installs the package as a visible indication of progress.

-v

The verbose option specifies that RPM should print messages that summarize its actions and progress.

Generally, RPM will successfully install 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.

8.5.1 Package Is Already Installed

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 a 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-8.0-1.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-5 shows the structure of such a line. The first eight characters 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.

Figure 8-5. The structure of RPM's discrepancy report
figs/rh3_0805.gif

Table 8-1. Package file discrepancy codes

Code

Meaning

.

No discrepancy

5

MD5 checksum discrepancy

D

Device discrepancy

G

Group discrepancy

L

Symbolic link discrepancy

M

Access mode or file type discrepancy

S

File size discrepancy

T

File modification time discrepancy

U

User discrepancy

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.

8.5.2 Conflicting File

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 force RPM to install the package, by using the -- replacefiles option:

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.

8.5.3 Failed Dependency

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.



Learning Red Hat Linux
Learning Red Hat LINUX: Guide to Red Hat LINUX for New Users
ISBN: B00007FYF7
EAN: N/A
Year: 2003
Pages: 118
Authors: Bill McCarty

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net