Previous Section
 < Day Day Up > 
Next Section


Red Hat Package Manager (RPM)

Several Linux distributions, including Red Hat, Mandrake, Caldera, and SuSE, use RPM to organize Linux software into packages you can automatically install, update, or remove. RPM is a command line–driven package management system that is capable of installing, uninstalling, querying, verifying, and updating software packages installed on Linux systems. An RPM software package operates as its own installation program for a software application. A Linux software application often consists of several files that need to be installed in different directories. The program itself is most likely placed in a directory called /usr/bin, online manual files like Man pages go in other directories, and library files in yet another directory. In addition, the installation may require modification of certain configuration files on your system. The RPM software package performs all these tasks for you. Also, if you later decide you don't want a specific application, you can uninstall packages to remove all the files and configuration information from your system. RPM works similarly to the Windows Install Wizard, automatically installing software, including configuration, documentation, image, sample, and program files, along with any other files an application may use. All are installed in their appropriate directories on your system. RPM maintains a database of installed software, keeping track of all the files installed. This enables you to use RPM also to uninstall software, automatically removing all files that are part of the application.

RPM Tools

To install and uninstall RPM packages, you can use the rpm command directly from a shell prompt, or the Red Hat distribution software management tool, redhat-config-packages. The redhat-config-packages tools is a GUI front end for the rpm command. Although you should download RPM packages for your particular distribution, numerous RPM software packages are designed to run on any Linux system. You can learn more about RPM at its Web site at www.rpm.org. The site contains up-to-date versions for RPM, documentation, and RPM support programs, such as rpm2html and rpm2cpio. rpm2html takes a directory containing RPM packages and generates Web pages listing those packages as links that can be used to download them. rpm2cpio is a Perl script to extract RPMs. Also, the Red Hat Linux Customization Guide provides an excellent tutorial for both RPM and redhat-config-packages.

RPM Packages

The naming conventions for RPM packages vary from one distribution to another. On Red Hat, the package name includes the package version along with its platform (i386 for Intel PCs) and the .rpm extension. An example of the Emacs editor's RPM package for Intel systems is shown here:

emacs-21.2-18.i386.rpm

The RPM packages on your DVD-ROM or distribution CD-ROM represent only a small portion of the software packages available for Linux. An extensive repository for RPM packages is also located at rpmfind.net. Packages here are indexed according to distribution, group, and name. The site includes packages for every distribution, including Red Hat.

Tip 

RPM packages with the term noarch are used for architecture-independent packages. This means that they are designed to install on any Linux system. Packages without noarch may be distribution- or architecture-dependent, designed to install on a particular type of machine.

You could place these packages in a directory on your system, and then use either rpm or a GUI RPM utility such as the redhat-config-packages tool to install it. Normally, you should always try to use the version of the RPM package set up for your Red Hat distribution; for instance, if you run Red Hat 9.0, it is best to download the software package designated for Red Hat 9.0 instead of downloading the same package for Red Hat 7.3. Packages for specific releases will be kept in the release directories. In many cases, attempting to install an RPM package meant for a different distribution may fail.

Installing from the Desktop: redhat-config-packages

The redhat-config-packages tool provides an effective and easy-to-use interface for managing the Red Hat RPM packages provided by your Red Hat distribution, whether you installed from CD-ROMs, DVD-ROM, hard disk, or network. It runs on any window manager, including GNOME and KDE. You can access redhat-config-packages using the Packages icon in the System Settings window. This opens a Package Management window that initially displays a listing of package categories from which you can install packages. See Chapter 4 for more details.

Tip 

You can also install a particular RPM package directly. First display it with the file manager, and then double-click it. This invokes the redhat-config-packages tool, which installs the package. It also checks for dependent packages and installs those also. If you are using CD-ROMs instead of the DVD-ROM, you will be prompted to insert any other CD-ROMs as needed.

Updating Software

You can update your Linux system automatically using a distribution update agent like the Red Hat Network. You can also manually download packages using an FTP client, Web browser, or the GNOME or KDE file managers, and then use the rpm command or the redhat-config-packages tool to install the software.

For redhat-config-packages, you can use your file manager to locate the RPM file and double-click the RPM package file. You can also, on GNOME, right-click it, and select Open With | Install Packages, or on KDE, select Install Package. redhat-config-packages starts up and checks for any dependent packages you may need. It then installs the RPM package for you.

If you are using the rpm command, you use the -U option to upgrade packages. In the following example, the rpm command with the -Uvh option installs an upgrade for Emacs:

# rpm -Uvh emacs-21.2-18.i386.rpm

Command Line Installation: rpm

If you do not have access to the desktop, or you prefer to work from the command line interface, you can use the rpm command to manage and install software packages. rpm is the command that actually performs installation, removal, and queries of software packages. In fact, redhat-config-packages uses the rpm command to install and remove packages. An RPM package is an archive of software files that include information about how to install those files. The filenames for RPM packages end with .rpm, indicating software packages that can be installed by the Red Hat Package Manager.

The rpm Command

