Summary of Building RPMs from Source RPMs

Note: These are a summary of the steps to build from a source rpm distribution. For full instructions, see the links.

For safety, you should only build from RPM source files as a non-root user.

If you get errors like:

   unable to open /var/lib/rpm/RPMLOCK for exclusive access

you're probably try to install a binary distributed RPM not the source!


Preparation

Directory structure

Create directories for building RPMs

$ mkdir -p ~/rpm/{BUILD,RPMS/$ARCH,RPMS/noarch,SOURCES,SRPMS,SPECS,tmp}

Configuration files

~/.rpmrc

buildarchtranslate: i386: i586

buildarchtranslate: i486: i586
buildarchtranslate: i586: i586
buildarchtranslate: i686: i586


~/.rpmmacros

%_topdir                     /MyHomeDir/rpm
%_tmppath                   /MyHomeDir/rpm/tmp

%_signature              gpg
%_gpg_name                Mandrake Linux
%_gpg_path                ~/.gnupg
%distribution             Mandrake Linux
%vendor                   MandrakeSoft

Install Source

Install the source rpm ready for build

$ rpm -i mydist.src.rpm

Cleanup

Optionally, make sure the build directories are clean, if necessary.

$ rpm -bs --rmsource --rmspec SPECS/mydist.spec


Build

Build and clean

Build the source and binary rpms and clean the build directory afterwards to save disk space.

$ rpm -ba --clean SPECS/mydist.spec

Build and very clean

Build and leave things really clean.

$ rpm -ba --clean --rmsource --rmspec SPECS/mydist.spec

Clean Up

or clean up after

$ rpm -bs --clean --rmsource --rmspec SPECS/mydist.spec


http://qa.mandrakesoft.com/twiki/bin/view/Main/RpmHowTo

http://www.tldp.org/HOWTO/RPM-HOWTO/


-- Frank Dean - 06 Mar 2004