16
RPM: The RPM Package Manager

RPM (LINUX)

Embed Size (px)

Citation preview

RPM: The RPM Package Manager

RPM (RPM Package Manager; www.rpm.org) works only with software packages built for processing by RPM; it can download, install, uninstall, upgrade, query, and verify RPM packages.

The files that hold these packages have a filename extension of .rpm. RPM uses the local RPM installation database to track the locations where software packages are installed, the versions of the installed packages, and the dependencies between the packages.

RPM uses the Berkeley Database (Berkeley DB or BDB) and stores the database files in /var/lib/rpm. RPM forms the basis for yum: yum finds packages, downloads them from repositories, and then calls RPM to install/upgrade/remove the packages.

Querying Packages and FilesThe following rpm command displays a list of one-line summaries of all packages

installed on the system:

$ rpm -qa

mtools-4.0.15-2.fc15.i686

iwl6000-firmware-9.221.4.1-2.fc15.noarch

gnome-desktop3-2.91.93-1.fc15.i686

libmusicbrainz3-3.0.3-3.fc15.i686

dejavu-fonts-common-2.32-2.fc15.noarch

pptp-1.7.2-12.fc15.i686

The –q option queries the package database; the –a option specifies all packages.

Without –a, –q takes the name of a package as an argument and displays information

about that package only. For instance, rpm –q ypserv tells you whether the ypserv

package is installed and, if so, which version is installed. Use the –ql options to list the

files in a package.

$ rpm -q ypserv

package ypserv is not installed

$ rpm -ql logrotate

/etc/cron.daily/logrotate

/etc/logrotate.conf

/etc/logrotate.d

/usr/sbin/logrotate

/usr/share/doc/logrotate-3.7.9

/usr/share/doc/logrotate-3.7.9/CHANGES

/usr/share/doc/logrotate-3.7.9/COPYING

/usr/share/man/man5/logrotate.conf.5.gz

/usr/share/man/man8/logrotate.8.gz

/var/lib/logrotate.status

With the –qi options, rpm displays information about a package:

$ rpm -qi logrotate

Name : logrotate

Version : 3.7.9

Release : 8.fc15

Architecture: i686

Install Date: Wed 23 Mar 2011 05:37:59 PM PDT

Group : System Environment/Base

Size : 84226

License : GPL+

Signature : RSA/SHA256, Mon 21 Mar 2011 03:05:16 PM PDT, Key ID b4ebf579069c8460

Source RPM : logrotate-3.7.9-8.fc15.src.rpm

Build Date : Mon 21 Mar 2011 06:28:12 AM PDT

Build Host : x86-06.phx2.fedoraproject.org

Relocations : (not relocatable)

Packager : Fedora Project

Vendor : Fedora Project

Summary : Rotates, compresses, removes and mails system log files

Description :

The logrotate utility is designed to simplify the administration of

log files on a system which generates a lot of log files. Logrotate

allows for the automatic rotation compression, removal and mailing of

log files. Logrotate can be set to handle a log file daily, weekly,

monthly or when the log file gets to a certain size. Normally,

logrotate runs as a daily cron job.

Install the logrotate package if you need a utility to deal with the

log files on your system.

You can use the –qf options to determine which package a file belongs to; it works

with installed packages only. Use the yum whatprovides command (page 537) to

search repositories for the same information. The following command shows that

more is part of the util-linux package:

$ rpm -qf /bin/more

util-linux-2.19-3.fc15.i686

Include the –p option with other options to query an uninstalled RPM package file:

$ ls ypser*

ypserv-2.24-2.fc15.i686.rpm

$ rpm -qip ypserv-2.24-2.fc15.i686.rpm

Name : ypserv

Version : 2.24

Release : 2.fc15

Installing, Upgrading, and Removing PackagesAlthough it is frequently easier to use yum or gpk-application, you can use rpm to download, install, upgrade, or remove a package. Run rpm with root privileges; although you can run rpm as a nonprivileged user, you will not have permission to write to the necessary directories during an install or uninstall, and the procedure will fail. During a query, you do not need to work with root privileges, so you can and should work as a nonprivileged user. Give the –U (upgrade) option, followed

by the name of the file that contains the RPM version of the package you want to install. The –U option upgrades existing packages and installs new packages (as though you had used the –ioption). For kernels, use –i (not –U) to leave the old kernel intact when you install a new kernel. Add the –v (verbose) option to display more information about what is happening and the –h (or ––hash) option to display hash marks as the package is unpacked and installed.

Installing a package For example, the following command installs the samba package on the local system:

# ls samba*

samba-3.6.0-64pre1.fc15.1.i686.rpm

# rpm -Uvh samba-3.6.0-64pre1.fc15.1.i686.rpm

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

1:samba ########################################### [100%]

When you install a package, the rpm file must be in the working directory, or you

must use a pathname that points to the rpm file. If you specify an FTP or HTTP

URL, rpm will download the package before installing it (but it will not download

or install dependencies):

# rpm -Uvh http://download.fedora.redhat.com/pub/fedora/linux/updates/15/i386/bind-9.8.0-5.P2.fc15.i686.rpm

Removing a

package

The following command removes the samba package. You can give the command

from any directory:

# rpm -e samba

error: Failed dependencies:

samba is needed by (installed) system-config-samba-1.2.91-2.fc15.noarch

When you run this command, rpm reports that another package, system-configsamba,

is dependent on the samba package. To remove the samba package, you have

two choices: You can ignore the dependency by including the rpm ––nodeps option or

you can remove the dependent package and then remove the samba package.

# rpm -e system-config-samba

# rpm -e samba

If you remove the samba package without removing the package that is dependent

on it, the utilities within the dependent package will not work. In the preceding

example, the system-config-samba utility will not work.

When you use rpm to remove a package, rpm queries package database to find the

information it needs to uninstall the package and removes links, unloads device drivers,

and stops daemons as necessary. Refer to the rpm man page for more rpm options.

Installing a Linux Kernel BinaryThe following steps install a Linux kernel binary from an RPM package. If you simply

want to install the latest kernel for the local system, give the command yum

install kernel instead. Refer to Chapter 15 when you want to configure and rebuild

a kernel from source files, rather than installing a new, prebuilt kernel binary.

1. Run rpm with the –i option to install the new kernel. Do not use the –U

option: You are installing a new kernel that has a different name than the

old kernel; you are not upgrading the existing kernel.

2. Make sure the new kernel works before you remove the old kernel. To verify the new kernel works, reboot the system using the new kernel. You might want to wait a while before removing the old kernel to make sure that no problems arise with the new one.

3. When you are satisfied with the new kernel, remove the old kernel using rpm with the –e option; you must specify the kernel version number. If necessary, you can manually remove an old kernel by removing files whose names contain the release number from /boot or / (root). Remove information about the old kernel from grub.conf. Removing the kernel manually is not recommended because it is too easy to miss a file and because it does not remove the kernel from the RPM database.