With the rpm command, you can maintain packages, query them, build your own, and verify the ones you have. Maintaining packages involves installing new ones, upgrading to new versions, and uninstalling packages. The rpm command uses a set of options to determine what action to take. In addition, certain tasks, such as installing or querying packages, have their own options that further qualify the kind of action they take. For example, the -q option queries a package, but when combined with the -l option, it lists all the files in that package. Table 29-3 lists the set of rpm options. The syntax for the rpm command is as follows (rpm-package-name is the name of the software package you want to install):

rpm options rpm-package-name
Table 29-3: Red Hat Package Manager (RPM) Options

Mode of Operation

Effect

rpm -ioptions package-file

Installs a package; the complete name of the package file is required.

rpm -eoptions package-name

Uninstalls (erases) a package; you only need the name of the package, often one word.

rpm -qoptions package-name

Queries a package. An option can be a package name, a further option and package name, or an option applied to all packages.

rpm -Uoptions package-name

Upgrades; same as install, but any previous version is removed.

rpm -Foptions package-name

Upgrades, but only if package is currently installed.

rpm -verifyoptions

Verifies a package is correctly installed; uses same options as query. You can use -V or -y in place of -verify.

--percent

Displays percentage of package during installation.

--replacepks

Installs an already-installed package.

--replacefiles

Replaces files installed by other packages.

--redhatprovides dependent-files

Searches for dependent packages.

--oldfiles

Installs an older version of a package already installed.

--test

Tests installation; does not install, only checks for conflicts.

-h

Displays # symbols as package is installed.

--excludedocs

Excludes documentation files.

--nodeps

Installs without doing any dependency checks (dangerous).

--force

Forces installation despite conflicts (dangerous).

Uninstall Options (to be used with -e)

 

--test

Tests uninstall. Does not remove, only checks for what is to be removed.

--nodeps

Uninstalls without checking for dependencies.

--allmatches

Removes all versions of package.

Query Options (to be used with -q)

 

package-name

Queries package.

-qa

Queries all packages.

-qf filename

Queries package that owns filename.

-qR

List packages on which this package depends.

-qp package-name

Queries an uninstalled package.

-qi

Displays all package information.

-ql

Lists files in package.

-qd

Lists only documentation files in package.

-qc

Lists only configuration files in package.

-q --dump

Lists only files with complete details.

General Options (to be used with any option)

 

-vv

Debugs; displays descriptions of all actions taken.

--quit

Displays only error messages.

--version

Displays rpm version number.

--help

Displays detailed use message.

--rootdirectory

Uses directory as top-level directory for all operations (instead of root).

--dbpathdirectory

Uses RPM database in the specified directory.

--dbpath cmd

Pipes output of RPM to the command cmd.

--rebuilddb

Rebuilds the RPM database; can be used with the -root and -dbpath options.

--initdb

Builds a new RPM database; can be used with the -root and -dbpath options.

Other Sources of Information

 

www.rpm.org

The RPM Web site with detailed documentation.

RPM Man page (man rpm)

Detailed list of options.

A complete description of rpm and its capabilities is provided in the online manual:

# man rpm

Querying Information from RPM Packages and Installed Software

The -q option tells you if a package is already installed, and the -qa option displays a list of all installed packages. Piping this output to a pager utility, such as more, is best.

# rpm -qa | more

In the next example, the user checks to see if Mozilla is already installed on the system. Notice the full filename of the RPM archive is unnecessary. If the package is installed, your system has already registered its name and where it is located.

# rpm -q mozilla
mozilla-1.0.1-24

You can combine the q option with the i or l option to display information about the package. The option -qi displays information about the software, such as the version number or author (-qpi queries an uninstalled package file). The option -ql displays a listing of all the files in the software package. The --h option provides a complete list of rpm options. Common query options are shown in Table 29-4.

Table 29-4: Query Options for Installed Software

Option

Meaning

-q application

Checks to see if an application is installed.

-qa application

Lists all installed RPM applications.

-qf filename

Queries applications that own filename.

-qR application

Lists applications on which this application depends.

-qi application

Displays all application information.

-ql application

Lists files in the application.

-qd application

Lists only documentation files in the application.

-qc application

Lists only configuration files in the application.

Tip 

Keep in mind the distinction between the installed software package name and the package filename. The filename ends in a .rpm extension and can only be queried with a p option.

To display information taken directly from an RPM package, you add the p qualifier to the q options as shown in Table 29-5. The -qpi combination displays information about a specific package, and -qpl displays a listing of the files a given RPM package contains. In this case, you must specify the entire filename of the RPM package. You can avoid having to enter the entire name simply by entering a unique part of the name and using the * filename- matching character to generate the rest.

Table 29-5: Query Options for RPM Packages

Option

Meaning

-qpi RPM-file

Displays all package information in the RPM package.

-qpl RPM-file

Lists files in the RPM package.

-qpd RPM-file

Lists only documentation files in the RPM package.

-qpc RPM-file

Lists only configuration files in the RPM package.

-qpR RPM-file

Lists packages on which this RPM package depends.

If your RPM query outputs a long list of data, like an extensive list of files, you can pipe the output to the more command to look at it screen by screen, or even redirect the output to a file.

