• Aucun résultat trouvé

The rpm Command Set

Dans le document Linux+ Complete Study Guide CompTIA (Page 110-114)

The main RPM utility program is known as rpm. Use this program to install or upgrade a package at the shell prompt. The rpm command has the following syntax:

rpm [operation][options] [package-files|package-names]

Using RPM 51

Table 2.1 summarizes the most common rpm operations, and Table 2.2 summarizes the most important options. Be aware, however, that rpm is a complex tool, so this listing is nec-essarily incomplete. For information about operations and options more obscure than those listed in Tables 2.1 and 2.2, see the man pages for rpm. Many of rpm’s less-used features are devoted to the creation of RPM packages by software developers.

TA B L E 2 .1 Common rpm Operations

Operation Description

-i Installs a package; system must not contain a package of the same name

-U Installs a new package or upgrades an existing one

-F or --freshen Upgrades a package only if an earlier version already exists -q Queries a package—finds if a package is installed, what files it

contains, and so on

-V or --verify Verifies a package—checks that its files are present and unchanged since installation

-e Uninstalls a package

-b Builds a binary package, given source code and configuration files;

moved to the rpmbuild program with RPM version 4 .2

--rebuild Builds a binary package, given a source RPM file; moved to the rpmbuild program with RPM version 4 .2

--rebuilddb Rebuilds the RPM database to fix errors

TA B L E 2 . 2 Common rpm Options

Option Used with Operations Description

--root dir Any Modifies the Linux system having a root directory located at dir . This option can be used to maintain one Linux installation discrete from another one (say, during OS installation or emergency maintenance) . --force -i, -U, -F Forces installation of a package even

when it means overwriting existing files or packages .

52 Chapter 2 N Managing Software

TA B L E 2 . 2 Common rpm Options (continued)

Option Used with Operations Description

-h or --hash -i, -U, -F Displays a series of hash marks (#) to indicate the progress of the operation . -v -i, -U, -F Used in conjunction with the -h option to

produce a uniform number of hash marks for each package .

--nodeps -i, -U, -F, -e Specifies that no dependency checks be performed . Installs or removes the package even if it relies on a package or file that’s not present or is required by a package that’s not being uninstalled . --test -i, -U, -F Checks for dependencies, conflicts, and

other problems without actually installing the package .

--prefix path -i, -U, -F Sets the installation directory to path (works only for some packages) . -a or --all -q, -V Queries or verifies all packages . -f file or --file file -q, -V Queries or verifies the package that

owns file .

-p package-file -q Queries the uninstalled RPM package-file .

-i -q Displays package information, including

the package maintainer, a short descrip-tion, and so on .

-R or --requires -q Displays the packages and files on which this one depends .

-l or --list -q Displays the files contained in the package .

To use rpm, you combine one operation with one or more options. In most cases, you include one or more package names or package filenames as well. (A package filename is a complete filename, but a package name is a shortened version. For instance, a package file-name might be samba-server-3.0.25b-4.5mdv2008.0.x86_64.rpm, whereas the matching package name is samba-server.) You can issue the rpm command once for each package, or you can list multiple packages, separated by spaces, on the command line. The latter

Using RPM 53

is often preferable when you’re installing or removing several packages, some of which depend on others in the group. Issuing separate commands in this situation requires that you install the depended-on package fi rst or remove it last, whereas issuing a single com-mand allows you to list the packages on the comcom-mand line in any order.

Some operations require that you give a package fi lename, and others require a package name. In particular, -i, -U, -F, and the rebuild operations require package fi lenames; -q, -V, and -e normally take a package name, although the -p option can modify a query (-q) operation to work on a package fi lename.

When you’re installing or upgrading a package, the -U operation is generally the most useful because it allows you to install the package without manually uninstalling the old one. This one-step operation is particularly helpful when packages contain many dependen-cies because rpm detects these and can perform the operation should the new package fulfi ll the dependencies provided by the old one.

To use rpm to install or upgrade a package, issue a command similar to the following:

# rpm -Uvh samba-server-3.0.25b-4.5mdv2008.0.x86_64.rpm

You can also use rpm -ivh in place of rpm -Uvh if you don’t already have a samba-server package installed.

It’s possible to distribute the same program under different names . In this situation, upgrading may fail, or it may produce a duplicate installa-tion, which can yield bizarre program-specific malfunctions . Red Hat has described a formal system for package naming to avoid such problems, but they still occur occasionally . Therefore, it’s best to upgrade a package using a subsequent release provided by the same individual or organiza-tion that provided the original .

Verify that the package is installed with the rpm -qi command, which displays informa-tion such as when and on what computer the binary package was built. Listing 2.1 demon-strates this command. (rpm -qi also displays an extended plain-English summary of what the package is, which has been omitted from Listing 2.1.)

Listing 2.1: RPM Query Output

$ rpm -qi samba-server

Name : samba-server Relocations: (not relocatable) Version : 3.0.25b Vendor: Mandriva

Release : 4.5mdv2008.0 Build Date: Tue 27 May 2008➦

08:39:24 PM EDT

Install Date: Sat 31 May 2008 12:15:20 PM EDT Build Host:➦

linsec.homelinux.org

Group : Networking/Other Source RPM:➦

samba-3.0.25b-4.5mdv2008.0.src.rpm

54 Chapter 2 N Managing Software

Size : 13524400 License: GPL Signature : DSA/SHA1, Tue 27 May 2008 09:38:42 PM EDT,➦

Key ID 9aa8d0d022458a98

Packager : Mandriva Linux Security Team <security@mandriva.com>

URL : http://www.samba.org Summary : Samba (SMB) server programs

Dans le document Linux+ Complete Study Guide CompTIA (Page 110-114)