Maximum RPM

Taking the RPM Package Manager to the Limit

Edward C. Bailey

Red Hat, Inc.

%ghost description: Paul Nasrat

Start of updates, epoch, rpmbuild, etc: Matthias Saou

Various typo fixes, %check section, documentation on --recompil: Ville Skyttä

Copyright © 2000 by Red Hat, Inc. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/).

Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.

Revision History
Revision 1.0 17-February-1997
First edition (Produced/printed by Red Hat Software)
Revision 1.1 ??-???-1997
Revised for production by Sams Publishing
Revision 1.2 29-February-2000
Translated into DocBook
Revision 1.3 05-March-2003
Start of the update process

Table of Contents

Preface
Linux and RPM — A Brief History
Parts of the book, and who they're for
Acknowledgements
I. RPM and Computer Users — How to Use RPM to Effectively Manage Your Computer
1. An Introduction to Package Management
What are Packages, and Why Manage Them?
Enter the Package
Manage Your Packages, or They Will Manage You
Package Management: How to Do It?
Ancestors of RPM
RPM Design Goals
Make it easy to get packages on and off the system
Make it easy to verify a package was installed correctly
Make it easy for the package builder
Make it start with the original source code
Make it work on different computer architectures
What's in a package?
RPM's Package Labels
Labels And Names: Similar, But Distinct
Package-wide Information
Per-file Information
Let's Get Started
2. Using RPM to Install Packages
rpm -i — What does it do?
Performing dependency checks:
Checking for conflicts:
Performing any tasks required before the install:
Deciding what to do with config files:
Unpacking files from the package and putting them in the proper place:
Performing any tasks required after the install:
Keeping track of what it did:
Performing an Install
URLs — Another Way to Specify Package Files
A warning message you might never see
Two handy options
Getting a bit more feedback with -v
-h: Perfect for the Impatient
Additional options to rpm -i
Getting a lot more information with -vv
--test: Perform Installation Tests Only
--replacepkgs: Install the Package Even If Already Installed
--replacefiles: Install the Package Even If It Replaces Another Package's Files
--nodeps: Do Not Check Dependencies Before Installing Package
--force: The Big Hammer
--excludedocs: Do Not Install Documentation For This Package
--includedocs: Install Documentation For This Package
--prefix <path>: Relocate the package to <path>, if possible
--noscripts: Do Not Execute Pre- and Post-install Scripts
--percent: Not Meant for Human Consumption
--rcfile <rcfile>: Use <rcfile> As An Alternate rpmrc File
--root <path>: Use <path> As An Alternate Root
--dbpath <path>: Use <path> To Find RPM Database
--ftpport <port>: Use <port> In FTP-based Installs
--ftpproxy <host>: Use <host> As Proxy In FTP-based Installs
--ignorearch: Do Not Verify Package Architecture
--ignoreos: Do Not Verify Package Operating System
3. Using RPM to Erase Packages
rpm -e — What Does it Do?
Erasing a Package
Getting More Information With -vv
Additional Options
--test — Go Through the Process of Erasing the Package, But Do Not Erase It
--nodeps: Do Not Check Dependencies Before Erasing Package
--noscripts — Do Not Execute Pre- and Post-uninstall Scripts
--rcfile <rcfile> — Read <rcfile> For RPM Defaults
--root <path> — Use <path> As the Root
--dbpath <path>: Use <path> To Find RPM Database
rpm -e and Config files
Watch Out!
4. Using RPM to Upgrade Packages
rpm -U — What Does it Do?
Config file magic
Upgrading a Package
rpm -U's Dirty Little Secret
They're Nearly Identical…
--oldpackage: Upgrade To An Older Version
--force: The Big Hammer
--noscripts: Do Not Execute Install and Uninstall Scripts
5. Getting Information About Packages
rpm -q — What does it do?
The Parts of an RPM Query
Query Commands, Part One: Package Selection
Query Commands, Part Two: Information Selection
Getting a lot more information with -vv
--root <path>: Use <path> As An Alternate Root
--rcfile <rcfile>: Use <rcfile> As An Alternate rpmrc File
--dbpath <path>: Use <path> To Find RPM Database
A Few Handy Queries
Finding Config Files Based on a Program Name
Learning More About an Uninstalled Package
Finding Documentation for a Specific Package
Finding Similar Packages
Finding Recently Installed Packages, Part I
Finding Recently Installed Packages, Part II
Finding the Largest Installed Packages
6. Using RPM to Verify Installed Packages
rpm -V — What Does it Do?
What Does it Verify?
When Verification Fails — rpm -V Output
Other Verification Failure Messages
Selecting What to Verify, and How
The Package Label — Verify an Installed Package Against the RPM Database
-a — Verify All Installed Packages Against the RPM Database
-f <file> — Verify the Package Owning <file> Against the RPM Database
-p <file> — Verify Against a Specific Package File
-g <group> — Verify Packages Belonging To <group>
--nodeps: Do Not Check Dependencies During Verification
--noscripts: Do Not Execute Verification Script
--nofiles: Do Not Verify File Attributes
-v — Display Additional Information
-vv — Display Debugging Information
--dbpath <path>: Use <path> To Find RPM Database
--root <path>: Set Alternate Root to <path>
--rcfile <rcfile>: Set Alternate rpmrc file to <rcfile>
We've Lied to You…
RPM Controls What Gets Verified
7. Using RPM to Verify Package Files
rpm -K — What Does it Do?
Pretty Good Privacy: RPM's Assistant
Configuring PGP for rpm -K
Using rpm -K
-v — Display Additional Information
When the Package is Not Signed
When You Are Missing the Correct Public Key
When a Package Just Doesn't Verify
--nopgp — Do Not Verify Any PGP Signatures
-vv — Display Debugging Information
--rcfile <rcfile>: Use <rcfile> As An Alternate rpmrc File
8. Miscellanea
Other RPM Options
--rebuilddb — Rebuild RPM database
--initdb — Create a New RPM Database
--quiet — Produce as little output as possible
--help — Display a help message
--version — Display the current RPM version
Using rpm2cpio
rpm2cpio — What does it do?
A more real-world example — Listing the files in a package file
Extracting one or more files from a package file
Source Package Files and How To Use Them
A gentle introduction to source code
Do you really need more information than this?
So what can I do with it?
Stick with us!
II. RPM and Developers — How to Distribute Your Software More Easily With RPM
9. The Philosophy Behind RPM
Pristine Sources
Easy Builds
Reproducible Builds
Unattended Builds
Multi-architecture/operating system Support
Easier For Your Users
Easy Upgrades
Intelligent Configuration File Handling
Powerful Query Capabilities
Easy Package Verification
To Summarize…
10. The Basics of Developing With RPM
The Inputs
The Sources
The Patches
The Spec File
The Engine: RPM
The Outputs
The Source Package File
The Binary RPM
And Now…
11. Building Packages: A Simple Example
Creating the Build Directory Structure
Getting the Sources
Creating the Spec File
The Preamble
The %prep Section
The %build Section
The %install Section
The %files Section
The Missing Spec File Sections
Starting the Build
When Things Go Wrong
Problems During the Build
Testing Newly Built Packages
12. rpmbuild Command Reference
rpmbuild — What Does it Do?
rpmbuild -bp — Execute %prep
rpmbuild -bc — Execute %prep, %build
rpmbuild -bi — Execute %prep, %build, %install, %check
rpmbuild -bb — Execute %prep, %build, %install, %check, package (bin)
rpmbuild -ba — Execute %prep, %build, %install, %check, package (bin, src)
rpmbuild -bl — Check %files list
--short-circuit — Force build to start at particular stage
--buildarch <arch> — Perform Build For the <arch> Architecture
--buildos <os> — Perform Build For the <os> Operating System
--sign — Add a Digital Signature to the Package
--test — Create, Save Build Scripts For Review
--clean — Clean up after build
--buildroot <path> — Execute %install using <path> as the root
--timecheck <secs> — Print a warning if files to be packaged are over <secs> old
-vv — Display debugging information
--quiet — Produce as Little Output as Possible
--rcfile <rcfile> — Set alternate rpmrc file to <rcfile>
Other Build-related Commands
rpmbuild --recompile — What Does it Do?
rpmbuild --rebuild — What Does it Do?
13. Inside the Spec File
Comments: Notes Ignored by RPM
Tags: Data Definitions
Package Naming Tags
Descriptive Tags
Dependency Tags
Architecture- and Operating System-Specific Tags
Directory-related Tags
Source and Patch Tags
Scripts: RPM's Workhorse
Build-time Scripts
Install/Erase-time Scripts
Verification-Time Script — The %verifyscript Script
Macros: Helpful Shorthand for Package Builders
The %setup Macro
The %patch Macro
The %files List
Directives For the %files list
File-related Directives
Directory-related Directives
The Lone Directive: %package
-n <string> — Use <string> As the Entire Subpackage Name
Conditionals
The %ifarch Conditional
The %ifnarch Conditional
The %ifos Conditional
The %ifnos Conditional
The %else Conditional
The %endif Conditional
14. Adding Dependency Information to a Package
An Overview of Dependencies
Automatic Dependencies
The Automatic Dependency Scripts
Automatic Dependencies: An Example
The autoreqprov, autoreq, and autoprov Tags — Disable Automatic Dependency Processing
Manual Dependencies
The Requires Tag
The Conflicts Tag
The Provides Tag
To Summarize…
15. Making a Relocatable Package
Why relocatable packages?
The prefix tag: Relocation Central
Relocatable Wrinkles: Things to Consider
%files List Restrictions
Relocatable Packages Must Contain Relocatable Software
The Relocatable Software Is Referenced By Other Software
Building a Relocatable Package
Tying Up the Loose Ends
Test-Driving a Relocatable Package
16. Making a Package That Can Build Anywhere
Using Build Roots in a Package
Some Things to Consider
Having RPM Use a Different Build Area
Setting up a Build Area
Directing RPM to Use the New Build Area
Performing a Build in a New Build Area
Specifying File Attributes
%attr — How Does It Work?
Betcha Thought We Forgot…
17. Adding PGP Signatures to a Package
Why Sign a Package?
Getting Ready to Sign
Preparing PGP: Creating a Key Pair
Preparing RPM
Signing Packages
--sign — Sign a Package At Build-Time
--resign — Replace a Package's Signature(s)
--addsign — Add a Signature To a Package
18. Creating Subpackages
What Are Subpackages?
Why Are They Needed?
Our Example Spec File: Subpackages Galore!
Spec File Changes For Subpackages
The Subpackage's "Preamble"
The %files List
Install- and Erase-time Scripts
Build-Time Scripts: Unchanged For Subpackages
Our Spec File: One Last Look…
Building Subpackages
Giving Subpackages the Once-Over
19. Building Packages for Multiple Architectures and Operating Systems
Architectures and Operating Systems: A Primer
Let's Just Call Them Platforms
What Does RPM Do To Make Multi-Platform Packaging Easier?
Automatic Detection of Build Platform
Automatic Detection of Install Platform
Platform-Dependent Tags
Platform-Dependent Conditionals
Build and Install Platform Detection
Platform-Specific rpmrc Entries
Overriding Platform Information At Build-Time
Overriding Platform Information At Install-Time
optflags — The Other rpmrc File Entry
Platform-Dependent Tags
The excludexxx Tag
The exclusivexxx Tag
Platform-Dependent Conditionals
Common Features of All Conditionals
%ifxxx
%ifnxxx
Hints and Kinks
20. Real-World Package Building
An Overview of Amanda
Initial Building Without RPM
Setting Up A Test Build Area
Getting Software to build
Installing and testing
Initial Building With RPM
Generating patches
Making a first-cut spec file
Getting the original sources unpacked
Getting patches properly applied
Letting RPM do the Building
Letting RPM do the Installing
Testing RPM's Handiwork
Package Building
Creating the %files list
Testing those first packages
Finishing Touches
21. A Guide to the RPM Library API
An Overview of rpmlib
rpmlib Functions
Error Handling
Getting Package Information
Variable Manipulation
rpmrc-Related Information
RPM Database Manipulation
RPM Database Traversal
RPM Database Search
Package Manipulation
Package And File Verification
Dependency-Related Operations
Diagnostic Output Control
Signature Verification
Header Manipulation
Header Entry Manipulation
Header Iterator Support
Example Code
Example #1
Example #2
Example #3
III. Appendixes
A. Format of the RPM File
RPM File Naming Convention
RPM File Format
Parts of an RPM File
The Lead
Wanted: A New RPM Data Structure
The Signature
The Header
The Archive
Tools For Studying RPM Files
Identifying RPM files with the file(1) command
B. The rpmrc File
Using the --showrc Option
Different Places an rpmrc File Resides
/usr/lib/rpmrc
/etc/rpmrc
.rpmrc in the user's login directory
File indicated by the --rcfile option
rpmrc File Syntax
rpmrc File Entries
arch_canon
os_canon
buildarchtranslate
buildostranslate
arch_compat
os_compat
builddir
buildroot
cpiobin
dbpath
defaultdocdir
distribution
excludedocs
ftpport
ftpproxy
messagelevel
netsharedpath
optflags
packager
pgp_name
pgp_path
require_distribution
require_icon
require_vendor
rpmdir
signature
sourcedir
specdir
srcrpmdir
timecheck
tmppath
topdir
vendor
C. Concise RPM Command Reference
Global Options
Informational Options
Query Mode
Package Specification Options To Query Mode
Information Selection Options To Query Mode
Verify Mode
Options To Verify Mode
Install Mode
Options To Install Mode
Upgrade Mode
Options To Upgrade Mode
Erase Mode
Options To Erase Mode
Build Mode
Build Mode Stages
Options To Build Mode
Rebuild Mode
Options To Rebuild Mode
Recompile Mode
Options To Recompile Mode
Resign Mode
Options To Resign Mode
Add Signature Mode
Options To Add Signature Mode
Check Signature Mode
Options To Check Signature Mode
Initialize Database Mode
Options to Initialize database Mode
Rebuild Database Mode
Options to Rebuild Database Mode
D. Available Tags For --queryformat
List of --queryformat Tags
The NAME Tag
The VERSION Tag
The RELEASE Tag
The EPOCH Tag
The SUMMARY Tag
The DESCRIPTION Tag
The BUILDTIME Tag
The BUILDHOST Tag
The INSTALLTIME Tag
The SIZE Tag
The DISTRIBUTION Tag
The VENDOR Tag
The GIF Tag
The XPM Tag
The LICENSE Tag
The PACKAGER Tag
The GROUP Tag
The CHANGELOG Tag
The SOURCE Tag
The PATCH Tag
The URL Tag
The OS Tag
The ARCH Tag
The PREIN Tag
The POSTIN Tag
The PREUN Tag
The POSTUN Tag
The FILENAMES Tag
The FILESIZES Tag
The FILESTATES Tag
The FILEMODES Tag
The FILEUIDS Tag
The FILEGIDS Tag
The FILERDEVS Tag
The FILEMTIMES Tag
The FILEMD5S Tag
The FILELINKTOS Tag
The FILEFLAGS Tag
The ROOT Tag
The FILEUSERNAME Tag
The FILEGROUPNAME Tag
The EXCLUDE Tag
The EXCLUSIVE Tag
The ICON Tag
The SOURCERPM Tag
The FILEVERIFYFLAGS Tag
The ARCHIVESIZE Tag
The PROVIDES Tag
The REQUIREFLAGS Tag
The REQUIRENAME Tag
The REQUIREVERSION Tag
The NOSOURCE Tag
The NOPATCH Tag
The CONFLICTFLAGS Tag
The CONFLICTNAME Tag
The CONFLICTVERSION Tag
The DEFAULTPREFIX Tag
The BUILDROOT Tag
The INSTALLPREFIX Tag
The EXCLUDEARCH Tag
The EXCLUDEOS Tag
The EXCLUSIVEARCH Tag
The EXCLUSIVEOS Tag
The AUTOREQPROV, AUTOREQ, and AUTOPROV Tags
The RPMVERSION Tag
The TRIGGERSCRIPTS Tag
The TRIGGERNAME Tag
The TRIGGERVERSION Tag
The TRIGGERFLAGS Tag
The TRIGGERINDEX Tag
The VERIFYSCRIPT Tag
E. Concise Spec File Reference
Comments
The Preamble
Package Naming Tags
Descriptive Tags
Dependency Tags
Architecture- and Operating System-Specific Tags
Directory-related Tags
Source and Patch Tags
Scriptlets
Build Scriptlets
Install/Erase Scriptlets
%verifyscript Directive
Macros
The %setup Macro
The %patch Macro
The %files List
Directives For the %files list
File-related Directives
Directory-related Directives
%package Directive
The %package -n Option
Conditionals
The %ifarch Conditional
The %ifnarch Conditional
The %ifos Conditional
The %ifnos Conditional
The %else Conditional
The %endif Conditional
F. RPM-related Resources
Where to Get RPM
FTP Sites
What Do I Need?
Where to Talk About RPM
The rpm-list Mailing List
The redhat-list Mailing List
The redhat-digest Mailing List
RPM On the World Wide Web
RPM's License
GNU GENERAL PUBLIC LICENSE
Preamble
GNU GENERAL PUBLIC LICENSE
How to Apply These Terms to Your New Programs
G. An Introduction to PGP
PGP — Privacy for Regular People
Keys your Locksmith Wouldn't Understand
Are RPM Packages Encrypted?
Do All RPM Packages Have Digital Signatures?
So Much to Cover, So Little Time
Installing PGP for RPM's Use
Obtaining PGP
Building PGP
Ready to Go!
Index

