In order to safely build RPMS, we are going to setup a build environment. By default, the build environment is in /usr/src/rpm and requires you to be logged as root to build RPMS. This is dangerous because while you are logged as a superuser, you have too much potential to harm your system and a failed attempt to build a RPM could damage your system. To create a build environment, you will first need to create a set of directories in your home folder (write them as I do as it is case sensitive). Below is an example of my build directories.
/home/jfdesign/src/rpm/RPMS/noarch
(this is where multi architecture rpms will be created)
/home/jfdesign/src/rpm/RPMS/i586
(this is where i586 rpms will be created)
/home/jfdesign/src/rpm/RPMS/i686
(this is where i686 rpms will be created)
/home/jfdesign/src/rpm/RPMS/i486
(this is where i486 rpms will be created)
/home/jfdesign/src/rpm/RPMS/i386
(this is where i386 rpms will be created)
/home/jfdesign/src/rpm/RPMS/athlon
(this is where athlon rpms will be created)
/home/jfdesign/src/rpm/BUILD
(this is where the source files are installed during the build process)
/home/jfdesign/src/rpm/SRPMS
(this is where the source rpms will be created)
/home/jfdesign/src/rpm/SOURCES
(this is where you will place the source codes of the RPM to be built)
/home/jfdesign/src/rpm/SPECS
(this is where you will place the spec file of the RPM to be built)
/home/jfdesign/src/tmp
(this is where the build process takes place and error logs are created)
This command will create the directory structure:
cd ~
mkdir -p src/rpm/RPMS/i386
mkdir -p src/rpm/RPMS/i486
mkdir -p src/rpm/RPMS/i586
mkdir -p src/rpm/RPMS/i686
mkdir -p src/rpm/RPMS/noarch
mkdir -p src/rpm/RPMS/athlon
mkdir -p src/rpm/SRPMS
mkdir -p src/rpm/SOURCES
mkdir -p src/rpm/SPECS
mkdir -p src/rpm/BUILD
mkdir -p src/tmp
Once we have all the directories setup, we need to create two files to let the system know that we will be using our own build environment. The two files must be placed in your home directory (my files are in /home/jfdesign). Use a plaintext editor such as SCiTE or KWrite to create these files. The first file is called .rpmrc (do not forget the dot at the start of the name as it is a hidden file). Place the following content in this file.
buildarchtranslate: i386: i586
buildarchtranslate: i486: i586
buildarchtranslate: i586: i586
buildarchtranslate: i686: i586
The second file is called .rpmmacros (do not forget the dot at the start of the name as it is a hidden file). Place the following content in this file (do not forget to remove my name and put yours in it).
%_topdir /home/jfdesign/src/rpm
%_tmppath /home/jfdesign/src/tmp
%distribution KLIXs
%vendor Kreators
%distsuffix klixs2007
Now our system is ready to build rpms.