Выбрать главу

warning: /var/tmp/rpm-xfer.48amVs: V3 DSA signature: NOKEY, key ID 8df56d05

Preparing...        ########################################### [100%]

 1:freshrpms-release

########################################### [100%]

This example uses the v and h options, which provide a more verbose output and display of hash marks to show the progress of the installation. The example also demonstrates the capability of rpm to use HTTP or FTP servers to fetch files for installation. It also shows that rpm can use GPG keys to validate a file. (The key was not installed in the example.)

You can also use rpm to query its database after installing packages to verify an installation. Use the -V option, along with the name of a software package, to verify installation of your system. For example, to verify the freshrpms-release package, use the rpm command like this:

# rpm -V freshrpms-release

NOTE

If everything is correct with your software installation, your system displays no response to rpm -V after you run the command; only problems are displayed.

As you can see from the following program output, you can get additional information about a package by adding additional verification options (such as two more v's) to the -V option. To get more information about an installed package, use one or more forms of the rpm query options. For example, to display concise information about an installed package, use the -q option, along with the i option and the installed package name, like this. (Note that your version will differ from that shown here.)

# rpm -qi yum

Name        : yum                             Relocations: (not relocatable)

Version     : 3.2.7                           Vendor:      Fedora Project

Release     : 1.fc8                           Build Date:  Fri 12 Oct 2007 09:22:34 PM BST

Install Date: Sun 21 Oct 2007 05:20:19 PM BST Build Host:  ppc3.fedora.redhat.com

Group       : System Environment/Base         Source RPM:  yum-3.2.7-1.fc8.src.rpm

Size        : 1712619                         License:     GPLv2+

Signature   : (none)

Packager    : Fedora Project

URL         : http://linux.duke.edu/yum/

Summary     : RPM installer/updater

Description :

Yum is a utility that can check for and automatically download and

install updated RPM packages. Dependencies are obtained and downloaded

automatically prompting the user as necessary.

This form of the rpm query provides quite a bit of information about the software package. (You can also query packages before installation by providing a pathname for them.)

If this package is not up-to-date, you can easily and quickly upgrade the package by downloading a newer version and then using rpm's -U or upgrade option like this:

# rpm -Uvh yum-3.2.0-1.fc8.rpm

Preparing... ########################################### [100%]

1:yum        ########################################### [100%]

Note that it was not necessary to remove the currently installed software package — the U option removes the old version of the software (saving the old configuration files), and then automatically installs the new software.

You can also upgrade your system software by using the rpm command's -F or "freshen" option, which fetches a designated package from a remote FTP or HTTP server. For example, to upgrade the fetchmail-conf package, use rpm like this:

# rpm -Fv ftp://ftp.tux.org/linux/redhat/updates/9/en/os/i386/\

initscripts-7.14-1.i386.rpm

Retrieving ftp://ftp.tux.org/linux/redhat/updates/9/en/os/i386/\

initscripts-7.14-1.i386.rpm

Preparing packages for installation...

initscripts-7.14-1

Use the -e option, along with the name of a software package, to remove or erase software from your system with rpm. For example, to remove the unace archiving package, use the rpm command like this:

# rpm -e unace

Note that if the operation succeeds, no messages are displayed on your system. You can quickly search for the names of installed packages by piping the output of rpm -qa through the grep and sort commands (see Chapter 4, "Command-Line Quick Start," for additional information on grep and sort); here's how to do that search:

# rpm -qa | grep mail | sort

fetchmail-6.3.8-3.fc8

mailcap-2.1.25-1.fc8

mailx-8.1.1-46.fc7

procmail-3.22-20.fc8

sendmail-8.14.1-4.2.fc8

This example returns a sorted list of all packages with names containing the word mail.

NOTE

Another essential feature of the rpm command is its --rebuilddb option. If your system's RPM database becomes corrupted, this is your first (and perhaps only) option for restoring software management services. We hope that you never have to use this option; help ensure that by always backing up your data!

Extracting a Single File from an RPM File

Occasionally, it is useful to extract a single file from an RPM package. You can do so using the command-line version of mc, the Midnight Commander. In Figure 34.1, the Midnight Commander displays the contents of the yum RPM file. The Midnight Commander is a UNIX clone of the famous DOS Norton Commander, a file management utility. Using mc, just highlight the RPM file and press Enter; the contents of the RPM file are displayed. In the listing, you can browse the file structure of the RPM file and use mc to copy files from it.

FIGURE 34.1 A classic two-panel directory view and drop-down menus betray Midnight Commander's DOS inspiration, but it's a full-featured Linux file manager.

You might want to know what an .rpm script will do before you install the application. You can use the F3 key in mc to view the script files. If you want to look at the scripts without using mc, use this command:

# rpm -q --scripts filename > scripts.txt

This command pipes the scripts into a file, where you can examine it with a text editor. You could also pipe it to the less pagination command to view the scripts on your display:

# rpm -q -scripts filename | less

Getting Started with yum