List of Tables

2.1. rpm -i Command Syntax
3.1. rpm -e Command Syntax
4.1. rpm -U Command Syntax
5.1. rpm -q Command Syntax
6.1. rpm -V Command Syntax
6.2. Verification Versus File Types
7.1. rpm -K Command Syntax
12.1. rpmbuild Command Syntax

Preface

Linux and RPM — A Brief History

Welcome! This is a book about the Red Hat Package Manager, or RPM Package Manager, known to its friends as simply RPM. The history of RPM is inextricably linked to the history of GNU/Linux, so a bit of GNU/Linux history may be in order. GNU/Linux is a full-featured implementation of a UNIX-like operating system, and has taken the computing world by storm.

And for a good reason — When choosing GNU/Linux, an Intel-based personal computer that had previously been prisoner of the dreaded Windows hourglass is transformed into a fully multitasking, network capable, personal workstation. All for the cost of the time required to download, install, and configure the software.

Of course, if you're not the type to tinker with downloaded software, many companies have created CDROMs containing GNU/Linux and associated software. The amount of tinkering required with these distributions has varied widely. The phrase "You get what you pay for" is never more true than in the area of GNU/Linux distributions.

One distribution bears the curious name "Red Hat Linux". Produced by a company of the same name, this GNU/Linux distribution was different. One of the key decisions a new Linux user needs to make is which of the many different parts of the distribution to install on their system. Most distributions use some sort of menu, making it easy to pick and choose. Red Hat Linux is no different.

