RPM Packaging 101

Document Sample
RPM Packaging 101 Powered By Docstoc
					                             RPM Packaging 101

                                 Tanner Lovelace
                            Triangle Linux Users Group

Tanner Lovelace – Slide 1
            • Package Management Basics
            • RPM Package Management Basics
            • Creating Your Own RPM Packages
            • Creating RPM Packages of Downloaded
            • Advanced RPM Packaging

Tanner Lovelace – Slide 2
                            Package Management Basics
            • Why use package management?
               –OpenBSD base doesn’t
               –Most Linux systems do
            • Keeps track of system packages
            • Allows easy upgrades and uninstalls

Tanner Lovelace – Slide 3
                            RPM Package Management Basics
            • Developed by Redhat
               –Dominant distribution at the time was
                            »Slackware has packages, but not really a
                             package management system
                            »RPM was a big advance over Slackware
                     –Current stable version is 4.1
                     –Most commonly used version today is 4.0.x
                            »We will be covering 4.0.x

Tanner Lovelace – Slide 4
                            RPM Package Concepts
            • Pristine Sources
               –Most Linux software downloaded from the
               –Any distribution specific customizations
                should be kept separately in patches
                            »Makes it easier to handle new versions
            • Reproducible Builds
               –Building and packaging should be easy and
               –Shell script automation

Tanner Lovelace – Slide 5
                            Common RPM Installation Commands

            • Installation
               –rpm –ihv <package name>
            • Upgrade
               –rpm –Uhv <package name>
            • Freshen
               –rpm –Fhv <package names…>
            • Erase
               –rpm –e <package name>

Tanner Lovelace – Slide 6
                            Other Common RPM Commands
            • Query
               –rpm –q[option] <package name>
                            »-qi = Query Package Information
                            »-ql = List Package Files
                            »-qf = Query which package a file belongs to.
                            »--queryformat – Construct Special Query
                               »--querytags – List available tags
                            »-p – Specify non-installed rpm package
                            »-a – Query all installed files

Tanner Lovelace – Slide 7
                            Other Common RPM Commands
            • Verify
               –rpm –V[option] <package name>
                            » Compare information about installed package files with
                              information stored in rpm database and note any
                            » Compares size, MD5 sum, permissions, type, owner,
                              and group of each package file
            • Signature checking
               –rpm {-K|--checksig} <package name>
                            » Checks package gpg/pgp signature
            • Conversion to cpio
               –rpm2cpio cpio converts rpm files to cpio streams

Tanner Lovelace – Slide 8
                            Setting up the RPM Build Environment
            • NEVER BUILD RPMs AS ROOT!!!
            • ~/.rpmmacros
               – %_topdir /path/to/rpm/build/env
                            » I typically use ~/RPM
                     – Optional temp directory
                            » %_tmppath /path/to/tmp
            • Create directories
               – ~/RPM/BUILD
               – ~/RPM/RPMS/<arch>
               – ~/RPM/RPMS/noarch
               – ~/RPM/SOURCES
               – ~/RPM/SPECS
               – ~/RPM/SRPMS

Tanner Lovelace – Slide 9
                             Creating Your Own RPMs
            • rpmbuild command
               –rpmbuild –ba – build binary and source rpms
               –rpmbuild –bb – build binary rpm
               –rpmbuild –bs – build source rpm
            • Before version 4, the rpm command was used instead
              of rpmbuild.
               –Compatibility aliases in 4.0
               –Aliases removed in 4.1 (Redhat 8.0)
            • Need source files, patches (if any) and a spec file.
               –Source and patch files go in SOURCES/
               –Spec file goes in SPECS/

Tanner Lovelace – Slide 10
                             RPM Spec Files
            • Instructions for building and packaging an rpm.
               –Building – set of shell scripts
               –Packaging – General info, lists of files, etc.
            • Divided into sections
               –Headers (unlabeled section)

Tanner Lovelace – Slide 11
                             Creating RPMs Examples
            • See Pinky and the Brain Examples at

            •    Sub package example
            •    Example of how to “rpm-ify” a package.
            •    Patching
            •    Conditional building

Tanner Lovelace – Slide 12
            • References will go here when presentation
              goes online..

Tanner Lovelace – Slide 13

Shared By: