Chapter 5. RPM

Installing new packages to your Linux system

The Red Hat Package Manager (RPM) provides an easy way to install, remove, and verify files on your system.

Each program set (such as Apache) comes as a single file with an .rpm extension. After installing the .rpm file, all the files needed for installation are placed in the appropriate place, ready for running, including man pages, configuration files, and other documentation.

The advantages to the .rpm format are many:

  • Dependencies—. Since you may have instances where one package depends on another, RPM has dependencies to alert you if a library or other package is missing. If you do have the other files already installed and RPM doesn't know about it, such as if you compiled from source, you can tell the RPM to ignore dependency rules by using the --nodeps command to the rpm program.

  • Convenient installation (typically one command to install)—. A typical fresh install of a package consists of a command of the form rpm -i package-1.0-1.i386.rpm. To find out what files would be installed if you installed the entire package, you can use rpm -qlp package-1.0-1.i386.rpm. You'll then get a list of what files are in the package and where they will be installed. To find out the details of a particular .rpm file, you can use rpm -qip package-1.0-1.i386.rpm to get a list of the package name, description, build information, size of the installed package, and other information. This can be handy if you have a large number of .rpm files and don't know what they're for.

  • Convenient upgrading and removal—. Upgrading the version of an existing package just uses the -U option instead of the -i switch to the rpm command. Since you can install two packages of the same kind using -i, it's advisable to use the upgrade switch when in doubt. Use the -e switch to remove packages. If there are dependencies that would break if you removed a package, you will get an error message from the RPM. You can get around this by using the --nodeps option. This isn't really advisable since some system programs may be affected. For example, glint (see below) uses Tcl/TK. Removing Tcl/TK from your system would generate an error saying that glint depends on Tcl/TK.

  • Easy to see what is installed on your system—. The -q switch allows you to query the RPM database. You can query a specific package to see if it's installed (such as rpm -q apache) or get a list of the files that are part of a package and where they're located (using the -ql switch, such as rpm -ql apache). If you don't know the name of the package you're looking for, you can use the -qa switch to list all installed packages and grep for the package you're looking for. For example, Netscape is installed as netscape-communicator, netscape-common, and netscape-navigator. Using rpm -q netscape, you won't find the package, but -qa will. In addition, if you want to find out what RPM package "owns" a particular file, you can use the -qf switch followed by the file. If that file is listed in RPM's database, it will report which RPM package owns that file.

  • Easy system verification—. If you suspect there are problems with your system and want to verify that packages are installed properly, you can use the -V option to rpm to verify packages. RPM stores file sizes, modes, MD5 sums, and other information. This option will let you quickly see if a file has been erased or modified since you installed it. If you find a problem, you can use the -U switch to reinstall the package to its original form. You can verify all packages on your system with the command rpm -Va. If the verification passes, you won't see any output. If a particular test fails, you'll get a list of eight characters, followed by a "c" if it's a configuration file, followed by the name of the file. These eight characters can be:

    5 - MD5 checksum failed.

    S - File size.

    L - Symbolic link.

    T - File modification time.

    D - Device file.

    U - User (file owner).

    G - Group (group owner).

    M - File mode.

    If you modified a configuration file, such as for Apache, you can expect to see at least one or more of the above failures. If you see this on a file like /bin/su or /bin/login, it may indicate a breakin attempt.

  • Graphical interface available—. It provides a graphical way to see what packages are installed, install new packages, verify package files, and list files in a package. If you have the install CD, you can install files directly from the CD. This provides a user-friendly way to install packages. There are other programs to install RPM files as well, such as kpackage for the KDE Window Manager.

Binary RPM Installation

RPM files typically have the following filename syntax:

package-1.0-1.i386.rpm

This syntax tells you the following four things:

  • package—. The name of the package, usually the same name as the RPM package name.

  • 1.0—. Version number of the package. This usually refers to the version of the original source, not the RPM version.

  • 1—. Release number of the package. This refers to the RPM build, so if package-1.0 was made into an RPM file again (either because of a configuration error or other change), the next version would be called package-1.0-2.i386.rpm.

  • i386—. Architecture for the build. You'll typically see i386, sparc, or alpha. You might see i586 or i686, which refer to packages built with a Pentium or Pentium-Pro-specific compiler. If you're not sure and there's a choice, go for the i386 version.

Source RPM (SRPM)

