Jul 082008
 

Customizing your RPM build environment

To make RPM use your environment definitions, you need to override the default macros RPM uses. The only one that is crucial for this is %_topdir (which by default would point to /usr/src/redhat).

You can do this by adding the following to ~/.rpmmacros.

%_topdir /home/dag/redhat/

As a consequence, RPM will need the default directory structure underneath. So you can do as user:

$ mkdir -p ~/redhat/{BUILD,RPMS/{i386,i686,noarch},SOURCES,SPECS,SRPMS}

And now you’re set to go.

The obvious catch

Beware that you don’t have the same permissions as root, which means you can’t chown files to other users. So if the default Makefile uses chown or install to change ownership, this will obviously fail. As a workaround, you can’t use %makeinstall, and instead use install yourself without changing owners. Ownerships should be in the %files section.

Customize even more !

Since you now can build packages yourself, you can also customize the default packager, vendor and other information by defining more macros.

%packager Dag Wieers <dag@wieers.com>
%vendor Dag Wieers <dag@wieers.com>
%_tmppath /home/dag/tmp/
%_topdir /home/dag/redhat/
%prefix /usr/local/

There are much more macros for changing default paths, programs or even function-macros. See our links for more specific information.