BuildingRPMPackages

From The Open Source Backup Wiki (Amanda, MySQL Backup, BackupPC)
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

WORK IN PROGRESS! TALK TO KEN BEFORE EDITING!

This guide is intended to provide information on how to build RPM packages. It is not intended to discuss packaging software as RPMs, which is much more lengthly, and is covered in depth very well on the Fedora Project Wiki.

Setup

Building as a non-root user

The defaults for RPM are assuming that you build packages as root. While this assumption is primarily based on historical reasons, it mostly has to with the default directories used by the RPM system when building packages:

  • RPM installs the software during the packaging process, and normally only the root user can write to the install directories.
  • RPM also expects to read and write in the directories under /usr/src/redhat, which ordinary users cannot modify.

To work-around these limitations, we will need to perform the following steps:

  1. Create the necessary directory structure for the RPM build process
  2. Create an RPM macro configuration that points to these directories

Creating the directory structure

For the account that will be building the RPM packages, the following directory structure must be present:


~/rpm
~/rpm/SOURCES
~/rpm/SPECS
~/rpm/BUILD
~/rpm/RPMS
~/rpm/SRPMS
~/rpm/TEMP

This structure can either be created manually, automatically by running the following script in the user's home directory:


#!/bin/sh

mkdir rpm
cd rpm

for DIR in SOURCES SPECS BUILD RPMS SRPMS TEMP;
do
   mkdir $DIR
done

cd ..

Creating the RPM macro configuration

To tell the 'rpm' command to use this new directory structure, a personalized macro file needs to be created in the user's home directory.

To create and activate the configuration, create a file in your home directory called .rpmmacros as follows:


%_topdir /home/<your_userid>/rpm
%_tmppath %{_topdir}/TEMP

(replace <your_userid> with your user name.)

This tells the 'rpm' command to create and find relevant files in a different set of directories from the default. What 'rpm' normally looks for under

/usr/src/redhat

will instead be under

/home/<your_userid>/rpm

.

Building