PDA

View Full Version : How to add executable files to kernel package?


petersenna
27th June 2011, 04:54 PM
Dear forum members,

I'm having some fun playing with building and using custom Kernel for Fedora 15. I can successfully download and build custom kernels following the instructions at:

http://fedoraproject.org/wiki/Docs/CustomKernel

But I want to add two executable files on /usr/bin that are related to kernel modifications I made.

How can I add source files to the BUILD tree, compile it, and have the executable files added to custom kernel RPM package I generate when:

# rpmbuild -bb --with baseonly --without debuginfo --target=`uname -m` kernel.spec

Thanks!

jvillain
30th June 2011, 11:56 PM
That comes off as a really strange post. If you are a good enough developer to be hacking the kernel you wouldn't need to ask the question. If you need to ask the question you can't bee good enough to be hacking the kernel. Maybe if you gave some more info on what the application does it could help.

The best way to communicate with the kernel is to write a driver to allow you to do it. The O'Rielly device drivers book shows you how to write a bare bones driver in 10 lines of code. You just do an insmod to load it then. Then it shows up as a node in the /sys tree that you can read. To read and write takes more work but the book can help you out.

Have a look at chapter 2 over here.

http://lwn.net/Kernel/LDD3/

petersenna
1st July 2011, 01:53 AM

Hi jvillain,

Thanks for the reply.

My question is about Makefiles and RPM spec file. It is not related to Kernel development...

I want to follow the instructions:

http://fedoraproject.org/wiki/Docs/CustomKernel

But I want to add two user land application that will be installed by the resulting kernel-*.rpm package.

I can compile my aplications by hand. And I'm quite sure that I can do another RPM package just for my two binary files, but I need some help on doing it on existing RPM.

Thanks,

Peter

petersenna
1st July 2011, 02:55 PM
I'm not happy with english skills, so I'll try to give an example of what I want to achieve.

When I install the Kernel source RPM the files are placed at:

/home/peter/rpmbuild/BUILD/kernel-2.6.38.fc15/linux-2.6.38.x86_64

I'll make an folder inside that directory:

/home/peter/rpmbuild/BUILD/kernel-2.6.38.fc15/linux-2.6.38.x86_64/user_land_apps

Then I'll place two source code there:

userland1.c
userland2.c

I want to know how to tell rpmbuild to compile those sources, put the resulting binary inside the Kernel RPM in a way that the binaries will be installed in /usr/bin.

Thanks again!

jvillain
4th July 2011, 04:01 PM
OK. That makes more sense. You should start with reading the Maximum RPM site. You can do almost any thing via the spec file. I would consider adding to your files to a separate source RPM then you can upgrade the kernel and just run rpmrebuild on your source RPM with out having to endlessly repackage.

http://rpm.org/max-rpm-snapshot/