RPM Packaging 101 (Old)


Published on

A talk I gave to the Triangle Linux Users Group ( http://www.trilug.org/ ) on 11-Jan-2003 on how to build RPM packages. Probably fairly outdated at this point.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • RPM Packaging 101 (Old)

    1. 1. RPM Packaging 101 Tanner Lovelace Triangle Linux Users Group 11/Jan/2003
    2. 2. Outline <ul><li>Package Management Basics </li></ul><ul><li>RPM Package Management Basics </li></ul><ul><li>Creating Your Own RPM Packages </li></ul><ul><li>Creating RPM Packages of Downloaded Programs </li></ul><ul><li>Advanced RPM Packaging </li></ul>
    3. 3. Package Management Basics <ul><li>Why use package management? </li></ul><ul><ul><li>OpenBSD base doesn’t </li></ul></ul><ul><ul><li>Most Linux systems do </li></ul></ul><ul><li>Keeps track of system packages </li></ul><ul><ul><li>Files </li></ul></ul><ul><ul><li>Descriptions </li></ul></ul><ul><ul><li>Checksums </li></ul></ul><ul><ul><li>Other… </li></ul></ul><ul><li>Allows easy upgrades and uninstalls </li></ul>
    4. 4. RPM Package Management Basics <ul><li>Developed by Redhat </li></ul><ul><ul><li>Dominant distribution at the time was Slackware </li></ul></ul><ul><ul><ul><li>Slackware has packages, but not really a package management system </li></ul></ul></ul><ul><ul><ul><li>RPM was a big advance over Slackware </li></ul></ul></ul><ul><ul><li>Current stable version is 4.1 </li></ul></ul><ul><ul><li>Most commonly used version today is 4.0.x </li></ul></ul><ul><ul><ul><li>We will be covering 4.0.x </li></ul></ul></ul>
    5. 5. RPM Package Concepts <ul><li>Pristine Sources </li></ul><ul><ul><li>Most Linux software downloaded from the Internet </li></ul></ul><ul><ul><li>Any distribution specific customizations should be kept separately in patches </li></ul></ul><ul><ul><ul><li>Makes it easier to handle new versions </li></ul></ul></ul><ul><li>Reproducible Builds </li></ul><ul><ul><li>Building and packaging should be easy and reproducible </li></ul></ul><ul><ul><li>Shell script automation </li></ul></ul>
    6. 6. Common RPM Installation Commands <ul><li>Installation </li></ul><ul><ul><li>rpm –ihv <package name> </li></ul></ul><ul><li>Upgrade </li></ul><ul><ul><li>rpm –Uhv <package name> </li></ul></ul><ul><li>Freshen </li></ul><ul><ul><li>rpm –Fhv <package names…> </li></ul></ul><ul><li>Erase </li></ul><ul><ul><li>rpm –e <package name> </li></ul></ul>
    7. 7. Other Common RPM Commands <ul><li>Query </li></ul><ul><ul><li>rpm –q[option] <package name> </li></ul></ul><ul><ul><ul><li>-qi = Query Package Information </li></ul></ul></ul><ul><ul><ul><li>-ql = List Package Files </li></ul></ul></ul><ul><ul><ul><li>-qf = Query which package a file belongs to. </li></ul></ul></ul><ul><ul><ul><li>--queryformat – Construct Special Query </li></ul></ul></ul><ul><ul><ul><ul><li>--querytags – List available tags </li></ul></ul></ul></ul><ul><ul><ul><li>-p – Specify non-installed rpm package </li></ul></ul></ul><ul><ul><ul><li>-a – Query all installed files </li></ul></ul></ul>
    8. 8. Other Common RPM Commands <ul><li>Verify </li></ul><ul><ul><li>rpm –V[option] <package name> </li></ul></ul><ul><ul><ul><li>Compare information about installed package files with information stored in rpm database and note any discrepencies. </li></ul></ul></ul><ul><ul><ul><li>Compares size, MD5 sum, permissions, type, owner, and group of each package file </li></ul></ul></ul><ul><li>Signature checking </li></ul><ul><ul><li>rpm {-K|--checksig} <package name> </li></ul></ul><ul><ul><ul><li>Checks package gpg/pgp signature </li></ul></ul></ul><ul><li>Conversion to cpio </li></ul><ul><ul><li>rpm2cpio cpio converts rpm files to cpio streams </li></ul></ul>
    9. 9. Setting up the RPM Build Environment <ul><li>NEVER BUILD RPMs AS ROOT!!! </li></ul><ul><li>~/.rpmmacros </li></ul><ul><ul><li>%_topdir /path/to/rpm/build/env </li></ul></ul><ul><ul><ul><li>I typically use ~/RPM </li></ul></ul></ul><ul><ul><li>Optional temp directory </li></ul></ul><ul><ul><ul><li>%_tmppath /path/to/tmp </li></ul></ul></ul><ul><li>Create directories </li></ul><ul><ul><li>~/RPM/BUILD </li></ul></ul><ul><ul><li>~/RPM/RPMS/<arch> </li></ul></ul><ul><ul><li>~/RPM/RPMS/noarch </li></ul></ul><ul><ul><li>~/RPM/SOURCES </li></ul></ul><ul><ul><li>~/RPM/SPECS </li></ul></ul><ul><ul><li>~/RPM/SRPMS </li></ul></ul>
    10. 10. Creating Your Own RPMs <ul><li>rpmbuild command </li></ul><ul><ul><li>rpmbuild –ba – build binary and source rpms </li></ul></ul><ul><ul><li>rpmbuild –bb – build binary rpm </li></ul></ul><ul><ul><li>rpmbuild –bs – build source rpm </li></ul></ul><ul><li>Before version 4, the rpm command was used instead of rpmbuild. </li></ul><ul><ul><li>Compatibility aliases in 4.0 </li></ul></ul><ul><ul><li>Aliases removed in 4.1 (Redhat 8.0) </li></ul></ul><ul><li>Need source files, patches (if any) and a spec file. </li></ul><ul><ul><li>Source and patch files go in SOURCES/ </li></ul></ul><ul><ul><li>Spec file goes in SPECS/ </li></ul></ul>
    11. 11. RPM Spec Files <ul><li>Instructions for building and packaging an rpm. </li></ul><ul><ul><li>Building – set of shell scripts </li></ul></ul><ul><ul><li>Packaging – General info, lists of files, etc. </li></ul></ul><ul><li>Divided into sections </li></ul><ul><ul><li>Headers (unlabeled section) </li></ul></ul><ul><ul><li>%description </li></ul></ul><ul><ul><li>%prep </li></ul></ul><ul><ul><li>%build </li></ul></ul><ul><ul><li>%install </li></ul></ul><ul><ul><li>%files </li></ul></ul><ul><ul><li>Others </li></ul></ul>
    12. 12. Creating RPMs Examples <ul><li>See Pinky and the Brain Examples at </li></ul><ul><li>http://home.fnal.gov/~dawson/rpms/howto/index.html </li></ul><ul><li>Sub package example </li></ul><ul><li>Example of how to “rpm-ify” a package. </li></ul><ul><li>Patching </li></ul><ul><li>Conditional building </li></ul>
    13. 13. References <ul><li>References will go here when presentation goes online.. </li></ul>
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.