Red Hat RPM Guide

book cover thumbnail image of Red Hat RPM Guide

Overview

The Red Hat RPM Guide covers the RPM package format used on Red Hat, Centos, Fedora, OpenSUSE, and other Linux distributions. It covers how to use, download, create, manage, and work with packages in the RPM format.

With RPM packaging, you can release your software in a consistent manner across a huge number of Linux systems, automating the installation of your packages. In addition, the book delves into programming with RPM packages from C, Python, and Perl.

Available online on a separate site as the Fedora RPM Guide, this book is now released under the Open Publication License, Version 1.0.

Table of Contents

  • Acknowledgments
  • Forward
  • Preface
  • Part I: RPM Basics
  • Chapter 1: Introducing Package Management
  • Chapter 2: Introduction to RPM
  • Chapter 3: RPM Overview
  • Chapter 4: Using RPM
  • Chapter 5: Using the RPM Database
  • Chapter 6: Package Dependencies
  • Chapter 7: Transactions
  • Chapter 8: RPM Management Software
  • Part II: Creating RPMs
  • Chapter 9: Creating RPMs: An Overview
  • Chapter 10: Working with Spec Files
  • Chapter 11: Advanced RPM Packaging
  • Chapter 12: Controlling the Build with rpmbuild
  • Chapter 13: Supplemental Packaging Software
  • Chapter 14: Packaging Guidelines
  • Part III: Programming RPM
  • Chapter 15: Automating RPM with Scripts
  • Chapter 16: Programming RPM with C
  • Chapter 17: Programming RPM with Python
  • Chapter 18: Programming RPM with Perl
  • Part IV: Extending RPM
  • Chapter 19: Using RPM on Non-Red Hat Linuxes
  • Chapter 20: RPM on Other Operating Systems
  • Chapter 21: Customizing RPM Behavior
  • Part V: Appendices
  • Appendix A: RPM Command Reference
  • Appendix B: Spec File Syntax
  • Appendix C: RPM Feature Evolution
  • Appendix D: RPM Package File Structure
  • Appendix E: RPM Resources
  • Appendix F: Linux Text Editors and Development Tools
  • Appendix G: Licensing RPM
  • Index

Errata for Red Hat RPM Guide, Printed Edition

Thanks to Aaron Bennett, Peter Bowen, Jeff Johnson, Christian Krause, Kelwin Wylie, Richard Hitt, JP Vossen, and the wonderful people at Red Hat.

Page Errata & Corrections
35 In the third paragraph, just below the example, the warning comes from the fact that the packages is signed, but the key is not found. If the package hadn't been GPG signed at all it would have passed.
50 The description of the %config behavior was confusing and partially wrong. If you attach the %config attribute to a file (quoted from the RPM mailing list):

.rpmorig is used to save copy of preexsiting, but not in a package, file.
.rpmsave is used to save modified, previously installed, contents.
.rpmnew is used to save incoming if %config(noreplace) was used, and previously installed contents are modified. Note that if previous contents are not modified, then previous versions of the file are simply replaced, not saved in in .rpmsave, incoming not saved in .rpmnew.
51 In the 2nd paragraph under Installing over the Internet, FileTransfer Protocol should be three words: File Transfer Protocol. Duh. Dumb typo.
55 The default repackage directory isn't /var/spool, but /var/spool/repackage. Check your RPM settings to be sure of the directory configured on your system.
56 In the 3rd paragraph in the note, /etc/rpmrc should be used for local customizations rather than modifying /usr/lib/rpm/rpmrc. See page 427 for a more in-depth look at the chain of these files.
57 The default set of initialization files is missing /etc/rpmrc. It should be:

