You are not logged in.

#1 2007-12-23 17:35:43

Reasons
Member
From: Washington
Registered: 2007-11-04
Posts: 572

Help patching a kernel

I've read the three wikis:
http://wiki.archlinux.org/index.php/Ker … _Patchsets
http://wiki.archlinux.org/index.php/Cus … n_with_ABS
http://wiki.archlinux.org/index.php/Ker … n_with_ABS

and am still pretty lost as to what I have to do or which way is best. At the moment, I'm looking at the fallen patchset because of gensplash and suspend2. I'm just not sure where to start and if I could save my old kernel just in case I decide to go back.

Offline

#2 2007-12-23 18:50:54

kishd
Member
Registered: 2006-06-14
Posts: 401

Re: Help patching a kernel

You could use the PKGBUILD for the standard kernel26 and edit it to include the patches that you want and remove those that you don't want.

In this thread http://bbs.archlinux.org/viewtopic.php?id=34815 there is a nice script by kano to rename the kernel and all the necessary file so that you could install your custom kernel without losing the original arch kernel.


---for there is nothing either good or bad, but only thinking makes it so....
Hamlet, W Shakespeare

Offline

#3 2007-12-23 19:12:45

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Help patching a kernel

kishd wrote:

You could use the PKGBUILD for the standard kernel26 and edit it to include the patches that you want and remove those that you don't want.

In this thread http://bbs.archlinux.org/viewtopic.php?id=34815 there is a nice script by kano to rename the kernel and all the necessary file so that you could install your custom kernel without losing the original arch kernel.

Just one thing about this script - in the latest versions of the kernel26 PKGBUILD it changes some lines in the source array it shouldn't change ("ftp://ftp.archlinux.org/other/kernel26/sched-cfs-v2.6.23.11-v24.patch" specifically, I think) by replacing kernel26 with kernel26-[yourname] in the path, so make sure to revert that change manually - otherwise the PKGBUILD will fail.

I agree with kishd that this is probably the most efficient way of building your own kernel.  It'll rename the kernel for you and add make menuconfig line so you can customize the configuration as well.

Offline

#4 2007-12-23 20:00:42

Reasons
Member
From: Washington
Registered: 2007-11-04
Posts: 572

Re: Help patching a kernel

Where is kernel26? All I could find was linux-2.6.23-ARCH in /usr/src.

But basically, once I find it, I put the script where I have all my kernels and run it. But where do I put the patches? Same place as the script?

Offline

#5 2007-12-23 20:07:08

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Help patching a kernel

you have to use abs to get the pkgbuild... well, you don't have to but that's the most efficient way.  look up the wiki on abs.  once you get the whole abs tree synchronized you can copy the kernel26 dir to you home directory, for example, run kano's script, change whatever needs to be changed in the PKGBUILD and build your new kernel with makepkg.

Offline

#6 2007-12-23 20:31:16

Reasons
Member
From: Washington
Registered: 2007-11-04
Posts: 572

Re: Help patching a kernel

Right, but there is no kernel26 anywhere that I can find. Which makes me sound like an idiot. Is /var/abs/unstable/kernels/kernel26mm the same thing? Then on the script, on what part do I change to make it use the patches?

Offline

#7 2007-12-23 20:48:02

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Help patching a kernel

Should be in /var/abs/core/base/kernel26

The script is not going to change the patches for you - it only renames the package to what you specify in the script (you have to edit it first) and adds make menuconfig to the PKGBUILD.  You'll have to add the patches by manually editing the PKGBUILD, it should be fairly intuitive.

Last edited by fwojciec (2007-12-23 20:50:23)

Offline

#8 2007-12-23 21:07:41

Reasons
Member
From: Washington
Registered: 2007-11-04
Posts: 572

Re: Help patching a kernel

Okay, first I'd like to say thanks for getting me this far. I created a directory called source in my home folder and copied kernel 28 there as well as putting the script there (just called it builder.sh, or should it be something else?) and then put the patch I'm using, too, in the sources folder.

However, if I read right, shouldn't the patch go into the kernel26 folder along with the script? Then I edit the PKGBUILD in the kernel26 folder to add the patch?

Offline

#9 2007-12-23 22:24:59

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Help patching a kernel

