Tuesday, June 30, 2009

How to update the custom compiled kernel to a new release using git

In a previous article I addressed how to compile a kernel for Ubuntu Intrepid using git and in a follow up article I explained how to compile a new release if you already compiled your own custom kernel using git. The upgrade article was written if the kernel upgrade was one where the only ABI number changed was the last one.
In this article I’ll explain how you can update your previously compiled custom kernel to a newer version, if you used git. This article won’t touch an upgrade of kernel 2.6.27 to 2.6.28.

Updates:
Jan 9, 2009: Added git add to the “commit your changes” section.

The base of this article is that you already compiled a your own kernel with git using my previous article.

A lot of the steps are similar to my previous article but there are a few extra steps and liek I mentioned earlier I also explain how to handle the situation where the Ubuntu git repository is already in the next development cycle.

On October 31st, 2008 I have a made a few changes in the article, Compiling a custom kernel for Ubuntu Intrepid using git, to help compiling an upgrade of the kernel a bit easier. If you compiled a kernel prior to this you need to follow the steps in Preparing manual upgrade otherwise you can skip this step and go straight to Upgrading the source. If you read this article to update your kernel again you can also go straight to Upgrading the source.

Preparing manual upgrade

We need to work in our created branch

git checkout core2

We’re going to copy all the files we needed to change, restore the branch to it’s original starting point and copy all of our files back again. To keep remember this state we’ll do a commit.

cp debian/abi/2.6.27-7.13/i386/core2 ..
cp debian/abi/2.6.27-7.13/i386/core2.modules ..
cp debian/scripts/misc/getabis ..
cp debian/rules.d/i386.mk ..
cp debian/control.stub ..
cp debian/control ..
git reset --hard
git git clean -xdf
cp ../core2 debian/abi/2.6.27-7.13/i386/
cp ../core2.modules debian/abi/2.6.27-7.13/i386/
cp ../getabis debian/scripts/misc/
cp ../i386.mk debian/rules.d/
cp ../control.stub debian/
cp ../control debian/
git commit -a -m "Core2 modifications"

Upgrading the source

It’s time to get the new kernel source.
We’re going to update our master branch and use the master branch to update our own core2 branch.

git checkout master
git pull

If you have a problem switching to the master branch and you are stuck in the core2 branch use the following commands

git reset HEAD --hard
git clean -xdf
git checkout master
git pull

We now have the latest kernel source but we don’t want to the updates that are part of the next release.
To check for the latest tagged version the easiest way is to check the debian changelog.

 less debian/changelog

Look for the second section of the changelog

linux (2.6.27-10.21) UNRELEASED; urgency=low

CHANGELOG: Do not edit directly. Autogenerated at release.
CHANGELOG: Use the printchanges target to see the curent changes.
CHANGELOG: Use the insertchanges target to create the final log.

-- Tim Gardner Mon, 24 Nov 2008 10:50:51 -0700

linux (2.6.27-10.20) intrepid-proposed; urgency=low

In this case the latest tagged version is 2.6.27-10.20
Let’s find the git tag name for this version

git tag -l *2.6.27-10.20*

This will result in

Ubuntu-2.6.27-10.20

We want to reset our git repository to this state, as we don’t want the unreleased updates

 git reset Ubuntu-2.6.27-10.20 --hard

To check if the above command really worked

git log

And log should say:

 UBUNTU: Ubuntu-2.6.27-10.20

Now that the master branch is all set we can go into our core branch and get ready for compilation.

git checkout core2
git reset --hard
git clean -xdf
git merge master

Because we added files to the directory

debian/abi/2.6.27-7.16/i386/

we need to move these files ourselves to the new abi directory

mv debian/abi/2.6.27-7.16/i386/core2* debian/abi/2.6.27-8.17/i386
rm -rf debian/abi/2.6.27-7.16

We need to edit the control file debian/control.
In the sections of core2 we created we need to change all the references to -7 to -10. I usually do it using vi, search for -7 and manually replacing it with -10.

Now we need to commit our changes in the git repository

git add.
git commit -a -m "Core2 modifications"

The text after -m is the message you add to your commit.

Compilation

It’s time for compiling.

CONCURRENCY_LEVEL=2 NOEXTRAS=1 skipabi=true skipmodule=true fakeroot debian/rules binary-core2

As we are upgrading to a higher version of the kernel we also need to compile the default linux-headers file

CONCURRENCY_LEVEL=2 NOEXTRAS=1 skipabi=true skipmodule=true fakeroot debian/rules binary-indep

Installation

After the compilation is finished we’ll have two deb files in the parent directory. To install the files

dpkg -i linux-image-2.6.27-10-core2_2.6.27-10.20_i386.deb
dpkg -i linux-headers-2.6.27-10-core2_2.6.27-10.20_i386.deb linux-headers-2.6.27-10_2.6.27-10.20_all.deb

Check your bootloader if the newly installed kernel is the default one, for grub edit the file /boot/grub/menu.lst

Reboot and enjoy your newly installed kernel.

No comments: