Setting up development environment

First, you have to create a directory rpmbuild where you will work. Simply install the rpmdevtools RPM and use :

su -c 'yum install yum-utils rpmdevtools'
rpmdev-setuptree

Getting the source

We will use yum, the fedora package manager, to download the source, extract them, and install the require build & runtime dependencies. The last command line option -bp tells rpmbuid to just prepare the source by patching them with patchs provided by Fedora, if any.

yumdownloader --source dvtm 
su -c 'yum-builddep dvtm-0.5.2-1.fc12.src.rpm' 
rpm -Uvh dvtm-0.5.2-1.fc12.src.rpm 
cd ~/rpmbuild/SPECS 
rpmbuild -bp dvtm.spec

Hacking

You can now modify the sources as you wish. Just be cautious to keep the necessary data required to create a patch of your modification at the end. For example, if you are using GIT, just type:

cd ~/rpmbuild/BUILD/dvtm-0.5.2 
git init 
git add . 
git commit -am "Pristine source" 
vim config.h 
git diff >~/rpmbuild/SOURCES/myDVTM.patch

Save your patch in ~/rpmbuild/SOURCES/.

Rebuild the binary RPM

You will now have to modify the SPEC file to include your patch before regenerating the RPM. First and foremost, change the spec file revision number, then declare your patch name and add a command to apply it. Here is a diff of what you should do :

--- old/dvtm.spec	2009-08-06 05:30:23.000000000 +0200 
+++ new/dvtm.spec	2010-01-14 03:10:59.671995544 +0100 
@@ -1,6 +1,6 @@ 
Name:           dvtm 
Version:        0.5.2 
-Release:        1%{?dist} 
+Release:        2%{?dist} 
Summary:        Tiling window management for the console 

Group:          Applications/System 
@@ -8,6 +8,7 @@ 
URL:            http://www.brain-dump.org/projects/%{name}/ 
Source0:        http://www.brain-dump.org/projects/%{name}/%{name}-%{version}.tar.gz 
Patch0:         Makefile-%{version}.patch 
+Patch1:        mypatch.patch 
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 

BuildRequires:  ncurses-devel 
@@ -21,6 +22,7 @@ 
%prep 
%setup -q 
%patch0 -p1 -b .Makefile 
+%patch1 -p1

You can now build a new dvtm package.

rpmbuild -bb dvtm.spec

End

You RPM binary is ready. Just use the following command to install it:

rpm -Uvh ~/rpmbuild/RPMS/<arch>/dvtm-0.5.2-2.fc12.i686.rpm

/DS

Information gathered from: