You are not logged in.

#1 2013-08-28 14:11:10

labotsirc
Member
Registered: 2013-08-21
Posts: 108

[SOLVED] Modify kernel driver "C" file, recompile kernel

Hello,

I am trying to recompile a kernel where i have modified one driver file, but my changes get erased (and back to default) as soon as i start making the package.

I am using archlinux ABS (followed the wiki page https://wiki.archlinux.org/index.php/Ke … ild_System) and downloaded the kernel 3.10.9. The first thing i did was

makepkg -o PKBUILD

So i could get the sources. Next i modified "src/drivers/hid/usbhid/hid-core.c" adding one line to fix something related to my keyboard.
Afterwards i proceed to recompile the kernel

makepkg -s PKBUILD

i see at least two potential problems with what i am doing.

(1) When i see the kernel build output of "makepkg -s PKBUILD" ,i see there is a patch for the file i modified; "src/drivers/hid/usbhid/hid-core.c". Does the patch removes all my manual changes done on the file?
i tried modifying "patch-3.10.9" commenting out the part that patches that file, so it does not get touched by the patch process. But still no luck, maybe because of problem (2)

(2) Each time i run "makepkg PKBUILD" i see that the "*.xy" file gets unpacked, probably overwriting all sources again, loosing the manual change.

In the end, what i am looking for is to have that custom kernel as another option in my grub list.
I am lost at this moment, any help is welcome.

Last edited by labotsirc (2013-08-28 15:36:16)

Offline

#2 2013-08-28 14:17:39

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Modify kernel driver "C" file, recompile kernel

Read the man page for makepkg.


The correct link to the wiki is https://wiki.archlinux.org/index.php/Ke … ild_System (the closing parenthesis broke it)

Last edited by karol (2013-08-28 14:19:14)

Offline

#3 2013-08-28 14:20:56

labotsirc
Member
Registered: 2013-08-21
Posts: 108

Re: [SOLVED] Modify kernel driver "C" file, recompile kernel

karol wrote:

Read the man page for makepkg.


The correct link to the wiki is https://wiki.archlinux.org/index.php/Ke … ild_System (the closing parenthesis broke it)

fixed link.

edit:

mmm maybe this should do:
from "man makepkg":

-e, --noextract
           Do not extract source files or run the prepare() function (if present); use whatever source already exists in the $srcdir/ directory. This is handy if you want to go into $srcdir/ and manually
           patch or tweak code, then make a package out of the result. Keep in mind that creating a patch may be a better solution to allow others to use your PKGBUILD.

I will try and post back. Thanks

Last edited by labotsirc (2013-08-28 14:24:35)

Offline

#4 2013-08-28 14:27:38

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,606
Website

Re: [SOLVED] Modify kernel driver "C" file, recompile kernel

If the change(s) are simple modifications (e.g. adding/changing a word on a line) you can add a sed command to the prepare() function in the PKGBUILD. This will then be executed for you when you run makepkg, making your changes before the build stage.

If the changes are more complex, consider creating a patch that you can apply during the prepare stage. https://wiki.archlinux.org/index.php/Patching_in_ABS

edit: I hadn't considered makepkg -e, that should work in this case.

Last edited by WorMzy (2013-08-28 14:29:58)


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2013-08-28 14:47:49

labotsirc
Member
Registered: 2013-08-21
Posts: 108

Re: [SOLVED] Modify kernel driver "C" file, recompile kernel

WorMzy wrote:

If the change(s) are simple modifications (e.g. adding/changing a word on a line) you can add a sed command to the prepare() function in the PKGBUILD. This will then be executed for you when you run makepkg, making your changes before the build stage.

If the changes are more complex, consider creating a patch that you can apply during the prepare stage. https://wiki.archlinux.org/index.php/Patching_in_ABS

edit: I hadn't considered makepkg -e, that should work in this case.

Actually it is just one line. If i add the sed command as you suggest, will i be able to skip the "makepkg -o PKGBUILD" source downloading part?

Offline

#6 2013-08-28 14:54:09

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,606
Website

Re: [SOLVED] Modify kernel driver "C" file, recompile kernel

Yes, it will be applied to the "fresh" source that makepkg extracts from the tarball, everytime you run "makepkg". Take a look at the linux package's PKGBUILD for an example of a prepare function.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#7 2013-08-28 15:35:18

labotsirc
Member
Registered: 2013-08-21
Posts: 108

Re: [SOLVED] Modify kernel driver "C" file, recompile kernel

Thanks Karol and WorMzy, adding the sed command in "prepare" did the job.

Offline

Board footer

Powered by FluxBB