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:

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 .

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 $