/usr/lib/rpm/rpmrc:/usr/lib/rpm/redhat/rpmrc:/etc/rpmrc:~/.rpmrc Note that it is actually listed without /etc/rpmrc in the rpm man page, too.
61 In the first paragraph under Querying everything, it should be --all (with two hyphens).
74 In table 5-2, there are some states that are missing. In RPM 4.1 there is a 'net shared' state, and RPM 4.2 adds 'wrong color' to the list.
77 In the changelog example, the last entry appears to have bogus formatting instructions at the beginning of the comment line. (The code 80 refers to a Wiley document style.)
91 In the Querying Package Files Remotely callout, all the exampes should have -qp not -qf.
102 In the 2nd to last paragraph, the text on the version should be clearer. The example shows a relationship of greater than or equal (such as >= the 2.2 version of python). This should have been called out more clearly.
124 In the caution, it suggests that you can use rpmbuild to make a repackaged package into a full package, but there are not any instructions on how to do so. (This is left as an exercise for the reader. See Chapters 10, 11, and 12 for more on building packages.)
125 The program rpmrebuild was given an extra "p" in a typo.
168 This section calls the first part of the spec file the introduction section. I combined a number of things into what I called the introduction, including the preamble.
168 The preamble example has several problems:
  • it shouldn't explicitly provide jikes
  • the copyright tag is deprecated. It will automatically get turned into a license tag when the package is built, so it shouldn't be used, especially to hold copyright.
  • %define version is bad practice. RPM will automatically define the version macro from the Version: tag

(Comment: This is a real spec file from the jikes Java compiler. I won't argue on the best practices, but I wanted to focus on examples people might really see, not made-up examples, since one target audience is Linux administrators. -Eric)
182 In really old versions of RPM, which no one should be using, the deprectaed Serial directive was used in place of the version and release, not in addition to it.
183 The text should be more blatant about Copyright being deprecated. I wanted to show an example of both Copyright and License.
184 In the third paragraph, it states that lines in the %description section that start with whitespace will be treated as preformatted. I should have been clearer: the rpm command will treat it as such, but other programs (Ximian/Red Carpet, for example), may not honor this.
186 The description of the Nosource should be:

NoSource: 0
This example means that the first source item should not be included in the package.

NoSource: 3
This example means that the third source item should not be included in the package. The NoPatch directive works similarly. In addition, do not place more than one number on any given NoSource or NoPatch directive.
188 The %setup directive can automatically extract tar, zip, gzip, bzip2, pack, compress, and lzh compressed files. The tar-gzip format is most widely used, though.
189 In the second paragraph, the %patch directive should be documented as only to taking six options: -P, -R , -E, -b, -z, and -p.
197 In the note, /usr/share/man would be a better example for the directory, as that is the one that red Hat Linux and FHS use.
202 The example directories uses the standard RPM macro file, /usr/lib/rpm/macros, instead of the Red Hat-specific file, /usr/lib/rpm/redhat/macros, which holds:

%_prefix            /usr
%_sysconfdir        /etc
%_localstatedir     /var
%_infodir           /usr/share/info
%_mandir            /usr/share/man
%_initrddir         %{_sysconfdir}/rc.d/init.d
                                           
%_defaultdocdir     %{_usr}/share/doc

I should have used the Red Hat one.
205 The XML format for spec files is not only expermimental, it is very experimental. Assume there will be changes.
485 Parts of RPM are available under the LGPL in addition to the GPL.
Section 9.5.5 The %verify attributes are now different than what was described in the book. The old list was: group, maj, md5, min, mode, mtime, owner, size, symlink. The current list, in Fedora Core 6, is: group, md5, mode, mtime, link, rdev, size, user, as shown following:

VFA_t verifyAttrs[] = {
    { "md5",    0,      RPMVERIFY_MD5 },
    { "size",   0,      RPMVERIFY_FILESIZE },
    { "link",   0,      RPMVERIFY_LINKTO },
    { "user",   0,      RPMVERIFY_USER },
    { "group",  0,      RPMVERIFY_GROUP },
    { "mtime",  0,      RPMVERIFY_MTIME },
    { "mode",   0,      RPMVERIFY_MODE },
    { "rdev",   0,      RPMVERIFY_RDEV },
    { NULL, 0,  0 }
};
   

Purchase Options

I'm sorry. This book is out of print but a free version, Fedora Draft Documentation RPM Guide, is available online and as a PDF file.