But what is different about Red Hat Linux is that the creators of the distribution wanted their customers to have the the ability to make the same choices long after the installation process was over. Some commercial UNIX systems have this capability (called "package management"), and a few GNU/Linux distributors were trying to come up with something similar, but none had at the time the extensive scope present in RPM.

Over time, Red Hat Linux has become the most popular distribution available today. For it to edge out the previous leader (Slackware) in just two years is amazing. There has to be a reason for this kind of success, and a good part of the reason is RPM. But until the first edition of this book, there had been precious little in terms of RPM documentation. You could say that RPM's ease of use has made detailed instructions practically unnecessary, and you'd be right.

However, there are always people that want to know more about their computers, and given the popularity of Red Hat Linux, this alone would have made a book on RPM worthwhile. But there's more to the story than that.

There is a truism in the world of Free Software, that goes something like this: If there's a better solution freely available, use it! RPM is no exception to the rule. Put under the terms of the GNU General Public License (Meaning: RPM cannot be made proprietary by anyone, not even Bill Gates), RPM started to attract the attention of others in the Linux, Unix, and free software communities.

At present, RPM is used by several commercial software companies producing Linux applications. They find that RPM makes it easier to get their products into the hands of their customers. They also find that it can even make the process of building their software easier. (Those of you that develop software for fun and profit, stick around — the second half of this book will show you everything you need to know to get your software "RPM-ized")

