Differences between revisions 1 and 16 (spanning 15 versions)
Revision 1 as of 2007-05-09 16:19:00
Size: 5469
Editor: ?HvWoerkom
Comment:
Revision 16 as of 2008-04-08 15:50:01
Size: 4668
Editor: madduck
Comment: add instruction about documenting changes in changelog
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
== Reasons to do this ==
 1. Modifying the Debian configuration to enable the Nvidia closed source driver creation. Specifically in 2.6.20 if '''CONFIG_PARAVIRT''' is set, the Nvidia driver won't build, you might want to change that setting.
 1.#2 Modifying the Debian configuration to change the '''preemption model'''.
 1.#3 Modifying the Debian configuration to change the '''timer frequency'''.
 1.#4 Modifying the Debian configuration to change the '''Logo'''.
 1.#5 Modifying the Debian configuration to add '''kernel timings'''.
 * Reasons to do this:
  1.#1 Modifying the Debian configuration to change the '''preemption model'''.
  1.#2 Modifying the Debian configuration to change the '''timer frequency'''.
  1.#3 Modifying the Debian configuration to change to '''Pata'''.
  1.#4 Add an patch fix.
  1.#5 Add your favorite patchset.
 
What you'll get is exactly the kernel that Debian releases but with those added changes.
Line 14: Line 16:
What you'll get is exactly the kernel that Debian releases but with thos added changes. == Add a Patch to linux-2.6 ==
Line 16: Line 18:
== Presumption ==
You are just interested in building one flavor of a kernel-image.
First get the orig tar ball from buildserver, see [DebianKernel], unpack it:
{{{
~/src$ tar xzf linux-2.6_2.6.24~rc6.orig.tar.gz
}}}
Line 19: Line 23:
== 10 easy (albeit time consuming) steps == Get latest Debian patches + config settings:
{{{
~/src/linux-2.6-2.6.24-rc6$ svn export svn://svn.debian.org/svn/kernel/dists/trunk/linux-2.6/debian
}}}

Now you can start adding patches inside the patches dir. To have them applied don't forget to add them to the series file.

{{{
~/src/linux-2.6-2.6.24~rc6$ cp ~/special-fix.patch debian/patches/bugfix/
~/src/linux-2.6-2.6.24~rc6$ echo "+ bugfix/special-fix.patch" \
  >> debian/patches/series/1~experimental.1
}}}

Do not forget to document the new patch in a new stanza at the top of {{{debian/changelog}}}. You will likely want to append some string to the version, using {{{~}}} or {{{+}}} to ensure your change does not conflict with existing or future official kernel packages.

Now check that your patchset still applies and fix any conflicts
{{{
~/src/linux-2.6-2.6.24~rc6$ make -f debian/rules source-all
}}}

Then build with appropriate DEBIAN_KERNEL_JOBS according to the box core cpu number:
{{{
~/src/linux-2.6-2.6.24~rc6$ DEBIAN_KERNEL_JOBS=${NR_CPUS} debuild
}}}

== 8 easy (albeit time consuming) steps ==
Assuming you are just interested in building one flavor of a kernel-image.
Line 21: Line 52:
 1.#2 Get the kernel source. You could install the kernel source package:  1.#2 Get the package source. For this to work, you need to have {{{deb-src}}} lines for the official archive in {{{/etc/apt/sources.list}}}:
Line 23: Line 54:
apt-get install linux-source-2.6 apt-get source linux-2.6
Line 25: Line 56:
But that will get the entire kernel source. Very large. A better approach is to keep up to date on the latest stable kernels from http://www.kernel.org and download the patch files when they become available. Then you just run a script to install the source into your directory:
Now your tree holds the source and all changes Debian made to it.

 1.#3 Add your patch into the {{{debian/patches}}} directory, as per the above. It may be a good idea to name the new series accordingly. For instance, when adding the "foo" patch, you might want to add a reference to the patch (see above) to {{{debian/patches/series/1+foo.1}}}, assuming {{{debian/patches/series/1}}} is the latest file. By ''abusing'' the ABI field for this, one guards against possible confusion when such custom kernel packages are installed on otherwise pristine Debian systems.

 1.#4 If you haven't yet, document your change in {{{debian/changelog}}}, e.g. with the {{{dch}}} tool from the {{{devscripts}}} package, and append the same string ("+foo.1") to the package version as you appended to the ABI field.
Line 27: Line 64:
#!/bin/bash
set -x
PLACE=/home/hugo/linux-2.6.20-3-build
dch --local +foo.
}}}
Line 31: Line 67:
cd $PLACE
tar -xjvf /hda10/backup.files/linux-2.6.9.tar.bz2
cd $PLACE/linux-2.6.9
patch -p1 < /hda10/backup.files/patch-2.6.10
cd $PLACE
mv $PLACE/linux-2.6.9 $PLACE/linux-2.6.10
cd $PLACE/linux-2.6.10
patch -p1 < /hda10/backup.files/patch-2.6.11
cd $PLACE
mv $PLACE/linux-2.6.10 $PLACE/linux-2.6.11
cd $PLACE/linux-2.6.11
patch -p1 < /hda10/backup.files/patch-2.6.12
cd $PLACE
mv $PLACE/linux-2.6.11 $PLACE/linux-2.6.12
cd $PLACE/linux-2.6.12
patch -p1 < /hda10/backup.files/patch-2.6.13
cd $PLACE
mv $PLACE/linux-2.6.12 $PLACE/linux-2.6.13
cd $PLACE/linux-2.6.13
patch -p1 < /hda10/backup.files/patch-2.6.14
cd $PLACE
mv $PLACE/linux-2.6.13 $PLACE/linux-2.6.14
cd $PLACE/linux-2.6.14
patch -p1 < /hda10/backup.files/patch-2.6.15
cd $PLACE
mv $PLACE/linux-2.6.14 $PLACE/linux-2.6.15
cd $PLACE/linux-2.6.15
patch -p1 < /hda10/backup.files/patch-2.6.16
cd $PLACE
mv $PLACE/linux-2.6.15 $PLACE/linux-2.6.16
cd $PLACE/linux-2.6.16
patch -p1 < /hda10/backup.files/patch-2.6.17
cd $PLACE
patch -p1 < /hda10/backup.files/patch-2.6.17
cd $PLACE
mv $PLACE/linux-2.6.16 $PLACE/linux-2.6.17
cd $PLACE/linux-2.6.17
patch -p1 < /hda10/backup.files/patch-2.6.18
cd $PLACE
mv $PLACE/linux-2.6.17 $PLACE/linux-2.6.18
cd $PLACE/linux-2.6.18
patch -p1 < /hda10/backup.files/patch-2.6.19
cd $PLACE
mv $PLACE/linux-2.6.18 $PLACE/linux-2.6.19
cd $PLACE/linux-2.6.19
patch -p1 < /hda10/backup.files/patch-2.6.20
cd $PLACE
mv $PLACE/linux-2.6.19 $PLACE/linux-2.6.20
cd $PLACE/linux-2.6.20
exit
}}}
That gets the '''2.6.9 source''' from the HDD and patches it for every version up to 2.6.20.

 1.#3 Download the Debian diff.gz file. That is the file that contains all the Debian changes for this kernel package. E.g http://ftp.debian.org/debian/pool/main/l/linux-2.6/linux-2.6_2.6.20-3.diff.gz
 1.#4 Patch the source with that. Cd into the tree of where you put the source, e.g. /home/hugo/linux-2.6.20-3-build/linux-2.6.20. You created linux-2.6.20-3-build and your script put linux-2.6.20 into it, cd into the latter and then:
 1.#5 Now prepare the rules file for the one build you want to make:
Line 87: Line 69:
zcat <path>linux-2.6_2.6.20-3.diff.gz| patch -p1
}}}
Now your tree holds the source and all changes Debian made to it.
 1.#5 '''Make debian/rules executable'''. In your tree there is a directory named '''debian''', in there is a file called '''rules''', that has to be made executable, because it is executed.
 1.#6 '''Change the file debian/bin/abicheck.py'''. After line 18 that contains '''ret = 0''' add a line that says '''return 0'''. This will stop you from doing the abicheck.
 1.#7 Prepare the tree for build. Still in the tree directory where you patched, do:
{{{
fakeroot debian/rules debian/build debian/stamps
fakeroot make -f debian/rules.gen setup-i386-none-k7
fakeroot make -f debian/rules.gen setup_i386_none_k7
Line 99: Line 73:
fakeroot make -f debian/rules.gen setup-i386-none-686 fakeroot make -f debian/rules.gen setup_i386_none_686
Line 102: Line 76:
 1.#8 Change the .config file. Do:  1.#6 Change the .config file. Do:
Line 106: Line 80:
and make any changes you had in mind. E.g the changes mentioned above in '''Reasons for doing this'''. Also this is the time to add additional patches, e.g. the Debian Logo patch.
 1.#9 Compile the kernel and generate the image and headers debs. Do:
and make any changes you had in mind. E.g the changes mentioned above in '''Reasons for doing this'''. An alternative is to run
Line 109: Line 82:
fakeroot make -f debian/rules.gen binary-arch-i386-none-k7 make oldconfig
}}}
which uses the currently running configuration of the machine on which you are building.
Also this is the time to add additional patches, e.g. the Debian Logo patch.
 1.#7 Compile the kernel and generate the image and headers debs. Replace {{{$NR_CPUS}}} with the number of CPUs of the build machine and run:
{{{
fakeroot make -f debian/rules.gen binary-arch_i386_none_k7 DEBIAN_KERNEL_JOBS=${NR_CPUS}
Line 113: Line 92:
fakeroot make -f debian/rules.gen binary-arch-i386-none-686 fakeroot make -f debian/rules.gen binary-arch_i386_none_686 DEBIAN_KERNEL_JOBS=${NR_CPUS}
Line 115: Line 94:
And on a 2.0GHz CPU the compile will take 1 hour and 20 minutes and 2 deb files will be generated: the image file and the headers file, e.g. On a 2.0GHz CPU the compile will take 1 hour and 20 minutes and 2 deb files will be generated: the image file and the headers file, e.g.
Line 120: Line 99:
 1.#10 Install them with dpkg and now you have installed the stock Debian kernel with your changes in it. Congratulations ;-)  1.#8 Install them with dpkg and now you have installed the stock Debian kernel with your changes in it. Congratulations ;-)

This Page is about Rebuilding an official Debian kernel package

There is the Kernel Handbook about this: http://kernel-handbook.alioth.debian.org/

We are following section 4.2: Rebuilding an official Debian kernel package

  • Reasons to do this:
    1. Modifying the Debian configuration to change the preemption model.

    2. Modifying the Debian configuration to change the timer frequency.

    3. Modifying the Debian configuration to change to Pata.

    4. Add an patch fix.
    5. Add your favorite patchset.

What you'll get is exactly the kernel that Debian releases but with those added changes.

Add a Patch to linux-2.6

First get the orig tar ball from buildserver, see [DebianKernel], unpack it:

~/src$ tar xzf linux-2.6_2.6.24~rc6.orig.tar.gz

Get latest Debian patches + config settings:

~/src/linux-2.6-2.6.24-rc6$  svn export svn://svn.debian.org/svn/kernel/dists/trunk/linux-2.6/debian

Now you can start adding patches inside the patches dir. To have them applied don't forget to add them to the series file.

~/src/linux-2.6-2.6.24~rc6$ cp ~/special-fix.patch debian/patches/bugfix/
~/src/linux-2.6-2.6.24~rc6$ echo "+ bugfix/special-fix.patch" \
  >> debian/patches/series/1~experimental.1 

Do not forget to document the new patch in a new stanza at the top of debian/changelog. You will likely want to append some string to the version, using ~ or + to ensure your change does not conflict with existing or future official kernel packages.

Now check that your patchset still applies and fix any conflicts

~/src/linux-2.6-2.6.24~rc6$ make -f debian/rules source-all

Then build with appropriate DEBIAN_KERNEL_JOBS according to the box core cpu number:

~/src/linux-2.6-2.6.24~rc6$ DEBIAN_KERNEL_JOBS=${NR_CPUS} debuild

8 easy (albeit time consuming) steps

Assuming you are just interested in building one flavor of a kernel-image.

  1. Create the directory where you will build the kernel package as a normal user.
  2. Get the package source. For this to work, you need to have deb-src lines for the official archive in /etc/apt/sources.list:

apt-get source linux-2.6

Now your tree holds the source and all changes Debian made to it.

  1. Add your patch into the debian/patches directory, as per the above. It may be a good idea to name the new series accordingly. For instance, when adding the "foo" patch, you might want to add a reference to the patch (see above) to debian/patches/series/1+foo.1, assuming debian/patches/series/1 is the latest file. By abusing the ABI field for this, one guards against possible confusion when such custom kernel packages are installed on otherwise pristine Debian systems.

  2. If you haven't yet, document your change in debian/changelog, e.g. with the dch tool from the devscripts package, and append the same string ("+foo.1") to the package version as you appended to the ABI field.

dch --local +foo.
  1. Now prepare the rules file for the one build you want to make:

fakeroot make -f debian/rules.gen setup_i386_none_k7

This presumes you are only interested in building a k7 AMD processor image! If you where interested in a 686 processor image do:

fakeroot make -f debian/rules.gen setup_i386_none_686

This will build a tree in the debian/build/build-i386-none-k7 or debian/build/build-i386-none-686 directory. Cd to that directory.

  1. Change the .config file. Do:

make menuconfig

and make any changes you had in mind. E.g the changes mentioned above in Reasons for doing this. An alternative is to run

make oldconfig

which uses the currently running configuration of the machine on which you are building. Also this is the time to add additional patches, e.g. the Debian Logo patch.

  1. Compile the kernel and generate the image and headers debs. Replace $NR_CPUS with the number of CPUs of the build machine and run:

fakeroot make -f debian/rules.gen binary-arch_i386_none_k7 DEBIAN_KERNEL_JOBS=${NR_CPUS}

or:

fakeroot make -f debian/rules.gen binary-arch_i386_none_686 DEBIAN_KERNEL_JOBS=${NR_CPUS}

On a 2.0GHz CPU the compile will take 1 hour and 20 minutes and 2 deb files will be generated: the image file and the headers file, e.g.

linux-image-2.6.20-1-k7_2.6.20-3_i386.deb
linux-headers-2.6.20-1-k7_2.6.20-3_i386.deb
  1. Install them with dpkg and now you have installed the stock Debian kernel with your changes in it. Congratulations ;-)