adding new driver to kernel src and building rpm

Sérgio Basto sergio at serjux.com
Thu Jan 29 20:21:57 UTC 2015


On Dom, 2015-01-25 at 18:43 +0100, Reindl Harald wrote:
> Am 25.01.2015 um 18:37 schrieb Amadeus W.M.:
> > On Sun, 25 Jan 2015 17:26:55 +0100, poma wrote:
> >> On 25.01.2015 07:50, Amadeus W.M. wrote:
> >>> I'm trying to do the following:
> >>>
> >>> 1) add the smi2021 driver for EasyCap Somagic usb frame grabbers into the
> >>> kernel tree
> >>> 2) compile the kernel with smi2021 as a module
> >>> 3) build the rpm.
> >>
> >> Why build the whole kernel for one module!?
> >
> > I would certainly build just the smi2021 driver if I knew how to, but
> > I followed the only instructions I could find for Fedora:
> >
> > https://fedoraproject.org/wiki/Building_a_custom_kernel
> 
> you do not need a Fedora specific page for everything
> 
> > How would I go about compiling just the module? The kernel source would have
> > to be patched, no?
> 
> no - that's why the packages "kernel-devel" and "kernel-headers" exists 
> to built modules against it - did that years ago for vmware PV drivers
> 
> https://www.google.at/#q=build+a+kernel+module

You could also build a kernel using mock and fedpkg . 
Note: this memo doesn't cover modifying .config and enable kernel
modules but hope that can help in some way. 

(as root) 
yum install mock fedpkg

Note: 
To use mock, a user should become a member of the mock group by adding
their username to 
the mock line in /etc/group. This can be done with the following
command:

sudo /usr/sbin/usermod -a -G mock $USER

Note that mock is not intended to be run directly as root.
Beware that adding a user to the mock group means that the user can
easily get root access 
on the machine without providing a password.

More info:
http://fedoraproject.org/wiki/Projects/Mock 

(as normal user)
cd ~/fedora-scm/
fedpkg clone kernel -a
cd kernel/
fedpkg switch-branch f20;
fedpkg srpm (this create src.rpm but also download also sources)
vi flooding.patch 
cat kernel_spec.patch | patch SPECS/kernel.spec
vi kernel.spec 
rpmbuild -bs kernel.spec  --define "_sourcedir ." --define
'_srcrpmdir .'  && mock -r fedora-20-x86_64
--rebuild ./kernel-3.15.8-200.fc20.src.rpm --target=x86_64
--define="buildid .sb" --with baseonly --without debuginfo --no-clean 

ll /var/lib/mock/fedora-20-x86_64/result/

(as root install it)
(you need have in /etc/mock/site-defaults.cfg , is not default
 config_opts['createrepo_on_rpms'] = True )

yum --tmprepo=/var/lib/mock/fedora-20-x86_64/result/repodata/repomd.xml
--nogpg update --skip-broken



-- 
Sérgio M. B.



More information about the devel mailing list