People have also ported RPM to several commercial UNIX systems, including DEC's Digital Unix, IBM's AIX, and Silicon Graphics' IRIX. Why? The simple answer is that it makes it easier to install, upgrade, and de-install software. If all these people are using RPM, shouldn't you?

Parts of the book, and who they're for

This book is divided into two major sections. The first section is for anyone that needs to know how to use RPM on their system. Given the state of the GNU/Linux arena today, this could mean just about anyone, including people that are new to GNU/Linux, or even UNIX. So those of you that think that

ls -FAl !* | less
        

is serious magic (or maybe even a typing error), relax — we'll explain everything you'll need to know in the first section.

In the book's second half, we'll be covering all there is to know about building packages using RPM. Since software engineering on GNU/Linux and UNIX systems requires in-depth knowledge of the operating system, available tools, and basic programming concepts, we're going to assume that the reader has sufficient background in these areas. Feel free to browse through the second half, but don't hesitate to seek additional sources of information if you find the going a bit tough.

Acknowledgements

Writing a book is similar to entering a long-term relationship with an obsessive partner. Throughout the nine months it took to write this book, life went on: job changes, births, deaths, and even a hurricane. Throughout it all, the book demanded constant attention. Therefore, I'd like to thank the people that made it possible to focus on the book to the exclusion of nearly everything else. My wife, Deb and son, Matt supported and encouraged me throughout, even when I was little more than a reclusive houseguest hunched over the computer in the study. Additionally, Deb acted as my editor and indexer, eventually reading the book completely three times! Thank you both.

