Aerospace



Home

Company Information

Information Request

Linux How-to Guides

ADSP 21xx
Digital Signal Processing
Tutorials

SW Utilities

On-line Order Form

Aerospace Projects

Commercial Projects

Circuit Boards

Server Support


Bonk

Have you found this site useful? Did we save you time? Did we cure your head-ache? Is your hair growing back now?

Please make a donation to help with maintenance.


RPM Mini-Howto

For Mandriva 2007.1 (or any other RPM distribution).

Herman Oosthuysen
Copyright Aerospace Software Ltd. GPL 2007


Scope

This is yet another RPM creation howto. The problem with RPM is its complexity and the howto guide on the RPM project site is really bad, since it leaves out all the important setup details, so even with the guide you just cannot get going. There is a good book on it, but damn - if all you want, is to make an RPM, not study for a final, then I hope this mini guide will help.

The best way to build RPMs is on a virtual machine, so that if you break your system, you can start again without much trouble from a previous snapshot. Even when building on a virtual machine, always build in your home directory. Do not build RPMs as root.

If you know nothing about RPM, read the Mandriva howto listed below, then come back here to copy and paste the essentials to set up your machine and get going. If you have half a clue already, then this guide should be sufficient.


Resources

  • Everything you never wanted to know about RPM: http://rikers.org/rpmbook/
  • A good Mandriva RPM howto: http://wiki.mandriva.com/en/Development/Howto/RPM#Preliminary_tasks
  • Get examples from the Mandriva source RPMs: http://ftp.u-picardie.fr/mirror/ftp.mandriva.com/MandrivaLinux/devel/cooker/SRPMS/main/release/
  • The confusing RPM Macros are all here: /usr/lib/rpm/macros

Preparation

Here is the information that is missing from the official Howto. I got this from the Mandriva howto and added a one line script.

First make a little script called 'mkrpmdir':

#! /bin/bash
# Make the RPM tree in your home directory
mkdir -p ~/rpm/{BUILD,RPMS/i586,RPMS/noarch,SOURCES,SRPMS,SPECS,tmp}

Put it in '/usr/local/bin' and make it executable with 'chmod 755 mkrpmdir'.

Now add two configuration files to your home directory. You got to mod that second one just a tad to suit:

File .rpmrc:
buildarchtranslate: i386: i586
buildarchtranslate: i486: i586
buildarchtranslate: i586: i586
buildarchtranslate: i686: i586

File .rpmmacros:
%_topdir               /home/herman/rpm
%_tmppath              /home/herman/rpm/tmp

%_signature            gpg
%_gpg_name             Mandriva Linux
%_gpg_path             ~/.gnupg
%distribution          Mandriva Linux
%vendor                Aeronetworks

You are now ready to go.


Examples

The best way to figure it out is to look for an example in the Mandriva SRPM repository. Find something similar to what you need to do, install the source RPM and plagiarize the spec file.

Make the rpm directory tree:

$ mkrpmdir

Download a source RPM to your home directory, for example eject-2.1.5.tar.gz and expand it with:

$ rpm -ivh eject-2.1.5.tar.gz

You can list the files with:

$ ls -R rpm

Rebuild the RPM to ensure that your setup is working:

$ cd rpm/SPECS
$ rpm -ba eject.spec

Rename the rpm directory for future reference to the spec file:

$ cd
$ mv rpm rpm-eject

Create a RPM from a source tar ball

Now for the real deal. Make a new RPM file.

First, make a new rpm tree:

$ mkrpmdir

Download a source tar ball and put the tar ball in rpm/SOURCES

Copy the spec file example to ~/rpm/SPECS

Edit it a bit, but leave the 'files' part empty for now and run:

$ rpm -bi mypackage.spec

The 'i' will stop the process without erasing the built files and you can list them with:

$ ls -R ~/rpm/tmp/whatever-buildroot

Edit the spec file again and add the file list.

That is about all there is to it.


La voila!

Herman



Copyright © 2005-2008, Aerospace Software Ltd., GPL.