UWMLSC > Beowulf Systems > Medusa

RPM (Red Hat Package Manager) Manual

The purpose of this page is to explain the process of how to unpack, modify, and rebuild an rpm file. A useful reference is http://www.rpm.org/max-rpm/

Directory structure

RPM requires a set of directories in which to perform the build. The normal directory layout consists of a single top-level directory (the default name is /usr/src/redhat), with five subdirectories. The five subdirectories and their functions are:

  • /usr/src/redhat/SOURCES - Contains the original sources, patches, and icon files.
  • /usr/src/redhat/SPECS - Contains the spec files used to control the build process.
  • /usr/src/redhat/BUILD - The directory in which the sources are unpacked, and the software built.
  • /usr/src/redhat/RPMS - Contains the binary package files created by the build process.
  • /usr/src/redhat/SRPMS - Contains the source package files created by the build process.

Unpacking, modifying, and rebuilding an RPM

At this point, I'll explain the process quickly for those who just want the command syntax, and below I'll explain the process in more depth. To begin, you will need an rpm package. As an example, I'll be using ddd-3.3-1.src.rpm .

  • First, we unpack the source rpm with the following command:

    rpm -Uvh ddd-3.3-1.src.rpm

    The added flags (-Uvh) unpack the source rpm and place its files under the /usr/src/redhat/ directory structure.

  • The previous command placed three files (ddd.desktop, ddd-3.3.tar.gz, ddd-3.3-pics.tar.gz) into the /usr/src/redhat/SOURCES directory. These files are the original sources.

    • These files can be untarred/gzipped and modified. Once all modifications are complete retar/gzip the files.
    • Syntax for untarring/gzipping a file:
      • tar -xzvvf ddd-3.3.tar.gz
    • Syntax for tarring/gzipping an archive:
      • tar -cvvf ddd-3.3.tar ddd-3.3/
      • gzip ddd-3.3.tar

  • While unpacking the source rpm, a file was also placed in the /usr/src/redhat/SPECSdirectory. This file (ddd.spec) is refered to as the spec file. The spec file contains all of the information we need in order to direct RPM in the build process for this application. The first section of the spec file contains information about package being built. If modifications are made to the application, the release number should be incremented by one.

  • If the modifications to the application were only minor (e.g. modifying a script) then you can simply repackage the source. First change your working directory to the /usr/src/redhat/SPECS directory. Find the .spec file corresponding to your application and type the following command:

    • rpm -ba ddd.spec

Example transcript of modifying the memtest rpm

Unpack source RPM:
rpm -Uvh memtest86-2.6-1medusa.src.rpm
Build from source RPM:
cd /usr/src/redhat/SPECS
rpm -ba memtest86-2.6.spec
Make copy of original source code directories and tree
cd /usr/src/redhat/BUILD
cp -r memtest86-2.6 memtest86-2.6-orig
Modify source code:
cd memtest86-2.6/
[I then edited the file config.h. Note: this edit disabled the serial port output. You will do something different when you modify the source files for whatever change you are making.]
Generate a diff file to use as a patch:
cd /usr/src/redhat/BUILD/
diff -uNr memtest86-2.6-orig/ memtest86-2.6/ > memtest86-2.6-serial.patch
Copy the patch file into the SOURCES directory:
cp /usr/src/redhat/BUILD/memtest86-2.6-serial.patch /usr/src/redhat/SOURCES
Edit the spec file (warning - this is the longest part of this description):
cd /usr/src/redhat/SPECS
[The file to edit is called memtest86-2.6.spec. Here is a summary of the changes:
After Source: change
Patch0: memtest86-2.6.patch
Patch1: memtest86-2.6-unsupervised.patch
to read
Patch0: memtest86-2.6.patch
Patch1: memtest86-2.6-unsupervised.patch
Patch2: memtest86-2.6-serial.patch

%patch0 -p1 -b .buildroot
%patch1 -p1
to read

%patch0 -p1 -b .buildroot
%patch1 -p1
%patch2 -p1
Release: 1medusa
Release: 2medusa
Add additional lines to the %build section of the SPEC file if needed. In my case I added:
cat test.h.save | sed 's/#define MAXPASS 4/#define MAXPASS 144/' > test.h
mv -f memtest.bin memtest.bin-week
make clean
at the appropriate point. This changed the number of iterations of the memtest from 4 to 144, and
saved the resulting executable in memtest.bin-week.

I also edited the %install section of the .spec file I added a line reading:
cp memtest.bin-week $RPM_BUILD_ROOT/boot/memtest86-week

I also modified the post-installation section of the file. This follows %post. The main change was to modify the script that updateds /etc/lilo.conf, to add extra lines to include this new version of memtest.

I modified the part of the script that defines the file attributes:


Finally, I edited the "Changelog" at the end of the .spec file to put in come comments about what I had done. I added
* Sun Dec 2 2001 Bruce Allen <ballen@uwm.edu>
- changed number of unsupervised runs to 144 (one week + 30 min) since without serial IO it is faster.


Rebuild the SRPM and RPM
cd /usr/src/redhat/SPEC
rpm -ba memtest86-2.6.spec
The new SRPM and RPM should now be tested then checked into the CVS archive. They can be found in:
/usr/src/redhat/RPM and /usr/src/redhat/SRPM

$Id: rpm_manual.html,v 1.7 2003/01/06 22:45:21 kflasch Exp $
Check this page for dead links, sloppy HTML, or a bad style sheet; or strip it for printing.
Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.