Thanks also to Marc Ewing and Erik Troan, RPM architects extraordinaire. Without their programming savvy, RPM wouldn't be the elegant tool it is. Without their boundless patience, my many questions would have gone unanswered, and this book would have been much less than it is now. I hope you find this book a worthy companion to your programming handiwork.

Rik Faith provided some much-needed information about PMS and PM, two of RPM's ancestors. Thank you!

Finally a great big thank you goes to Jessica and the gang at L'il Dinos, Jennifer and her crew at the Cary Barnes & Noble coffee shop, and Mom and her "kids" at Schlotzsky's Deli in Durham. If all of you hadn't let me sit around for hours writing, this book wouldn't be nearly as fat as it is. And neither would I!

February, 1997 Cary, North Carolina

RPM and Computer Users — How to Use RPM to Effectively Manage Your Computer

Table of Contents

1. An Introduction to Package Management
What are Packages, and Why Manage Them?
Enter the Package
Manage Your Packages, or They Will Manage You
Package Management: How to Do It?
Ancestors of RPM
RPM Design Goals
Make it easy to get packages on and off the system
Make it easy to verify a package was installed correctly
Make it easy for the package builder
Make it start with the original source code
Make it work on different computer architectures
What's in a package?
RPM's Package Labels
Labels And Names: Similar, But Distinct
Package-wide Information
Per-file Information
Let's Get Started
2. Using RPM to Install Packages
rpm -i — What does it do?
Performing dependency checks:
Checking for conflicts:
Performing any tasks required before the install:
Deciding what to do with config files:
Unpacking files from the package and putting them in the proper place:
Performing any tasks required after the install:
Keeping track of what it did:
Performing an Install
URLs — Another Way to Specify Package Files
A warning message you might never see
Two handy options
Getting a bit more feedback with -v
-h: Perfect for the Impatient
Additional options to rpm -i
Getting a lot more information with -vv
--test: Perform Installation Tests Only
--replacepkgs: Install the Package Even If Already Installed
--replacefiles: Install the Package Even If It Replaces Another Package's Files
--nodeps: Do Not Check Dependencies Before Installing Package
--force: The Big Hammer
--excludedocs: Do Not Install Documentation For This Package
--includedocs: Install Documentation For This Package
--prefix <path>: Relocate the package to <path>, if possible
--noscripts: Do Not Execute Pre- and Post-install Scripts
--percent: Not Meant for Human Consumption
--rcfile <rcfile>: Use <rcfile> As An Alternate rpmrc File
--root <path>: Use <path> As An Alternate Root
--dbpath <path>: Use <path> To Find RPM Database
--ftpport <port>: Use <port> In FTP-based Installs
--ftpproxy <host>: Use <host> As Proxy In FTP-based Installs
--ignorearch: Do Not Verify Package Architecture
--ignoreos: Do Not Verify Package Operating System
3. Using RPM to Erase Packages
rpm -e — What Does it Do?
Erasing a Package
Getting More Information With -vv
Additional Options
--test — Go Through the Process of Erasing the Package, But Do Not Erase It
--nodeps: Do Not Check Dependencies Before Erasing Package
--noscripts — Do Not Execute Pre- and Post-uninstall Scripts
--rcfile <rcfile> — Read <rcfile> For RPM Defaults
--root <path> — Use <path> As the Root
--dbpath <path>: Use <path> To Find RPM Database
rpm -e and Config files
Watch Out!
4. Using RPM to Upgrade Packages
rpm -U — What Does it Do?
Config file magic
Upgrading a Package
rpm -U's Dirty Little Secret
They're Nearly Identical…
--oldpackage: Upgrade To An Older Version
--force: The Big Hammer
--noscripts: Do Not Execute Install and Uninstall Scripts
5. Getting Information About Packages
rpm -q — What does it do?
The Parts of an RPM Query
Query Commands, Part One: Package Selection
Query Commands, Part Two: Information Selection
Getting a lot more information with -vv
--root <path>: Use <path> As An Alternate Root
--rcfile <rcfile>: Use <rcfile> As An Alternate rpmrc File
--dbpath <path>: Use <path> To Find RPM Database
A Few Handy Queries
Finding Config Files Based on a Program Name
Learning More About an Uninstalled Package
Finding Documentation for a Specific Package
Finding Similar Packages
Finding Recently Installed Packages, Part I
Finding Recently Installed Packages, Part II
Finding the Largest Installed Packages
6. Using RPM to Verify Installed Packages
rpm -V — What Does it Do?
What Does it Verify?
When Verification Fails — rpm -V Output
Other Verification Failure Messages
Selecting What to Verify, and How
The Package Label — Verify an Installed Package Against the RPM Database
-a — Verify All Installed Packages Against the RPM Database
-f <file> — Verify the Package Owning <file> Against the RPM Database
-p <file> — Verify Against a Specific Package File
-g <group> — Verify Packages Belonging To <group>
--nodeps: Do Not Check Dependencies During Verification
--noscripts: Do Not Execute Verification Script
--nofiles: Do Not Verify File Attributes
-v — Display Additional Information
-vv — Display Debugging Information
--dbpath <path>: Use <path> To Find RPM Database
--root <path>: Set Alternate Root to <path>
--rcfile <rcfile>: Set Alternate rpmrc file to <rcfile>
We've Lied to You…
RPM Controls What Gets Verified
7. Using RPM to Verify Package Files
rpm -K — What Does it Do?
Pretty Good Privacy: RPM's Assistant
Configuring PGP for rpm -K
Using rpm -K
-v — Display Additional Information
When the Package is Not Signed
When You Are Missing the Correct Public Key
When a Package Just Doesn't Verify
--nopgp — Do Not Verify Any PGP Signatures
-vv — Display Debugging Information
--rcfile <rcfile>: Use <rcfile> As An Alternate rpmrc File
8. Miscellanea
Other RPM Options
--rebuilddb — Rebuild RPM database
--initdb — Create a New RPM Database
--quiet — Produce as little output as possible
--help — Display a help message
--version — Display the current RPM version
Using rpm2cpio
rpm2cpio — What does it do?
A more real-world example — Listing the files in a package file
Extracting one or more files from a package file
Source Package Files and How To Use Them
A gentle introduction to source code
Do you really need more information than this?
So what can I do with it?
Stick with us!

