The Patch in the Hat

From: Barsalou <barjunk@attglobal.net>
Date: Sat May 07 2005 - 21:21:15 AKDT

Recently I upgraded my system to Fedora Core 3. One of the issues this
created was that my version of Win4Lin 9x wouldn't work with the new
kernel.

In order to make the new kernel work, I was going to have to patch it.

Several people suggested starting with a pristine kernel from kernel.org
and work from there. This would have been the easy way to do it.

Instead it was decided to use the kernel src.rpm file and modify that.
This way there would be an easy way to recreate the kernel and to leave
a majority of the "features" of the stock Fedora kernel.

This wasn't as easy as you would think and there wasn't a lot of good
information about what I was specifically trying to do.

There were two main things that needed to be accomplished:

1. I needed to change the settings in the .config file to contain
specific entries. Namely, CONFIG_4KSTACKS=n, CONFIG_MKI=y and
CONFIG_REGPARM=n. The 4KSTACKS is to allow the use of NDISWrapper for
network devices that use XP drivers. Most of the newer ones will fail
with 4K stacks. CONFIG_MKI and CONFIG_REGPARM are to allow Win4Lin 9x to
work.

2. There are two needed patches for Win4Lin. The patches were easily
downloaded from the Win4Lin site. The goal was to incorporate these two
patches into the src.rpm

Actually the second part was the easier of the two. To incorporate the
two patches in the spec file all it took was to modify the spec file and
point it to the two patch files. The default location to store the
patches is: /usr/src/redhat/SOURCES. If you used the standard -ivh
command to install the src.rpm, everything gets put there. The spec
file is in: /usr/src/redhat/SPECS.

Changes were necessary to the spec file to place the patches in a
location that would work. Here is what I had to do:

- Place the patches above the others.
- Remove the Tux patch, it conflicted with the Win4Lin patch
- modify a section that wasn't working.

Having to modify the section of the spec file that wasn't working
affected my ability to accomplish my first task. I added the following
code to have it go through each of default config files and add the
4KSTACKS and other entries:

cd configs
for file in *.config
do
        grep -Ev 'CONFIG_4KSTACKS' $file > $file.tmp
        echo -e "CONFIG_4KSTACKS=n\n" >> $file.tmp
        mv -f $file.tmp $file
done

The for loop was repeated for each of the settings I wanted to change.
Additionally, at the end this was needed:

cd ..

Testing that the patches were in the right place was easy. Here is the
command:

rpmbuild -bp --target=i686 /usr/src/redhat/SPECS/kernel-2.6.spec

This does the prep stage, creates the /usr/src/redhat/BUILD directory
and patches the pristine kernel and copies the appropriate config file
to .config.

If a problem is created, the program lets you know and a reject file
will be created to help you rectify the problem.

If everything is OK after the prep stage, you can issue this command:

rpmbuild -bb --target=i686 /usr/src/redhat/SPECS/kernel-2.6.spec

This creates the binary needed to install the changed kernel. It stores
this here: /usr/src/redhat/RPMS

I hope this helps someone else when modifying a kernel src.rpm.

Mike B.
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Sat May 7 21:20:26 2005

This archive was generated by hypermail 2.1.8 : Sat May 07 2005 - 21:20:26 AKDT