Notes on building RPMs with an example patching and rebuilding the kernel srpm from SL30x.

The SL30x update rpms are available in:

When rebuilding the kernel, don't forget to build the bcm rpm!

Install the source rpm, this unpacks the srpm and puts the source code in SOURCE and the spec file in SPECS dir:

# rpm -i kernel-2.4.21-37.EL.src.rpm

The kernel has many patches, and sometimes these may confict; your patch may apply fine to a vanilla kernel, but not to the patched version in the rpm. The order that patches are applied is defined in the spec file. In general, you should add new patches after the existing ones. So, we'll want to apply the existing patches before testing our patch.

# rpmbuild -bp SPECS/kernel-2.4.spec

You should no be able to find a copy of the file(s) that you wish to patch in BUILD/kernel-2.4.21, you can diff them with the files in the SOURCE tree to see if they have been touched by patches:

# pwd

# echo "linux-2.4.21/drivers/usb/hid-core.c" > files.txt 
# bunzip2 --stdout ../SOURCES/linux-2.4.21.tar.bz2 | tar -x -T files.txt -f -

# diff linux-2.4.21/drivers/usb/hid-core.c ../BUILD/kernel-2.4.21/linux-2.4.21/drivers/usb/hid-core.c


# mkdir -p a/drivers/usb 
# mkdir -p b/drivers/usb 
# cp ../BUILD/kernel-2.4.21/linux-2.4.21/drivers/usb/hid-core.c a/drivers/usb
# cp ../BUILD/kernel-2.4.21/linux-2.4.21/drivers/usb/hid-core.c b/drivers/usb

{edit the b version and get it how it should be...}

# diff -Nur a b > apcupsd.patch

{examine the patch to verify it...}

# cp apcupsd.patch ../SOURCES/

Place the .patch file in the SOURCES dir. Edit the spec file to include the patch. Alter/increment the release variable. Since this is a patch to a driver, will put it in the range 5000 to 7000. You need a statement listing the patch file as something to include in the rpm and a second statement that says to apply it.

%define release 37.EL.%{distribution}

Patch6901: apcupsd.patch

# fix for usb interface to APC UPS
%patch6901 -p1

After you have put the patch in place and editted the spec file, build a new srpm and then install it. Then build the binary rpms.

# rpmbuild -bs SPECS/kernel-2.4.spec
Wrote: /work/cap/software/rpm/SRPMS/kernel-2.4.21-37.EL.MSUHEP.src.rpm

# rpm -i SRPMS/kernel-2.4.21-37.EL.MSUHEP.src.rpm

# rpmbuild -bb SPECS/kernel-2.4.spec
Wrote: ...RPMS/i386/kernel-source-2.4.21-37.EL.MSUHEP.i386.rpm
Wrote: ...RPMS/i386/kernel-doc-2.4.21-37.EL.MSUHEP.i386.rpm
Wrote: ...RPMS/i386/kernel-BOOT-2.4.21-37.EL.MSUHEP.i386.rpm
Wrote: ...RPMS/i386/kernel-debuginfo-2.4.21-37.EL.MSUHEP.i38


# rpmbuild -bb --target athlon SPECS/kernel-2.4.spec
Wrote: ...RPMS/athlon/kernel-2.4.21-37.EL.MSUHEP.athlon.rpm
Wrote: ...RPMS/athlon/kernel-unsupported-2.4.21-37.EL.MSUHEP.athlon.rpm
Wrote: ...RPMS/athlon/kernel-smp-unsupported-2.4.21-37.EL.MSUHEP.athlon.rpm
Wrote: ...RPMS/athlon/kernel-smp-2.4.21-37.EL.MSUHEP.athlon.rpm
Wrote: ...RPMS/athlon/kernel-debuginfo-2.4.21-37.EL.MSUHEP.athlon.rpm

# rm -rf BUILD/*
# rm -rf tmp/*

There is also a switch --without smp you can to build just uniproc kernels.

-- TomRockwell - 15 Nov 2005
Topic attachments
I Attachment Action Size Date Who Comment
.rpmmacrosrpmmacros .rpmmacros manage 0.1 K 15 Nov 2005 - 13:53 TomRockwell  
rpm-dirs.tgztgz rpm-dirs.tgz manage 0.3 K 15 Nov 2005 - 13:55 TomRockwell directory structure for RPM build area
Topic revision: r5 - 16 Oct 2009, TomRockwell

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback