7. Building RPMS from SOURCE or SRPMS

If you haven't done so before: It is easy to build or rebuild RPMS from SRPMS. Let's get a quick overview how we build RPMS in our HOWTO.


Never build RPMS as root.

  1. Log into your machine as a regular user.

  2. create a mirror image of the main RPM directory structure in your $HOME and

  3. tell RPM to use these directories instead of the original ones.

7.1. Create RPM directories

RPM needs a certain directory structure to build RPMS from SOURCE or from SRPMS. When we build them as non-root user, we cannot use the default location because only root is allowed to write to those directories. So we create the same directory structure in our regular users $HOME-directory:

[user@example.com]$ mkdir $HOME/rpm $HOME/rpm/SOURCES $HOME/rpm/SPECS $HOME/rpm/BUILD $HOME/rpm/SRPMS $HOME/rpm/RPMS $HOME/rpm/RPMS/i386

When we are done with this, the directory tree of the new rpm directory in our $HOME-directory should look like that:

Example 1. directory tree of new rpm directory

|-- RPMS
|   `-- i386

7.2. Set environment variables

Now we need to tell the RPM-Manager that the non-root user wants this location to build RPMS instead of the default location.

[user@example.com]$ echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros

If you want to dig deeper into building RPMS you can find excellent information in the Maximum RPM HOWTO at rpm.org.

That's it, you are ready to build RPMS.