Modifying and rebuilding an RPM from source

This is a topic covered over and over on the internet and yet I can never find the quick guide I need. Here for my notes are how to modify and rebuild an RPM from source.

First, download the SRPM and install it:

rpm -Uvh httpd-2.4.41-1.el7.src.rpm 

You may see some errors about groups, you can ignore these.

You should now have a /root/rpmbuild/ dir – if not, find where the .spec file was put (you’ll find the other needed files near it):

find / -name "*.spec" -print

Before you change anything, try to just rebuild the rpm unmodified. You’ll likely find things you need that are missing. Fix all this first.

rpmbuild -ba SPECS/httpd.spec

When you have the default rebuild working, you can start changing things. If you only need to change a configure option you can edit the .spec file in /SPECS. If you need to patch code, you’ll need to (ideally and properly) use patch files added to the sources directory. If this is not possible, you will have to copy the .tgz for the source package, unarchive it, modify it, then tar it back up and put your modified copy in /SOURCES

Leave a comment

Your email address will not be published. Required fields are marked *