Chapter 1. An Introduction to Package Management

What are Packages, and Why Manage Them?

To answer that question, let's go back to the basics for a moment. Computers process information. In order for this to happen, there are some prerequisites:

  • A computer (Obviously!).

  • Some information to process (Also obvious!).

  • A program to do the processing (Still pretty obvious!).

Unless these three things come together very little is going to happen, information processing-wise. But each of these items have their own requirements that need to be satisfied before things can get exciting.

Take the computer, for example. While it needs things like electricity and a cool, dry place to operate, it also needs access to the other two items — information and programs — in order to do its thing. The way to get information and programs into a computer is to place them in the computer's mass storage. These days, mass storage invariably means a disk drive. Putting information and programs on the disk drive means that they are stored as files. So much for the computer's part in this.

OK, let's look at the information. Does information have any particular needs? Well, it needs sufficient space on the disk drive, but more importantly, it needs to be in the proper format for the program that will be processing it. That's it for information.

Finally, we have the program. What does it need? Like the information, it needs sufficient disk space on the disk drive. But there are many other things that it may need:

  • It may need information to process, in the correct format, named properly, and in the appropriate area on a disk drive somewhere.

  • It may need one or more configuration files. These are files that control the program's behavior and permit some level of customization. Like the information, these files must be in the proper format, named properly, and in the appropriate area on a disk. We'll be referring to them by their other name — config files — throughout the book.

  • It may need work areas on a disk, named properly, and located in the appropriate area.

  • It may even need other programs, each with their own requirements.

  • Although not strictly required by the program itself, the program may come with one or more files containing documentation. These files can be very handy for the humans trying to get the program to do their bidding!

