Shortest RPM-HowTo


Before you think about putting your code into an RPM, it is much useful if you have at least three targets in your Makefile:

removed all generated files
compile all necessary files
copy the files into the system directories

It is important that after make install the binaries are well installed, and that even after removal of the source-direcotry, the program still runs. Furthermore it is necessary to have an optional variable for the Makefile, preferably called RPM_BUILD_ROOT, that is prefixed on all installed files. So, for example, if RPM_BUILD_ROOT points to /tmp/rpm, a file usually installed in /usr/bin would be installed in /tmp/rpm/usr/bin. Once you have done this, you may take the next step: The spec file


If you are working with xemacs (I advise you too, but vi seems to be pretty OK, too), you can open a new file in your project-directory that is called <project_name>.spec XEmacs then will fill it with the standard lines. I will go through the lines from Etrans.spec, the specification-file used in the Etrans-project: </project_name>

Summary: Etrans - the Software Radio from EPFL/Eurecom Name: Etrans Version: 0.3 Release: 1 URL: http://lcmpc10.epfl.ch] Source0: %{name}-%{version}.tar.gz License: GPL Group:Development/System  BuildRoot: %{_tmppath}/%{name}-root Requires: rtlkernel = 2.4.4rtl rtlinux = 3.1  %description This is a remake of the software radio originally written by Raymond Knopp and others. It is put in a usable shape, bound with a frontend and should also get some documentation.  %prep %setup -q  %build make  %install rm -rf $RPM_BUILD_ROOT make install  %clean rm -rf $RPM_BUILD_ROOT  %files %defattr(-,root,root) /opt/radio /etc/profile.d /dev/daq0  %changelog * Tue Mar  5 2002 root <> - Initial build.

We will no go through the file line by line and look what this rpm-spec file is all about:

  • Summary is a one-liner for a description.
  • Name is the base-name of your Project. It has to match with your directory-name and with the name of your .tgz In our example the project Etrans in it’s version 0.3 is stored in a directory called Etrans-0.3 and it’s source-tarball is called Etrans-.0.3.tgz So the name would be Etrans
  • Version In our example, this is 0.3
  • URL is an optional URL where the source can be get
  • License should be GPL, but of course may differ
  • Group is one of the groups described in /usr/share/doc/rpm-4.0.3/GROUPS
  • Requires gives a list of packages that need to be installed. It is important to have a space before and after the ‘=’, ifnot the file ‘rtlkernel=2.4.4rtl’ is expected.
  • description is a longer description
  • build commands to build the binaries. In some cases you may want to include a ./configure here.
  • install the variable RPM_BUILD_ROOT is created in the prep step and points to the base directory for the installation. ‘make install’ then puts the files in this directory, if all is put up well. For some programs you’ll need a ‘configure –prefix=$RPM_BUILD_ROOT’ in the build stage. But Etrans looks directly for the environment-variable RPM_BUILD_ROOT and puts the files under this directory
  • clean after the binaries are taken from the install-directory, this is called to clean up the installation-directory. The command presented here is a bit of a security-hazard, as RPM_BUILD_ROOT may point to ‘/’ and thus the whole filesystem would be deleted.
  • files indicates which files need to be taken into the rpm-package. All names and directories are relative to $RPM_BUILD_ROOT. If a name points to a directory, it is stepped through recursively and all files are included in the rpm.
  • changelog don’t forget to update your changes

Building of RPM

Once you have your spec-file, you only need to pack up your project and let it build:

tar cvzf Etrans-0.3.tar.gz Etrans-0.3/. rpmbuild -ta Etrans-0.3.tar.gz

The ‘.’ in Etrans-0.3/. is there because on my system, Etrans-0.3 is a symbolic link. So rather than tarring a symbolic link, I’d like to tar the content of this symbolic link! The second command then does everything from decompressing the tar.gz to calling all necessary scripts and building up a rpm. If all goes right, you can find your rpm in


If you’re on an intel machine, of course. Try the file on a clean, freshly installed machine, to look if you didn’t forget any dependencies.