Personal tools
You are here: Home Documentation Tips rpms RPM-Build.html
Document Actions

RPM-Build.html

by Troy Dawson last modified 2007-03-09 10:07
Creating RPM's for Linux

RPM stands for Red Hat Package Manager.  It is a way to install and uninstall programs, files, or whatever you wish, quickly and easily on a Linux System.

Building an RPM isn't as easy as using them, but it isn't too complicated of a task.  The RPM program is much more flexible and versatile that what I am going to go through, but this info is to get a complete novice started and creating their own RPM's.   For more indepth How-To's, you can try RPM-How-To (needs better examples, but alot was taken from it for this) or if you  want a really good book on it, Maximun RPM is available in Postscript or LaTeX format.

We're going to start with two simple examples and then let you customize them from there, instead of the way the two above works try, which is give you the whole shebang and drown you in it.  Our two examples will be from Pinky and The Brain.  Pinky wants to have his computer make butterscotch pudding, Brain wants it to take over the world.

Where to build an RPM:
With all of Fermi Red Hat distributions (and most all Linux distributions) there is a directory /usr/src/redhat that has in it several more directories.

  • /usr/src/redhat/SOURCES - Contains the original sources, patches, and icon files.
  • /usr/src/redhat/SPECS - Contains the spec files used to control the build process.
  • /usr/src/redhat/BUILD - the directory in which the sources are unpacked and the software is built.
  • /usr/src/redhat/RPMS - Contains the binary package files created by the build process.
  • /usr/src/redhat/SRPMS - Contains the source package files created by the build process.
For the most part we need only concern ourselves with the SOURCES and the BUILD directories.  The other directories the rpm will use when it's building the rpms.

So let's look at the directories of our two little lab mice, before they build their rpm's.
The Brain (Example 1)
Pinky (Example 2)

Now take a look at the directories after they built their rpm's.
The Brain (Example 1)
Pinky (Example 2)

And just for fun, lets look at before and after at the same time.
The Brain (Example 1)
Pinky (Example 2)

Zoinks.  Where did all those other files come from? 
Well, we told the rpm to put them there, or at least what we should name the files, when we built the rpm.
Narf.  But how did the little rpm know what we wanted? 
A very good question.  We told the rpm what we wanted in a file called the spec file.

The Spec File:
This file is so important that we are going to give it a page all it's own.  If you just want to see examples of them, you can look at our examples.
The Brain (With Comments, Plain)
Pinky (With Comments, Plain)

What to do last:
Naarf.  That spec file blew my brain into tiny bits.  Yippeee!!  Oh, no.  no ... but you still haven't told us how to actually build an rpm now, have you.
Presicely.  Now we are going to actually hit the keys that start the building process in motion.  First we must be in the SPECS directory that we mentioned earlier.  Our specs file must be in there also.  Then we type in the command
rpm -ba conquest67.spec
But ... I wanted to make butterscotch pudding ...
Oh, very well, then type in the command
rpm -ba butterscotch.yummy.spec
Weee... and then what happens.
Well if we did everything correctly, the rpm build program will untar my files, putting them in a corresponding directory in the BUILD directory.  It will then make sure that I am able to do everything that I have told it to do in the installation.  Finding everything able to be installed it will shove all the files and instructions in a larger file called the source in the SRPMS directory.  It then runs a complicated algorithem that take the source file and converts it into a binary executable, which it properly names and places in RPMS directory, thus making it possible for me to take over the..
Then I get my butterscotch pudding?
Yes, if that is what your quivering mind wants.  You get your butterscotch pudding.
But what if I don't want it to do all that?  What if I don't want it to actually make it into a binary, because sources are so much more yummy?
*Sigh*  Well then you simply do not type the -ba, you type in something else.  You can find all the variations for building in the rpm man page.  Now if you excuse me, I have a world to conquer.
Naaarf ... zoink!



MAIN - SPEC FILE - EXAMPLE 1: DIR - SPEC - EXAMPLE 2: DIR - SPEC

How-To
July 23, 1999
 
 


Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: