The basic procedure to build an RPM is as follows:
- Get the source code you are building the RPM for to build on your system.
- Make a patch of any changes you had to make to the sources to get them to build properly.
- Make a spec file for the package.
- Make sure everything is in its proper place.
- Build the package using RPM.
The spec file is required when building a RPM. The file holds the description and the instructions of how to build the software along with a file list of the binaries required for the install.
Below will be the portions of the spec file and their descriptions:
Summary: A visual aid for the physical location of devices in your datacenter's racks.
Name: racmon
Version: 0.1.1
Release: 1
Copyright: GNU
Group: Documentation
Source: https://github.com/Driste/racmon-0.1.1.tar.gz
Patch: racmon-0.1.1-buildroot.patch
BuildRoot: /var/tmp/%{name}-buildroot
- Summary: This is a one line description of the package.
- Name: This must be the name string from the rpm filename you plan to use.
- Version: This must be the version string from the rpm filename you plan to use.
- Release: This is the release number for a package of the same version (ie. if we make a package and find it to be slightly broken and need to make it again, the next package would be release number 2).
- Copyright: This line tells how a package is copyrighted. You should use something like GPL, BSD, MIT, public domain, distributable, or commercial.
- Group: This line is used to tell high level installation programs (such as Red Hat's gnorpm) where to place this particular program in its hierarchical structure. You can find the latest description in /usr/doc/rpm*/GROUPS.
- Source: This line points at the HOME location of the pristine source file. It is used if you ever want to get the source again or check for newer versions. Caveat: The filename in this line MUST match the filename you have on your own system (ie. don't download the source file and change its name).
- Patch: This is the place you can find the patch if you need to download it again. Caveat: The filename here must match the one you use when you make YOUR patch.
- BuildRoot: This line allows you to specify a directory as the "root" for building and installing the new package. You can use this to help test your package before having it installed on your machine.
%description
This is a multi-line field that should be used to give a comprehensive description of the package.
%description
Racmon is a application that allows the system administrator to
view the physical locations and configurations of devices in
their datacenter. It is a web application with appliance features
to check the network and statuses of the racks.
%prep
The second section of the spec file is the prep. This with where you get the sources ready to build. You need to do anything here to get the sources patched and setup like the need to be setup to do a make. In other words, this is where you would unpack the sources and cd into the source directory.
%prep
%setup -q
%patch -p1 -b .buildroot