RPM : Build a binary RPM package from sources on Red Hat

From Deimos.fr / Bloc Notes Informatique
Jump to: navigation, search

1 Introduction

Building a RPM is not a complicated task, even from sources files. In my job I had to compil Open On Load kernel module and package it.

The problem is when you want to deploy this kernel module on several production servers and you don't want to have all development tools installed on all production servers. This is the documentation I've made to create RPMs with binaries from sources.

2 Compilation

It is better to test compilation before trying to package it (just to be sure it works).
So You need to have a Red Hat with development tools installed to compil Open On Load module :

Command yum
yum groupinstall "Development Tools"

Now we can compil :

wget http://www.openonload.org/download/openonload-201104.tgz
tar -xzf openonload-201104.tgz
rm -f openonload-201104.tgz
cd openonload-201104

3 Create package

Now let's build a binary RPMS from the source RPM :

cd ..
tar -cf openonload-201104.tgz openonload-201104
rpmbuild -ts openonload-201104.tgz
cd /root/rpmbuild/SRPMS/
rpmbuild --rebuild openonload-201104-1.src.rpm

You now have got packages in /root/rpmbuild/RPMS/x86_64/ and can deploy them without any development packages on production servers.