Using RPM for Software Management

 < Day Day Up > 

RPM was derived (in part) from early Linux package management software named RPP, PMS, and PM that 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 time simultaneously, 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. A .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):

 $ ls -l /var/lib/rpm total 53820 -rw-r--r--    1 rpm      rpm       5423104 Oct 14 19:53 Basenames -rw-r--r--    1 rpm      rpm         12288 Oct 14 12:32 Conflictname -rw-r--r--    1 root     root        16384 Oct 14 17:31 __db.001 -rw-r--r--    1 root     root      1318912 Oct 14 17:31 __db.002 -rw-r--r--    1 root     root       458752 Oct 14 17:31 __db.003 -rw-r--r--    1 rpm      rpm       1179648 Oct 14 19:53 Dirnames -rw-r--r--    1 rpm      rpm       5521408 Oct 14 19:53 Filemd5s -rw-r--r--    1 rpm      rpm         24576 Oct 14 19:53 Group -rw-r--r--    1 rpm      rpm         20480 Oct 14 19:53 Installtid -rw-r--r--    1 rpm      rpm         45056 Oct 14 19:53 Name -rw-r--r--    1 rpm      rpm      41070592 Oct 14 19:53 Packages -rw-r--r--    1 rpm      rpm        348160 Oct 14 19:53 Providename -rw-r--r--    1 rpm      rpm         98304 Oct 14 19:53 Provideversion -rw-r--r--    1 rpm      rpm         12288 Oct 14 19:53 Pubkeys -rw-r--r--    1 rpm      rpm        237568 Oct 14 19:53 Requirename -rw-r--r--    1 rpm      rpm        176128 Oct 14 19:53 Requireversion -rw-r--r--    1 rpm      rpm         94208 Oct 14 19:53 Sha1header -rw-r--r--    1 rpm      rpm         49152 Oct 14 19:53 Sigmd57 -rw-r--r--    1 rpm      rpm         12288 Oct 14 19:53 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 33MB (and perhaps larger) if you perform a full installation of Fedora Core (more than 4GB of software). After you install Fedora Core Linux, rpm and related commands will use this directory during software management operations.

Command-Line and Graphical RPM Clients

As a Fedora Core Linux 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 will 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

Erases (deletes) a package.

 

Useful option to -e:

 

--nodeps: Ignores any dependencies.

rpm -U

Upgrades 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

Queries 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

Verifies packages against the RPM database

 

Useful options to -V:

 

-a: Verifies all installed packages.


rpm K

Uses 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 Core 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 multi-platform 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 now more functionality is promised), you will still end up administering RPM packages from the command line. You can perform all the 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 will display 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 unace Name        : unace                        Relocations: (not relocateable) Version     : 2.2                               Vendor: Penguin Liberation Front Release     : 2plf                          Build Date: Sat 01  Mar 2003 12:13:48 PM EST Install date: Tue 02 Sep 2003 03:46:28 PM EDT      Build Host: baader.subversion.alt Group       : Archiving/Compression         Source RPM: unace-2.2-2plf.src.rpm Size        : 401368                           License: freeware Packager    : Guillaume Rousse <guillomovitch@zarb.org> URL         : http://www.winace.com Summary     : Decompressor for .ace format archives Description : Unace is a utility to extract, view, and test the contents of an ACE archive. 

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 unace-2.2-2plf.i586.rpm Preparing...                ########################################### [100%]    1:unace                   ########################################### [100%] 

Note that it wasn't 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 will fetch 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 (see 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.0-7 mailcap-2.1.14-1.1 mailx-8.1.1-31.1 mozilla-mail-1.4.1-8 procmail-3.22-11 sendmail-8.12.10-1.1 sendmail-cf-8.12.10-1.1 

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 Core Linux system are organized into various groups, as you see later in this chapter. Using a group organization helps Fedora Core 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 Core Linux 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 

Graphical Package Management

The Fedora graphical package management tool identified in the menu as Add/Remove Software is actually an application named system-config-packages. This application replaces kpackage, gnorpm, and xrpm all 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 Core, you may now add your own packages to the Fedora Core graphical tools' database, improving its usefulness over earlier versions.

Launch the Fedora GUI package manager by clicking the Start button on your desktop, and then choose System Settings, Add/Remove Applications. The package management tool launches with the Add and Remove Software screen, shown in Figure 7.2.

Figure 7.2. The initial screen of the package management tool will look familiar if you installed Fedora Core; it's the package selection screen used by the installation program.


The packages listed in the screen are organized into the Desktops, Applications, Servers, Development, and Systems groups. To choose individual package groups for installation or removal click details next to the subgroup. The numbers to the right of the package group name indicate the number of packages installed on your system and the total number of packages available in the group. In Figure 7.2, you can see that 37 of 44 possible GNOME packages have been installed.

Under the details for each subgroup, simply select the packages you want to remove. Note that you can only access the Extra Packages; to remove the base packages, you need to uncheck the box next to the name of the subgroup.

Figure 7.3. The Standard Packages listing (collapsed in this view) details the base packages installed when the main category is selected. Extra Packages are those that you have the option of installing.


     < Day Day Up > 


    Red Hat Fedora 4 Unleashed
    Red Hat Fedora 4 Unleashed
    ISBN: 0672327929
    EAN: 2147483647
    Year: 2006
    Pages: 361

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