Howto: Building RPM packages as a normal user

Author: knut (a) knuthaugen dot no, copyright 2004.
Legalese: Please read the copyright and the disclaimer wich apply to this document

In a standard install of an rpm based distribution, such as Fedora, Redhat, Mandrake or SuSE, one has to be root to build binary rpm packages from source packages. There is really no need for using the root account for this kind of work. In addition, it's a good principle to only use the root account for what you need it for, and nothing else.

Here's what you do:

  1. We need rpm directories locally, as substitutes for /usr/src/redhat and the likes.
    Run mkdir -p ~/rpm/SOURCES ~/rpm/BUILD ~/rpm/SPECS ~/rpm/RPM
  2. Then we need a .rpmmacros file in our home directory:
    echo '
    %_topdir /your/home/dir/rpm
    %_tmppath /your/home/dir/rpm/BUILD
    %_buildroot /your/home/dir/rpm
    ' > ~/.rpmmacros
  3. Install an rpm source packages as you would do as root, and the source package will be installed in your home dir rpm directory. Change to the SPECS directory and build as your own user.
  4. That's it!

There are some additional tips as well. If you add %debug_package %{nil} to the .rpmmacros file, the standard debug package will not be built. Also, you can save space in your home directory if you set %_tmppath in .rpmmacros to /var/tmp or some other scratch disk with a lot of space.


Copyright © Knut Haugen 2004-08-23, last updated 2004-08-23, valid xhtml 1.0 strict