First, the actual environment for BUILDing RPMs is needed. The commands named here prepare as in a quick and easy way.

  • To compile SRPMs, the programme rpmbuild is always required. The application is installed with the command su -c 'yum install rpm-build'.
  • The package yum-utils is also required. The command for the installation is: su -c 'yum install yum-utils'.
  • Unfortunately, many source packages silently assume that compilers and the central developer libraries and tools are already installed. The following command can be used under Fedora to install all required packages: su -c 'yum install @buildsys-build rpmdevtools'.
  • Fedora also offers support for building the RPMBUILD directory tree with the command rpmdev-setuptree.

The installation of rpmbuild under CentOS creates the path /usr/src/redhat as the RPMBUILD directory. To create RPMs or compile SRMPs, a special user created for this purpose should be used instead of the root user. The existing environment can simply be copied into the home directory of the designated user.

su -
cp -r /usr/src/redhat/ ~/rpmbuild
echo '%_topdir %(echo $HOME)/rpmbuild' ~/.rpmmacros

So now almost everything is done, the environment for compiling is ready. Now you have to check whether all developer packages are installed. This can be verified and installed with the following command under CentOS: su -c 'yum-builddep <src-paketname'>. Alternatively, use the command rpm -qp --requires to find out <src-paketname> and install them with the package manager. All preparations completed, now it's time to compile the SRPM package. This is quite simple and is done by the following command: rpmbuild --rebuild <src-paketname>.