How To Make RPM Packages

When working with RedHat Linux systems the best way to ensure that you have the right software installed is by using RPM’s

RPM is a package management system like Solaris packages.

To create packages from source code some or all of the following steps would be needed.

To set it up a build environment and number of configuration files are needed.

First the build environment.

cd /home/asbjorn
mkdir myrpm
cd rpm

In earlier releases of RedHat a file .rpmrc was used.

Now rpmbuild uses the .rpmmacros for default values.

In the first two lines, information about the package creator is provided.

The _topdir line is included, so the package can be build as a user rather than as root.
Do not build packages as root if you can avoid it.

The following lines provide references to the build environment.

cd /home/asbjorn

vi .rpmmacros

%packager      Asbjorn Riedel <[email protected]>
%vendor        The name of the project

%_topdir       /home/asbjorn/myrpm


By defining the .spec file we can set up all the parameters needed for building packages of software delivered as tar files.

The %{_prefix} definition can be changed depending on the location where you want your package to be installed, example /opt, /usr or /usr/local. Just change the line with Prefix:  in it.

 vi myrpm/SPECS/testpackage.spec

%define name testpackage
%define version 0.0.1
%define release 1

Summary: A test package for RedHat Linux
Name: %{name}
Version: %{version}
Release: %{release}
Vendor: Guess It Must Be Me
License: None
Group: System
Prefix: %{_prefix}

This is a testpackage , specially made for testing

%package devel
Summary: package with stuff to develop %{name}.
Group: System
Requires: %{name} = %{version}

%description devel
The %{name}-devel testpackage contains stuff for building %{name}.

%setup -q




%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%doc ReadMe

%files devel
%doc ReadMe

* Thu Mar 27 2008 Asbjorn Riedel <
[email protected]>
– Initial spec file

The %install part contains the actual commands to build the software and it may need to be changed in your case.


How to finally do the build …

rpmbuild -ba SPECS/testpackage.specs