the script should be in the directory where you have the the kernel26 directory (and the directory which contains the kernel PKGBUILD + stuff must be called kernel26).  so in your case the script should go into the ~/source.  same thing for the whole kernel26 directory (so cp -r /var/abs/core/base/kernel26 ~/source).  make sure to edit the script before running it (you have to specify how you want your custom kernel package to be called by defining one of the variables).  then run the script from ~/source - this will create a new folder called kernel26-[your custom name]

then the real fun begins...

you will need to edit the PKGBUILD file to add information about the patch you want to add (look at how other patches in the PKGBUILD are defined and add yours analogously).  you'll need to add the patch source to the source array, add the command to actually patch the source and add the md5sum as well (or you can remove the md5sums altogether - makepkg will complain but will not fail).  once you're done editing the PKGBUILD just run "makepkg" command from ~/source/kernel26-[custom name] and it should build arch package for you with your custom kernel.  then you can just install this package with pacman -U, edit /boot/grub/menu.lst to create a new entry for your custom kernel and you're done.

it sounds like a complicated process, but really it's quite easy once you understand how it works.  the critical thing is to understand how the PKGBUILD file works, you don't have to know everything, just enough to be able to make the changes you need.

Offline

#10 2007-12-23 22:51:49

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Help patching a kernel

One more thing, it might be useful.  The build process will probably fail for you at some stage before you figure out exactly how it's supposed to be done - if it does make sure to remove the src dir from the build directory before rerunning makepkg.  On each run makepkg will try to patch the kernel source and if the files in src are already patched it will fail.  I remember it took me a while to figure this out when I was trying to compile my first kernel.

Offline

#11 2007-12-23 23:21:38

Reasons
Member
From: Washington
Registered: 2007-11-04
Posts: 572

Re: Help patching a kernel

Okay, when I ran the script I got

cp: cannot stat `kernel26/*': No such file or directory
Editing PKGBUILD
cat: kernel26/PKGBUILD: No such file or directory
Editing kernel26.preset
cat: kernel26/kernel26.preset: No such file or directory
Regenerating md5sum for kernel26.preset
md5sum: kernel26/kernel26.preset: No such file or directory
Editing kernel26.install
cat: kernel26/kernel26.install: No such file or directory
Regenerating md5sum for kernel26.install
md5sum: kernel26/kernel26.install: No such file or directory
Editing config
cat: kernel26/config: No such file or directory
Regenerating md5sum for config
md5sum: kernel26/config: No such file or directory
Editing config.x86_64
cat: kernel26/config.x86_64: No such file or directory
Regenerating md5sum for config.x86_64
md5sum: kernel26/config.x86_64: No such file or directory
mv: cannot stat `kernel26-fallen/mkinitcpio-kernel26.conf': No such file or directory
Custom kernel pkgbuild created.

But it created a kernel26-fallen in my home directory with the contents:
config
config.x86_64
kernel26-fallen.install
kernel26-fallen.preset
PKGBUILD

EDIT - and as far as patching goes, I should only need fallen-patchset-2.6.21-fallen6.bz2 from here right?

http://www.fallendusk.org/linux_patches/fallen/2.6.21/

Last edited by Reasons (2007-12-23 23:28:37)

Offline

#12 2007-12-24 00:08:55

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Help patching a kernel

Fallen's patchset almost certainly will not work with the current kernel.  Patches are kernel version specific, fallen's patchset is for kernel 2.6.21.  You have to look for individual patches that can be applied to the current kernel.

The script failed because it was not executed from the correct directory.  It looks for directory kernel26 in the same directory in which it was run.  The error messages you got say pretty much the same thing.

Offline

#13 2007-12-24 03:57:29

kishd
Member
Registered: 2006-06-14
Posts: 401

Re: Help patching a kernel

Reasons wrote:

Okay, when I ran the script I got cp: cannot stat `kernel26/*': No such file or directory
/

Create a directory say kernel_build and place the script in that directory. In the kernel_build directory create a directory kernel26 and place all the PKGBUILD files etc in there. Run the script from the parent diretory (kernel_build). It should work.


---for there is nothing either good or bad, but only thinking makes it so....
Hamlet, W Shakespeare

Offline

#14 2007-12-24 18:47:56

Reasons
Member
From: Washington
Registered: 2007-11-04
Posts: 572

Re: Help patching a kernel

Thanks once again, I've gotten to the part about messing the the PKGBUILD. I just commented out the md5sums and then added the line

  #BOOTSPLASH
  patch -Np1 -i ../bootsplash.patch || return 1

where I saw all the others but before it gets that far I get

No such directory `other/kernel26-splash'.

