I can't find a clean, non-hacky, way to emerge external modules for a 2.6 kernel. Reproducible: Always Steps to Reproduce: I've spent hours now trying to find a way for "emerge lirc" to succeed on a 2.6 kernel. When following the Gentoo install documentation (doing a manual kernel build, not using genkernel), I always end up with a sandbox violation (this is bug#1: the installation documentation is simply broken wrt kernel 2.6) After some looking around, I found documentation that told me I could use "config-kernel --allow-writable=yes" as a hack to work around the sandbox violation. However, config-kernel is masked by package.mask, which states that it is broken (this is bug#2: the documentation refers, in several places, to a package which is broken and due to be removed, according to package.mask). Another way is to use "export KBUILD_OUTPUT=/var/tmp/kernel-output/2.6.9-gentoo-r1", for example, to redirect the kernel output to the given directory. I've tried this, but while "make menuconfig" works, when I do "make" I get: > Using /usr/src/linux-2.6.9-gentoo-r1 as source for kernel > /usr/src/linux-2.6.9-gentoo-r1 is not clean, please run 'make mrproper' > in the '/usr/src/linux-2.6.9-gentoo-r1' directory. > make[1]: *** [prepare1] Error 1 > make: *** [_all] Error 2 So I do "make mrproper" in the given directory and get: > awk: cmd. line:2: fatal: cannot open file `/usr/src/linux-2.6.9-gentoo-r1/include/linux/version.h' for reading (No such file or directory) > CLEAN scripts/basic > CLEAN scripts/kconfig > CLEAN scripts/lxdialog > CLEAN .config Ignoring the error message (hoping it works anyway), I do "make" again and get: > /usr/src/linux-2.6.9-gentoo-r1/Makefile:461: .config: No such file or directory > Using /usr/src/linux-2.6.9-gentoo-r1 as source for kernel > /usr/src/linux-2.6.9-gentoo-r1 is not clean, please run 'make mrproper' > in the '/usr/src/linux-2.6.9-gentoo-r1' directory. > make[1]: *** [prepare1] Error 1 > make: *** [_all] Error 2 That's the same error message as before plus the error that he can't find the ".config" file - shouldn't he be looking for that in "/var/tmp/..." anyway??? Of course, I can install lirc manually (that's what I've been doing for over a year now), but I'd really like to use emerge for that (and other external kernel modules I might want to install in the future). I've also tried to use "genkernel" a few months ago (at my first several-days-long attempt to get this to work), but that didn't work either - can't remember the exact problem though. Anyway, I don't want to use genkernel as I want to use my own kernel config (my machine is old and slow and compiling a kernel with all drivers takes ages) and don't want/need the extra complexity of using an initrd. Help! There's gotta be some way to make external modules work on a gentoo 2.6 kernel, no?
bug#3: setting "KBUILD_OUTPUT" (or "O" on the command line) doesn't work. btw, "make menuconfig" correctly leaves the ".config" file in "/var/tmp/..." when KBUILD_OUTPUT is set accordingly, so he does recognize the variable, it's just that after that the kernel refuses to build at all.
Arrgh! I'm a stupid git, I admit it. The last problem I had (the kernel not compiling at all) was due to the fact that I had accidentally put my old ".config" file into "/usr/src/linux" instead of "/var/tmp/kernel-output/2.6.9-gentoo-r1". Now I've put it in this directory and removed it from "/usr/src/linux" and now it builds. Still don't know if "emerge lirc" will work afterwards though (I will come back here if it doesn't). Anyway, this leaves us with only documentation bugs: - the install documentation should at least mention "KBUILD_OUTPUT" and warn that external modules can't be emerged if that isn't used. - all references to "config-kernel" should be removed from the documentation or at least mention that it is deprecated and can only be merged if putting it in "package.unmask" or removing it from "package.mask"
OK, the kernel compiled and booted fine. However, I still can't emerge lirc. I've tried lirc-0.7.0-pre7 and lirc-0.7.0-pre7-r1. To make sure this is not just a lirc bug, I've tried nvidia-kernel as well, which also failed. I always get this message telling me to use the KBUILD_OUTPUT feature - but I've done that (the output really ended up in "/var/tmp/kernel-output/2.6.9-gentoo-r1") - however the build system doesn't seem to notice that, as the emerge output states that it's using the kernel sources in "/usr/src/linux" which "outputs to /usr/src/linux" (and yes, /usr/src/linux points to /usr/src/linux-2.6.9-gentoo-r1 as it should), which is wrong, it DID output to "/var/tmp/...". Oh yeah, setting the environment variable "KBUILD_OUTPUT" to "/var/tmp/kernel-output/2.6.9-gentoo-r1" before emerging lirc doesn't make a difference. For the record: all this is on a freshly installed stage3 from the Gentoo 2004.3 install CD with the snapshot of the portage tree contained on that CD (i.e. I didn't emerge sync before trying this).
OK, I know, I should always try "emerge sync" _before_ reporting a bug. Hey, I already admitted I'm a stupid git :) So, after doing this it all worked fine, both lirc and nvidia-kernel. All that's left is to update the documentation as mentioned above. Additionally, the docs could mention that some ebuilds in the portage snapshot coming with Gentoo 2004.3 are broken wrt building external modules for a 2.6 kernel and so you should *always* emerge sync before building external modules for a 2.6 kernel after a fresh install. It could also mention that the building of external modules for 2.6 only works if "KBUILD_OUTPUT" is set correctly before calling emerge (i.e. it's not enough to set it before compiling the kernel itself), so putting a corresponding line in root's .profile might be a good idea.
The outdated documents have now been removed. Hopefully we will find time to document the correct usage of KBUILD_OUTPUT in the future.