Recompile a source rpm your own way 

Howto 

rpm -ih emacs-21.2-18.src.rpm

or,

apt-get source emacs
cd /usr/src/redhat/

change

        %configure --with-gcc --with-pop --with-sound
to
%configure --with-gcc --with-pop --without-sound --without-toolkit-scroll-bars

in SPECS/emacs.spec

Increase Release number, so that ours won't get overwritten during apt-get upgrade. E.g, Change "Release: 18" to "Release: 18.1"

Get dependent rpms (XFree86-devel ncurses-devel libpng-devel libjpeg-devel libungif-devel libtiff-devel) and istall them. or better,

apt-get build-dep emacs

Then,

rpmbuild -bb SPECS/emacs.spec

Then,

move out built rpm:

cd ...
mv /usr/src/redhat/RPMS/i386/emacs-2*.i386.rpm .
rpm -Uh emacs-2*.i386.rpm

History 

rpm -ih emacs-21.2-18.src.rpm

change

%configure --with-gcc --with-pop --with-sound

to

%configure --with-gcc --with-pop --without-toolkit-scroll-bars

in SPECS/emacs.spec

% rpmbuild -bb SPECS/emacs.spec
[...]
+ ./configure --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --target=i386-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --with-gcc --with-pop --without-toolkit-scroll-bars
[...]
Processing files: emacs-leim-21.2-18
[...]
Requires: emacs
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/emacs-21.2-root
Wrote: /usr/src/redhat/RPMS/i386/emacs-21.2-18.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/emacs-el-21.2-18.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/emacs-leim-21.2-18.i386.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.18929
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd emacs-21.2
/usr/src/redhat/BUILD/emacs-21.2
+ rm -rf /var/tmp/emacs-21.2-root
+ exit 0
-bb    Build a binary package  (after  doing  the  %prep,  %build,  and
       %install stages).
rm -rf /usr/src/redhat/BUILD/emacs-21.2
rm /usr/src/redhat/SPECS/emacs.spec

Trying history 

Attempt 1 

cd /usr/src/redhat
% rpmbuild -bp SPECS/emacs.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.83857
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ cd /usr/src/redhat/BUILD
+ rm -rf emacs-21.2
+ /usr/bin/bzip2 -dc /usr/src/redhat/SOURCES/emacs-21.2.tar.bz2
+ tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ /usr/bin/bzip2 -dc /usr/src/redhat/SOURCES/leim-21.2.tar.bz2
+ tar -xf -
[...]
+ echo 'Patch #1 (emacs-21.2-pop.patch):'
Patch #1 (emacs-21.2-pop.patch):
+ patch -p1 -s
+ exit 0
-bp    Executes  the  "%prep"  stage  from the spec file. Normally this
       involves unpacking the sources and applying any patches.
cd BUILD/emacs-21.2
configure --without-toolkit-scroll-bars

— I want standard x-scrollbar behavior

make
src/emacs &

— test run ok

make install

— do it manually! Do NOT use the 'rpmbuild -bi' command:

-bi    Do  the  "%install"  stage  from  the spec file (after doing the
       %prep and %build stages).  This generally involves  the  equiva-
       lent of a "make install".

It wipe off all my previously build when I tried!

# Tried to build rpms out of my current build but failed:
% rpmbuild -bb --nobuild SPECS/emacs.spec
[...]
RPM build errors:
    Could not open %files file /usr/src/redhat/BUILD/emacs-21.2/core-filelist: No such file or directory
    Could not open %files file /usr/src/redhat/BUILD/emacs-21.2/el-filelist: No such file or directory
    Could not open %files file /usr/src/redhat/BUILD/emacs-21.2/leim-filelist: No such file or directory
make uninstall

— very important! It installs emacs to /usr/local/bin/emacs, not the place specified by rpm!

Attempt 2 

How about I build it first? Will the files be generated then?

cd /usr/src/redhat
rpmbuild -bc SPECS/emacs.spec
cd BUILD/emacs-21.2
configure --without-toolkit-scroll-bars
# -- I want standard x-scrollbar behavior
make
src/emacs &
# -- test run ok
cd /usr/src/redhat
rpmbuild -bi --nobuild SPECS/emacs.spec
[...]
RPM build errors:
    Could not open %files file /usr/src/redhat/BUILD/emacs-21.2/core-filelist: No such file or directory
[...]

Attempt 3 

Seems that I have to do build-install to get those files generate:

rpmbuild -bi SPECS/emacs.spec
rpmbuild -bb --nobuild SPECS/emacs.spec
# -- no rpms written

Help 

Do not use —rebuild or —recompile. When invoked as,

rpmbuild --rebuild|--recompile SOURCEPKG ...

rpmbuild installs the named source package, and does a prep, compile and install.

According to man page, —rebuild builds a new binary package. When the build has completed, the build directory is removed (as in —clean) and the the sources and spec file for the package are removed.

I found that —recompile removes the build directory too! It leaves the spec file though.

% rpmbuild --recompile emacs-21.2-18.src.rpm
[...]
Wrote: /usr/src/redhat/RPMS/i386/emacs-21.2-18.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/emacs-el-21.2-18.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/emacs-leim-21.2-18.i386.rpm
[...]
Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.77688
+ umask 022
+ cd /usr/src/redhat/BUILD
+ rm -rf emacs-21.2
+ exit 0