Using RPM for Software Management


RPM was derived (in part) from early Linux package management softwarenamed RPP, PMS, and PMthat were written in Perl. RPM was first used with Red Hat Linux 2.0 in late 1995, and then rewritten in C for the Red Hat Linux 3.0.3 (Picasso) release in 1996. Since then, the rpm command has been the prime feature of Red Hat's unique software management system, which is based on the concept of pristine sources, or the capability to use a single, initial archive of a program's source code to build packages for different systems and to track versions. With the release of Red Hat 8.0 (Psyche) in 2002, Red Hat offered a slightly updated graphical management interface for its venerable RPM application.

In addition to improving the package management of early software management scripts, RPM version 4.1 introduced software features designed to ease the task of building software for different platforms from a single set of source-code files. Changes can be tracked and kept outside a developer's initial source code and multiple packages can be built from scratch and installed at the same timesimultaneously, RPM also verifies installation dependencies. Additional features, such as a checksum and GNU Privacy Guard (GPG) signatures, enable binary software packages to be safely distributed without the fear of virus infection or the inclusion of Trojan code.

The rpm command uses the RPM system to install, remove (erase), upgrade, verify, and build software archives known as .rpm files. These archives, or packages, contain package identification (a signature), checksums (mathematically derived validation values), and an archive of the software, either in source or binary form. An .rpm package also contains quite a bit of additional information, such as a name, version, and basic description, and can include pre- and post-installation scripts used for software installation, erasure, or upgrading.

The RPM database installed on your computer keeps track of which versions of which packages are installed. RPM uses your system's /var/lib/rpm directory to store files (actually databases) containing information about the software installed on your system. You can use the ls command to view these files (you might see file sizes different from those shown here, depending on the amount of software you have installed):

total 49288 -rw-r--r-- 1 rpm rpm  5488640 Oct 24 21:05 Basenames -rw-r--r-- 1 rpm rpm    12288 Oct 23 21:21 Conflictname -rw-r--r-- 1 rpm rpm  2150400 Oct 24 21:05 Dirnames -rw-r--r-- 1 rpm rpm  5386240 Oct 24 21:05 Filemd5s -rw-r--r-- 1 rpm rpm    28672 Oct 24 21:05 Group -rw-r--r-- 1 rpm rpm    20480 Oct 24 21:05 Installtid -rw-r--r-- 1 rpm rpm    45056 Oct 24 21:05 Name -rw-r--r-- 1 rpm rpm 37601280 Oct 24 21:05 Packages -rw-r--r-- 1 rpm rpm   331776 Oct 24 21:05 Providename -rw-r--r-- 1 rpm rpm    98304 Oct 24 21:05 Provideversion -rw-r--r-- 1 rpm rpm    12288 Oct 23 21:28 Pubkeys -rw-r--r-- 1 rpm rpm   397312 Oct 24 21:05 Requirename -rw-r--r-- 1 rpm rpm   192512 Oct 24 21:05 Requireversion -rw-r--r-- 1 rpm rpm    94208 Oct 24 21:05 Sha1header -rw-r--r-- 1 rpm rpm    49152 Oct 24 21:05 Sigmd5 -rw-r--r-- 1 rpm rpm    12288 Oct 23 21:21 Triggername


The primary database of installed software is contained in the file named Packages. As you can see from the preceding example, this database can grow to 37MB (and perhaps larger) if you perform a full installation of Fedora (more than 4GB of software). After you install Fedora, rpm and related commands will use this directory during software management operations.

Command-Line and Graphical RPM Clients

As a Fedora system administrator, you will use the rpm command or the Fedora Core graphical clients to perform one of five basic tasks. These operations, which must be conducted by the root operator, include the following:

  • Installing new software

  • Erasing or removing outdated or unneeded packages

  • Upgrading an installed software package

  • Querying to get information about a software package

  • Verifying the installation or integrity of a package installation

The rpm command has more than 60 command-line options, but its administrative functions can be grouped according to the previous five types of action. Graphical RPM clients provide easy-to-use interfaces to these operations. As a system administrator, you have a choice between using a graphical interface and using rpm's various command-line options. The general format of an rpm command is

# rpm option packagename


The basic options look like this:

  • -i Installs the selected package or packages

  • -e Erases (removes) the selected package or packages

  • -U Removes the currently installed package, and then installs software with the contents of the selected package or packages, leaving the existing configuration files

  • -q Queries the system or selected package or packages

  • -V Verifies installed or selected package or packages

Two Handy Options

By appending vh to any option, you get

v

Some status feedback

h

Hash marks as the work proceeds


Many additional options can also be added to or used in conjunction with these options. These are summarized in the following table:

Option

Used To

rpm-i

Install a package.
Useful options to -i:
--excludedocs: Does not install documentation to save space.
--replacepkgs: Replaces the package with a new copy of itself.
--force: The "big hammer"Ignores all warnings and installs anyway.
--noscripts: Does not execute any pre- or post-install scripts.
--nodeps: Ignores any dependencies.
--root path: Sets an alternative root to path.

rpm -e

Erase (deletes) a package.
Useful option to -e:
--nodeps: Ignores any dependencies.

rpm -U

Upgrade a package, removing the older one but keeping modified files, such as configurations.
Useful options to -U:
--oldpackage: Permits downgrading to an older version.
Other options are the same as with rpm -i.

rpm -q

Query about package information
Useful options to -q:
-p file: Displays all information about the package file.
-f file: What package owns the file file?
--whatprovides x: Determines what packages provide x.
--whatrequires x: Determines what packages require x.
-i: Summarizes the package information.
-l: Lists the files in package.
--scripts: Displays the contents of any install, uninstall, or verifies scripts.
--provides: Displays the capabilities package provides.
--requires: Displays the capabilities package requires.

rpm -V

Verify packages against the RPM database
Useful options to -V:
-a: Verifies all installed packages.

rpm -K

Use GPG to verify a downloaded package.
Useful options to -K:
--nosignature: If you lack public GPG encryption keys, do not have GPG installed, or are legally prohibited from using GPG, this still verifies the package
using size and MD5 checksums.


Details on obtaining the Fedora public GPG encryption key and using it are at http://www.rpm.org/max-rpm/s1-rpm-checksig-using-rpm-k.html.


RPM is for Programmers, Too!

Remember that RPM was created not only to provide an easy to use administrative tool, but also as a developer's tool for use in multiplatform source-code package management. Programmers using rpm for development and distribution will use its rpmbuild command, along with a myriad of additional command-line flags. RPM can be used to build binaries, execute programs, test installations, verify and sign packages, build source packages, track versions, and target builds for specific architectures. Details can be found at the RPM home page (listed in the "Reference" section at the end of this chapter).


Using rpm on the Command Line

Because the new graphical RPM client can only install and uninstall RPM packages (for nowmore functionality is promised), you will still end up administering RPM packages from the command line. You can perform all five basic rpm operations using the rpm command from the command line. This section gives you an introduction to performing those operations. It also provides examples of how to install, verify, query, remove, and upgrade a software package.

The most common rpm operation is software installation. Using rpm is an easy way to keep track of installed software, and it can be used to quickly remove undesired packages. Use the -i option, along with the full or partial name (using regular expressions) of a software package, to install software with rpm. For example, to install the unace archiving package, use the rpm command like this:

# rpm -ivh http://mirrors.zoreil.com/plf.zarb.org/mandrake/10.0/ i586/unace-2.2-2plf.i586.rpm Retrieving http://mirrors.zoreil.com/plf.zarb.org/mandrake/10.0/ i586/unace-2.2-2plf.i586.rpm warning: /var/tmp/rpm-xfer.48amVs: V3 DSA signature: NOKEY, key ID 8df56d05 Preparing...                ########################################### [100%]    1:unace ########################################### [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 our 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 unace archiving package, use the rpm command like this:

# rpm -V unace


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 be different from that shown here):

# rpm -qi yum Name        : yum                         Relocations: (not relocatable) Version     : 2.4.0                            Vendor: Red Hat, Inc. Release     : 0.fc4 Build Date:  Tue 16 Aug 2005 06:43:52  PM BST Install Date: Sun 23 Oct 2005 04:39:48 PM BST Build Host:  decompose.build.r edhat.com Group       : System Environment/Base       Source RPM: yum-2.4.0-0.fc4.src.rpm Size        : 1267012                          License: GPL Signature   : DSA/SHA1, Tue 13 Sep 2005 07:30:33 PM BST, Key ID b44269d04f2a6fd2 Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> 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-2.4.0-1.rpm Preparing...                ########################################### [100%]    1:yum                   ########################################### [100%]


Note that it was not necessary to remove the currently installed software packagethe 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 will be 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 (refer to Chapter 5, "First Steps with Fedora," for additional information on grep and sort); here's how to do that search:

# rpm -qa | grep mail | sort fetchmail-6.2.5-7.fc4.1 mailcap-2.1.19-1 mailx-8.1.1-44 procmail-3.22-16 sendmail-8.13.4-2 system-switch-mail-0.5.25-4 system-switch-mail-gnome-0.5.25-4


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!


Package Organization with RPM

Software packages on your Fedora system are organized into various groups, as you see later in this chapter. Using a group organization helps Fedora keep software organized by category and provides for hierarchical listings of software when using graphical RPM clients. You never have to manipulate these groups, but understanding the concept of package organization can help you gain familiarity with the way Fedora works.

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 7.1, the Midnight Commander is displaying 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 will be displayed. In the listing, you can browse the file structure of the RPM file and use mc to copy files from it.

Figure 7.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 a .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


Using pirut for Software Management

The Fedora graphical package management tool identified in the menu as Add/Remove Software is actually an application named pirut. This application replaces kpackage, gnorpm, and xrpmall of which are no longer provided. Add/Remove Software allows you to select packages arranged in categories and install or remove them. With the addition of yum to Fedora, you can now add your own packages to the Fedora graphical tools' database, improving its usefulness over earlier versions.

Launch the Fedora GUI package manager by clicking the Applications menu on your desktop, and then choose Add/Remove Software. You will be asked for the super-user password and then the package management tool launches with the package-browsing screen, shown in Figure 7.2.

Figure 7.2. The initial screen of pirut allows you to browse through packages sorted by groups.


The packages listed in the screen are organized into broad categories, with subcategories listed on the right side. Tick the box next to each subcategory to select the default packages for it. The numbers to the bottom of the package group window indicate the number of packages installed on your system and the total number of packages available in the group. In Figure 7.3, you can see that 37 of 53 possible GNOME packages have been installed.

Figure 7.3. All three of the window managers have been selected in this view.


You can see brief information about the subcategories in the box below the selection. Use the Optional Packages button to get access to all the optional packages related to that subcategory. Simply tick each box to select that package, and click close to return to the main window. Clicking the Apply button starts the download and installation process, which can take some time depending on the amount of packages you specify.

pirut also allows you to search for specific packages, as well as to browse through a long list of packages. Just tick each package you want to install and click the Apply button. With the search function, pirut will remember each package that you tick, so you can use it again and again to build up a list of required packages.



Red Hat Fedora 5 Unleashed
Red Hat Fedora 5 Unleashed
ISBN: 067232847X
EAN: 2147483647
Year: 2004
Pages: 362

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net