Source RPMs contain the source code for an application that either must be compiled on each individual system, or allow you to modify source code or pre-compile options before installing the software. One example of this is a program that depends on a particular library release. Another example is compiling a package to be Pentium-specific, using pgcc to compile the package instead of gcc or egcs. After SRPM installation, you can compile the package into a binary RPM, then install the binary RPM just like a pre-compiled package. Many SRPM files contain the original source code as a .tar.gz file, along with patches for it to compile as an SRPM, or to add extra functionality.

To build a SRPM into a binary, do the following:

  1. Install the source RPM file (rpm -Uvh file-2.1.src.rpm).

  2. Go to the SPECS directory (cd /usr/src/redhat/SPECS).

  3. Create a binary RPM from the source spec (rpm -bb -clean file-2.1.spec).

  4. Install the binary RPM (cd /usr/src/redhat/RPMS/i386 ; rpm -UVH file-2.1.rpm).

  5. Uninstall the source RPM (cd /usr/src/redhat/SPECS ; rpm - rmsource file-2.1.spec).

  6. Remove the source RPM (rm file-2.1.src.rpm).

Other RPM Utilities

In this section, we'll cover some of the utilities that make using RPM fairly painless.

RPMFIND

In case you ever wanted to find an RPM file, but didn't know where to look, there's the rpmfind program. A list of known RPM files are kept at rpmfind.net, and in most cases, copies of the RPMs are there as well. The client application, called rpmfind, can search for an application name (a search for mkisofs, for example), can search for updates to an RPM, and also gives the option to download dependent packages. Unfortunately, rpmfind is not included with Red Hat, as it's not part of the distribution. You can get an RPM of the application at http://www.rpm-find.net.

RPM2CPIO

The rpm2cpio program converts a given RPM file to a file format that can be used with the cpio program. This is mostly useful for those who are using distributions not based on Red Hat, but it can also be helpful if you're running Red Hat. If you feel you may have conflicts between two RPMs, or want to install only a few files from a given RPM, you can convert the RPM to a cpio file. The syntax of rpm2cpio is rpm2cpio file.rpm file.cpio. The resulting cpio program can be extracted using cpio -e file, where -e represents "extract". After extracting the cpio file, you can move, install, or whatever. The only problem with this is that files installed in this manner won't be tracked by RPM. Additionally, you won't be able to use regular rpm commands on the installed files.

Kpackage

The kpackage file runs under the KDE Window Manager. It provides for management of .rpm, .DEB (debian), and cpio files. Packages can be installed, uninstalled, verified, and so on. The kpackage program is not included as part of the KDE installation on the Red Hat CD-ROM, but can be found at the KDE Web site http://www.kde.org/.

GnoRPM

The GnoRPM program is included as part of the Red Hat installation and runs under the GNOME windowing system. If you're familiar with the older glint application that was with previous Red Hat installs, this program is its replacement. If you're not familiar with glint, here's how GnoRPM works.

RPMs are arranged based on their use, meaning that the PostgreSQL RPMs would be located under Applications/Databases. Depending on what RPMs you have installed, this may be different on your system. Each icon on the left side represents a section (such as Applications or Directories) and the right side lists the contents of the section. In our example of PostgreSQL, the left side would initially contain Applications, while the right side has Directories. Double-clicking Directories moves it to the left side and puts PostgreSQL on the right side. You can then verify, query, or delete the RPM. Verifying makes sure that all files listed in the RPM have the correct permission and ownership, and that all the files exist. Querying lists the files used by the RPM so you know where they're located. Deleting the RPM removes it from the system.

Clicking on a package makes it selected, and clicking on it again unselects it. This allows you to perform the same operation on multiple RPMs (like query or delete).

You can also install RPMs. By default, new RPMs are looked for at /mnt/cdrom/RedHat/RPMS. The /mnt/cdrom directory is the location where the CD-ROM is mounted, given the command mount/dev/cdrom. Assuming the Red Hat installation CD was in the drive, the list of RPMs used to install Red Hat would be located in /mnt/cdrom/RedHat/RPMS. In install mode, the screen will change to show what packages are not installed. You can then select packages to install. Clicking the install button would then install the RPMs on your system and remove them from the install screen.

Summary

  • RPM provides a useful way of managing system files.

  • Source RPM files allow you to compile programs from source with the management of RPM.

  • Numerous utilities exist to assist with .rpm file installation and management.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.200.3