As you can imagine, this can get pretty complicated. It's not so bad once everything is set up properly, but how do things get set up properly in the first place? There are two possibilities:

  1. After reading the documentation that comes with the program you'd like to use, you copy the various programs, configuration files, and information onto your computer, making sure they are all named correctly, are located in the proper place, and that there is sufficient disk space to hold them all. You make the appropriate changes to the configuration file(s). Finally, you run any setup programs that are necessary, giving them whatever information they require to do their job.

  2. You let the computer do it.

If it seems like the first choice isn't so bad, consider how many files you'll need to keep track of. On a typical Linux system, it's not unusual to have over 20,000 different files. That's a lot of documentation reading, file copying, and configuring! And what happens when you want a newer version of a program? More of the same!

Some people think the second alternative is easier. RPM was made for them.

Enter the Package

When you consider that computers are very good at keeping track of large amounts of data, the idea of giving your computer the job of riding herd over 20,000 files seems like a good one. And that's exactly what package management software does. But what is a "package"?

A package in the computer sense is very similar to a package in the physical sense. Both are methods of keeping related objects together in the same place. Both need to be opened before the contents can be used. Both can have a "packing slip" taped to the side, identifying the contents.

Normally, package management systems take all the various files containing programs, data, documentation, and configuration information, and place them in one specially formatted file — a package file. In the case of RPM, the package file is sometimes called a "package", a ".rpm file", or even an "RPM". All mean the same thing — a package containing software meant to be installed using RPM.

What types of software are normally found in a package? There are no hard and fast rules, but normally a package's contents consist of one of the following types of software:

  • A collection of one or more programs that perform a single well-defined task. This is normally what people think of as an "application". Word processors and programming languages would fit into this category.

  • A specific part of an operating system. Examples might be system initialization scripts, a particular command shell, or the software required to support a web server, for example.

Advantages of a Package

One of the most obvious benefits to having a package is that the package is one easily manageable chunk. If you move it from one place to another, there's no risk of any part getting left behind. But although this is the most obvious advantage, it's not the biggest one.

The biggest advantage is that the package can contain the knowledge about what it takes to install itself on your computer. And if the package contains the steps required to install itself, the package can also contain the steps required to uninstall itself. What used to be a painful manual process is now a straightforward procedure. What used to be a mass of 20,000 files becomes a couple hundred packages.

Manage Your Packages, or They Will Manage You

A couple hundred? Even though