==> ERROR: Failure while downloading sched-cfs-v2.6.23.11-v24.patch
==> Aborting...

which I guess means the new kernel I'm building should be in something like ~/kernel_build/other/kernel26-splash?

Offline

#15 2007-12-24 18:55:09

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Help patching a kernel

check out my first post in this thread - that's what I was warning you about.  That's a glitch in the script.  Just fix the line with sched-cfs-v2.6.23.11-v24.patch in the sources array, change kernel26-[your custom name] to "kernel26" - it should read "ftp://ftp.archlinux.org/other/kernel26/ … -v24.patch"

Edit:  By the way - you should add "bootsplash.patch" to sources as well.  You don't need to give the html/ftp address of the download, just the filename is OK as long as the file is in the same directory as the PKGBUILD.

Last edited by fwojciec (2007-12-24 18:57:31)

Offline

#16 2007-12-24 19:14:40

Reasons
Member
From: Washington
Registered: 2007-11-04
Posts: 572

Re: Help patching a kernel

Sorry for the stupid mistake and for one (hopefully) last question. Torwards the end I get

patching file drivers/char/keyboard.c
Hunk #1 succeeded at 1144 with fuzz 1 (offset -20 lines).
patching file drivers/char/n_tty.c
Hunk #1 succeeded at 1307 (offset 11 lines).
patching file drivers/char/vt.c
Hunk #1 succeeded at 3970 (offset 155 lines).
patching file drivers/video/bootsplash/bootsplash.c
patching file drivers/video/bootsplash/bootsplash.h
patching file drivers/video/bootsplash/decode-jpg.c
patching file drivers/video/bootsplash/decode-jpg.h
patching file drivers/video/bootsplash/Kconfig
patching file drivers/video/bootsplash/Makefile
patching file drivers/video/bootsplash/render.c
patching file drivers/video/console/bitblit.c
patching file drivers/video/console/fbcon.c
Hunk #1 succeeded at 92 (offset 1 line).
Hunk #2 succeeded at 108 with fuzz 2.
Hunk #3 succeeded at 587 (offset 21 lines).
Hunk #4 succeeded at 1172 (offset 40 lines).
Hunk #5 succeeded at 1855 with fuzz 1 (offset 68 lines).
Hunk #6 succeeded at 1920 (offset 45 lines).
Hunk #7 succeeded at 2097 (offset 74 lines).
Hunk #8 succeeded at 2184 (offset 45 lines).
Hunk #9 succeeded at 2346 (offset 74 lines).
Hunk #10 succeeded at 2521 (offset 45 lines).
patching file drivers/video/console/fbcon.h
patching file drivers/video/Kconfig
Hunk #1 succeeded at 1868 (offset 205 lines).
patching file drivers/video/Makefile
Hunk #1 FAILED at 13.
1 out of 1 hunk FAILED -- saving rejects to file drivers/video/Makefile.rej
patching file drivers/video/vesafb.c
patching file include/linux/console_struct.h
Hunk #1 succeeded at 105 (offset 6 lines).
patching file include/linux/fb.h
Hunk #1 succeeded at 833 (offset 38 lines).
==> ERROR: Build Failed.  Aborting...

How do I teel what hunk #1 is?

Offline

#17 2007-12-24 19:19:05

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Help patching a kernel

That means that one of the patches you wanted to apply doesn't apply to the current version of kernel sources.  Are you sure that the bootsplash patch you're trying to use is for 2.6.23 kernel version?

Why do you need bootsplash anyways?  Have tried using splashy (http://wiki.archlinux.org/index.php/Splashy) I've never tried using any of these bootsplash solutions, but I think the major advantage of splashy is that you don't have to recompile the kernel to use it.

Offline

#18 2007-12-24 19:22:30

Reasons
Member
From: Washington
Registered: 2007-11-04
Posts: 572

Re: Help patching a kernel

It's not a need but just a want. But when I used splashy on Ubuntu it'd take up my entire CPU until I did something else. I guess I'll give it a try on arch.

Offline

#19 2007-12-24 19:33:15

Reasons
Member
From: Washington
Registered: 2007-11-04
Posts: 572

Re: Help patching a kernel

Well splashy worked just fine, I guess. The few lines of text at the beginning are a bit annoying but it's just two seconds.

Offline

Board footer

Powered by FluxBB