The Trick to Creating RPM's from Binaries Directly

Editor's Note: The preferred method for building RPM's is from source. These instructions are for situations where this is not possible or practical.

The trick to building rpms from binaries directly:

  1. Create a spec file for your rpm, but leave the %prep, %setup, %build, and %install sections blank. Put the spec in /usr/src/redhat/SPECS.
  2. In the %files section of your specfile, list all the binary files you'd like included in the RPM, with full path information.
  3. Create an empty tarfile for your project... If you've set your Source: field in the spec file to be something like "project.tgz", make sure that your "empty" tar file contains only a "project" directory. Place this tarfile in /usr/src/redhat/SOURCES.
  4. cd /usr/src/redhat/SPECS and issue the command "rpm -bb specfile.spec"

RPM should now go and build the RPM directly from binaries.

Note: I got caught on the %files section in the specfile - I kept seeing the error "filename xyz listed twice". The problem was that my list of files was created from the output of the find command and looked something like this:


RPM was seeing the directory1 and directory2 as files, and considered the entries following them to be duplicates. I should have used the ``find -type f'' option to specify files only.

This tip was originally posted to the OCLUG mailing list by Michael Kelly.