# rpm -ql mozilla | more
# rpm -qpl emacs-21.2-18.i386.rpm  > mytemp

Installing and Updating Packages with rpm

You use the -i option to install new packages and the -U option to update currently installed packages with new versions. With an -e option, rpm uninstalls the package. If you try to use the -i option to install a newer version of an installed package, you will receive an error saying the package is already installed. When a package is installed, RPM checks its signature, using imported public keys from the software vendor. If the signature check fails, an error message is displayed, specifying NOKEY if you do not have the appropriate public key. If you want to install over an already installed package, you can force installation with the --replacepks option. Sometimes a package will include a file, such as a library, that is also installed by another package. To allow a package to overwrite the file installed by another package, you use the --replacefiles option. Many packages depend on the libraries installed by other packages. If these dependent packages are not already installed, you will first have to install them. RPM informs you of the missing dependent files and suggests packages to install. If no packages are suggested, you can use the --redhatprovides option with the missing files to search for needed packages.

The -U option also installs a package if it is not already installed, whereas the -F option will only update installed packages. If the package includes configuration files that will overwrite currently installed configuration files, it will save a copy of each current configuration file in a file ending with .rpmsave, such as /etc/mtools.conf.rpmsave. This preserves any customized configuration changes you may have made to the file. Be sure to also check for configuration compatibilities between the previous and updated versions. If you are trying to install a package that is older than the one already installed, then you need to use the --oldpackages option.

# rpm -Uvh mozilla-1.0.1-24.i386.rpm

If you are installing from a CD-ROM, you can change to the CD-ROM's RPMS directory, which holds the RPM packages (the RPMS directory may be located within a directory like RedHat on the Red Hat CD-ROM). An ls command lists all the software packages. If you know how the name of a package begins, you should include that with the ls command and an attached *. The list of packages is extensive and does not all fit on one screen. This is helpful for displaying the detailed name of the package. The following example lists most X Window System packages:

# ls x*

Installation Example

In the next example, the user first installs a new package with the -i option, and then updates a package with the -U option. Including the -v and -h options is customary. Here, -v is the verbose option that displays all files as they are installed, and -h displays a crosshatch symbol periodically to show RPM is still working. In the following example, the user installs the software package for the Balsa mail client. Notice the full filename is entered. To list the full name, you can use the ls command with the first few characters and an asterisk, ls balsa*. The rpm command with the -q option is then used to check that the software was installed. For installed packages only, the software name needs to be used—in this case, balsa-1.2.4-7.

 [root@turtle mypackages]# ls balsa*
balsa-1.2.4-7.i386.rpm
[root@turtle mypackages]# rpm -ivh balsa-1.2.4-7.i386.rpm
balsa-1.2.4-7                 ########################################
[root@turtle mypackages]# rpm -q balsa
balsa-1.2.4-7

To display information about the installed package, use -qi, and -ql displays a listing of the files a given RPM package contains.

# rpm -qi balsa
# rpm -ql balsa

If you are worried that a software package will install on your system incorrectly, you can use the test option (--test) in the debug mode (vv) to see exactly what actions RPM will take.

# rpm -ivv --test balsa-1.2.4-7.i386.rpm

Removing RPM Software Packages

To remove a software package from your system, first use rpm -q to make sure it is actually installed. Then use the -e option to uninstall it. You needn't use the full name of the installed file. You only need the name of the application. For example, if you decide you do not need Balsa, you can remove it using the -e option and the software name, as shown here:

# rpm  -e  balsa

Verifying an RPM Installation

You can use the verify option (-V) to see if any problems occurred with the installation. RPM compares the current attributes of installed files with information about them placed in the RPM database when the package was installed. If no discrepancies exist, RPM outputs nothing. Otherwise, RPM outputs a sequence of eight characters, one for each attribute, for each file in the package that fails. Those that do not differ have a period. Those that do differ have a corresponding character code, as shown in Table 29-6.

The following example verifies the ProFTPD package:

[root@turtle mypackages]# rpm -V proftpd
Table 29-6: RPM Discrepancy Codes

Attribute

Explanation

5

MD5 checksum

S

File size

L

Symbolic link

T

File modification time

D

Device

U

User

G

Group

M

Mode (includes permissions and file types)

To compare the installed files directly with the files in an RPM package file, you use the -Vp option, much like the -qp option. To check all packages, use the -Va option as shown here:

# rpm -Va

If you want to verify a package, but you only know the name of a file in it, you can combine verify with the -f option. The following example verifies the RPM package containing the ftp command:

# rpm -Vf  /bin/ftp

Rebuilding the RPM Database

RPM maintains a record of the packages it has installed in its RPM database. You may, at times, have to rebuild this database to ensure RPM has current information on what is installed and what is not. Use the --rebuilddb option to rebuild your database file:

#  rpm --rebuilddb

To create a new RPM database, use the --initdb option. This option can be combined with --dbpath to specify a location for the new database.



Previous Section
 < Day Day Up > 
Next Section
This HTML Help has been published using the chm2web software.