This is not intended to be an extensive guide to building rpms. Although, if there is interest, that can be arranged. Over the past few years, I have had quite a bit of experience working with RPM. In both creating them from scratch, and futzing with them to maintain a fleet of servers. The documentation out there is honestly ancient. Given that, there are some neat features I use.


Do not terminate the rpm build process because of unpackaged files:

%define _unpackaged_files_terminate_build 0

Maybe your GIT repo has some extra test related stuff in it? Or maybe you are just tired of cleaning up after other developers? Either way, RPM will be very upset if it finds missing files that were not accounted for in the SPEC file. So you can either play the game of cat and mouse removing any test related materials that it finds in your $BUILDROOT, or you can just tell it to not care about them by using the directive above.


Do not build debug package:

%define debug_package %{nil}

Sometimes the debug packages are super helpful for…debugging. But what if we just don't want it to build the majority of the time? Well, we can specify this directive, and then remove it or just contradict it via command line parameters if we do.


Change RPM naming convention:

%define _rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm

Sometimes we have company naming conventions to follow. Sometimes we are just obsessive about how we name things… For whatever reason, this is how you change the way RPM names the resulting files.


Temporarily change your rpmbuild root(or topdir) location:

mkdir -p tmp/rpmbuild
rpmbuild -bb  -D "_topdir `pwd`/tmp/rpmbuild" rpm/some-leet-program.spec

Ever have to share a build box with others? Well if you end up with all of your RPMs going to the same /home/some_build_user/rpmbuild/RPMs/x86_64 sometimes things get confusing. People dont tag their builds, or someone decides to manually specify a conflicting version number, etc. Ever want to just have your own rpmbuild dir? Coincidentally thats exactly what this directive lets you do.