Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Kernel compilate as user & out of tree
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
big_gie
Apprentice
Apprentice


Joined: 31 Aug 2004
Posts: 154

PostPosted: Fri Jun 22, 2012 10:44 pm    Post subject: Kernel compilate as user & out of tree Reply with quote

Hi all,

I'm writing a script to compile the kernel as a normal user (not as root) but I'm facing some issues.

The problem is that I can't find a way to both let the user build without touching /usr/src/linux-[version] AND allow emerge nvidia-drivers. Is it possible?

I'm exporting KBUILD_OUTPUT to the user owned directory, INSTALL_PATH to $KBUILD_OUTPUT/install/.../boot and INSTALL_MOD_PATH similarly.
I then copy a .config to KBUILD_OUTPUT, cd /usr/src/linux, run "make menuconfig", "make prepare", "make modules", "make modules_install" and finally "make install".
This works as expected. The user (or script) can copy the built files to where they should.

The problem comes when an out of tree driver is emerged. For example, x11-drivers/nvidia-drivers complains:
Code:

 * devdriver_5.0_linux_64_302.06.03.run RMD160 SHA1 SHA256 size ;-) ...                     [ ok ]
 * checking ebuild checksums ;-) ...                                                        [ ok ]
 * checking auxfile checksums ;-) ...                                                       [ ok ]
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux
 * Found sources for kernel version:
 *     3.3.8-gentoo
 * Could not find a usable .config in the kernel source directory.
 * Please ensure that /usr/src/linux points to a configured set of Linux sources.
 * If you are using KBUILD_OUTPUT, please set the environment var so that
 * it points to the necessary object directory so that it might find .config.
 * ERROR: x11-drivers/nvidia-drivers-302.06.03 failed (setup phase):
 *   Kernel not configured; no .config found in /usr/src/linux

Ok, copying the config is not too bad, but still fails:
Code:

 * devdriver_5.0_linux_64_302.06.03.run RMD160 SHA1 SHA256 size ;-) ...                     [ ok ]
 * checking ebuild checksums ;-) ...                                                        [ ok ]
 * checking auxfile checksums ;-) ...                                                       [ ok ]
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux
 * Found sources for kernel version:
 *     3.3.8-gentoo
 * These sources have not yet been prepared.
 * We cannot build against an unprepared tree.
 * To resolve this, please type the following:
 *
 * # cd /usr/src/linux
 * # make oldconfig
 * # make modules_prepare
 *
 * Then please try merging this module again.
 * ERROR: x11-drivers/nvidia-drivers-302.06.03 failed (setup phase):
 *   Kernel sources need compiling first

I thus have to run "make oldconfig && make modules_prepare" in /usr/src/linux. I can then emerge x11-drivers/nvidia-drivers fine.

BUT, this breaks the possibility for the user to build. "make menuconfig" runs fine, but "make prepare" fails:
Code:

$ make prepare V=1
make -C /home/nicolas/build/kernel/3.3.8-gentoo \
KBUILD_SRC=/usr/src/linux-3.3.8-gentoo \
KBUILD_EXTMOD="" -f /usr/src/linux-3.3.8-gentoo/Makefile \
prepare
make -f /usr/src/linux-3.3.8-gentoo/scripts/Makefile.build obj=arch/x86/syscalls all
make[2]: Nothing to be done for `all'.
make -f /usr/src/linux-3.3.8-gentoo/scripts/Makefile.build obj=arch/x86/tools relocs
make[2]: Nothing to be done for `relocs'.
rm -f include/config/kernel.release
echo "3.3.8-gentoo$(/bin/sh /usr/src/linux-3.3.8-gentoo/scripts/setlocalversion /usr/src/linux-3.3.8-gentoo)" > include/config/kernel.release
if [ -f /usr/src/linux-3.3.8-gentoo/.config -o -d /usr/src/linux-3.3.8-gentoo/include/config ]; then \
        echo "  /usr/src/linux-3.3.8-gentoo is not clean, please run 'make mrproper'";\
        echo "  in the '/usr/src/linux-3.3.8-gentoo' directory.";\
        /bin/false; \
fi;
  /usr/src/linux-3.3.8-gentoo is not clean, please run 'make mrproper'
  in the '/usr/src/linux-3.3.8-gentoo' directory.


There seems to be a check on /usr/src/linux/.config and /usr/src/linux/include/config in the Makefile ("prepare3" target).


OR, I could use KBUILD_OUTPUT to the user folder when emerging x11-drivers/nvidia-drivers. But I want x11-drivers/nvidia-drivers to be emerged in the user system (emerge will be run as root!), not KBUILD_OUTPUT.

Anyone has an idea how I can reconcile both compiling as users and emerge an out of tree drivers?

Thanks!
Back to top
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 7610

PostPosted: Fri Jun 22, 2012 10:56 pm    Post subject: Reply with quote

I think your options are to stop using out-of-tree drivers, stop building out-of-tree, or point $KBUILD_OUTPUT to the build tree. If the user has not set restrictive directory permissions, this last option should work fine. The build tree does not need to be owned by the user which builds the out-of-tree driver.
Back to top
View user's profile Send private message
Apheus
Apprentice
Apprentice


Joined: 12 Jul 2008
Posts: 182

PostPosted: Mon Jun 25, 2012 9:20 am    Post subject: Reply with quote

You may also need the variable KERNEL_DIR, set it to the same value as $KBUILD_OUTPUT. See here:

http://forums.gentoo.org/viewtopic-t-859409.html
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum