To make this happen, RPM needs to use your own environment definitions rather that of the root user. You need to override the default macros RPM uses. The most important one is the %_topdir (which by default would point to /usr/src/redhat) macro. There are a few more customizations you can make to speed up your Spec file generation. Open up a shell and create a rpmmacros file:
vim ~/.rpmmacros
Now add the following definitions into it, replacing it with your name, email address and system home directory
%distribution Mandriva Linux %packager Jeffery Fernandez <developer @jefferyfernandez.id.au> %vendor http://www.jefferyfernandez.id.au %_topdir /home/jeffery/redhat %_tmppath /home/jeffery/redhat/tmp %_signature gpg %_gpg_name 2473E75A %_gpg_path /home/jeffery/.gnupg %prefix /usr/local/
The first three lines define some macros you would use in a Spec file. This saves you from re-typing them into the Spec file every time you make one. Next comes the important bit, the topdir and tmppath macros.
As a consequence of re-defining the %_topdir macro, RPM will need the package building directory structure available in the topdir location you have defined. You can make this structure by executing the following:
mkdir -p ~/redhat/{BUILD,RPMS/{i386,i486,i586,i686,noarch},SOURCES,SPECS,SRPMS,tmp}
This will create a heirarchy of folders in your home directory (similar to the one found at /usr/src/redhat) which look like:
~/redhat/BUILD ~/redhat/RPMS/i386 ~/redhat/RPMS/i486 ~/redhat/RPMS/i586 ~/redhat/RPMS/i686 ~/redhat/RPMS/noarch ~/redhat/SOURCES ~/redhat/SPECS ~/redhat/SRPMS ~/redhat/tmp
The next three lines are required if you intend to sign your packages with a GPG key. If you don’t have one yet, you can ignore them. More about GPG signing of RPMS in an other topic
Once you have finished this, you should be ready to build packages as a normal user. Ok.. and if you are wondering what the prefix macros does….. then my answer is I am still researching about it. Quick google tells me that it is meant to define where the packages are installed. To me that doesn’t sound right. anyone have suggestions?