Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 321047 - linux-info.eclass bug if two kernels differ only by KV_LOCAL
Summary: linux-info.eclass bug if two kernels differ only by KV_LOCAL
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-22 14:09 UTC by Alessandro Guido
Modified: 2021-08-26 22:18 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alessandro Guido 2010-05-22 14:09:58 UTC
If two installed kernels differ only by KV_LOCAL and KBUILD_OUTPUT is not specified, the OUTPUT_DIR is set wrongly at line

530     OUTPUT_DIR="${OUTPUT_DIR:-/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build}"
531 
532     [ -h "${OUTPUT_DIR}" ] && KV_OUT_DIR="$(readlink -f ${OUTPUT_DIR})"
533     [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}"
534     if [ -n "${KV_OUT_DIR}" ];
535     then
536         qeinfo "Found kernel object directory:"
537         qeinfo "    ${KV_OUT_DIR}"
...

I suggest using "make kernelrelease" in $KV_DIR to get the right version, and use /lib/modules/$kernelrelease/build for KV_OUT_DIR if KBUILD_OUTPUT is not specified.

Reproducible: Always

Steps to Reproduce:




$ ls -d /usr/src/linux-*
/usr/src/linux-2.6.34  /usr/src/linux-2.6.34-7097-gf4b87de

$ cd /usr/src/linux-2.6.34 && head -n 4 Makefile && make kernelversion && make kernelrelease
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 34
EXTRAVERSION =
2.6.34
2.6.34


$ cd /usr/src/linux-2.6.34-7097-gf4b87de && head -n 4 Makefile && make kernelversion && make kernelrelease
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 34
EXTRAVERSION =
2.6.34
2.6.34-7097-gf4b87de
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2010-08-07 17:43:58 UTC
Please sync and retest as we have changed that logic.
Comment 2 Alessandro Guido 2010-08-07 22:02:25 UTC
~> cd /lib/modules/

/lib/modules> ls
2.6.35  2.6.35-4807-g4a386c3

/lib/modules> cd /usr/src/

/usr/src> ls
linux-2.6.35  linux-2.6.35-4807-g4a386c3

/usr/src> cd linux-2.6.35

/usr/src/linux-2.6.35> make kernelrelease
2.6.35

/usr/src/linux-2.6.35> cd ..

/usr/src> cd linux-2.6.35-4807-g4a386c3/

/usr/src/linux-2.6.35-4807-g4a386c3> make kernelrelease
2.6.35-4807-g4a386c3

/usr/src/linux-2.6.35-4807-g4a386c3> cat localversion 
-4807-g4a386c3

/usr/src/linux-2.6.35-4807-g4a386c3> KERNEL_DIR=`pwd` emerge -1 nvidia-drivers
Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-256.35
 * NVIDIA-Linux-x86-256.35.run RMD160 SHA1 SHA256 size ;-) ...                                                                                                                 [ ok ]
 * checking ebuild checksums ;-) ...                                                                                                                                           [ ok ]
 * checking auxfile checksums ;-) ...                                                                                                                                          [ ok ]
 * checking miscfile checksums ;-) ...                                                                                                                                         [ ok ]
 * CPV:  x11-drivers/nvidia-drivers-256.35
 * REPO: gentoo
 * USE:  elibc_glibc kernel_linux userland_GNU x86
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux-2.6.35-4807-g4a386c3
 * Found kernel object directory:
 *     /lib/modules/2.6.35/build
 * Found sources for kernel version:
 *     2.6.35
 * Checking for MTRR support ...                                                                                                                                                [ ok ]
>>> Unpacking source...
>>> Unpacking NVIDIA-Linux-x86-256.35.run to /var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work
^C

Exiting on signal 2



/usr/src/linux-2.6.35-4807-g4a386c3> KBUILD_OUTPUT=/lib/modules/2.6.35-4807-g4a386c3 emerge -1 nvidia-drivers
Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-256.35
 * NVIDIA-Linux-x86-256.35.run RMD160 SHA1 SHA256 size ;-) ...                                                                                                                 [ ok ]
 * checking ebuild checksums ;-) ...                                                                                                                                           [ ok ]
 * checking auxfile checksums ;-) ...                                                                                                                                          [ ok ]
 * checking miscfile checksums ;-) ...                                                                                                                                         [ ok ]
 * CPV:  x11-drivers/nvidia-drivers-256.35
 * REPO: gentoo
 * USE:  elibc_glibc kernel_linux userland_GNU x86
 * Determining the location of the kernel source code
 * Unable to find kernel sources at /usr/src/linux
 * Please make sure that /usr/src/linux points at your running kernel, 
 * (or the kernel you wish to build against).
 * Alternatively, set the KERNEL_DIR environment variable to the kernel sources location
 * Unable to calculate Linux Kernel version for build, attempting to use running version
 * Found kernel object directory:
 *     /usr/src/linux-2.6.35
 * Found sources for kernel version:
 *     2.6.35
 * Checking for MTRR support ...                                                                                                                                                [ ok ]
>>> Unpacking source...
>>> Unpacking NVIDIA-Linux-x86-256.35.run to /var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work
^C

Exiting on signal 2



/usr/src/linux-2.6.35-4807-g4a386c3> KERNEL_DIR=`pwd` KBUILD_OUTPUT=/lib/modules/2.6.35-4807-g4a386c3 emerge -1 nvidia-drivers
Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-256.35
 * NVIDIA-Linux-x86-256.35.run RMD160 SHA1 SHA256 size ;-) ...                                                                                                                 [ ok ]
 * checking ebuild checksums ;-) ...                                                                                                                                           [ ok ]
 * checking auxfile checksums ;-) ...                                                                                                                                          [ ok ]
 * checking miscfile checksums ;-) ...                                                                                                                                         [ ok ]
 * CPV:  x11-drivers/nvidia-drivers-256.35
 * REPO: gentoo
 * USE:  elibc_glibc kernel_linux userland_GNU x86
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux-2.6.35-4807-g4a386c3
 * Found kernel object directory:
 *     /lib/modules/2.6.35-4807-g4a386c3
 * Found sources for kernel version:
 *     2.6.35
 * Could not find a usable .config in the kernel source directory.
 * Please ensure that /usr/src/linux-2.6.35-4807-g4a386c3 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-256.35 failed:
 *   Kernel not configured; no .config found in /lib/modules/2.6.35-4807-g4a386c3
 * 
 * Call stack:
 *                      ebuild.sh, line  48:  Called pkg_setup
 *   nvidia-drivers-256.35.ebuild, line 187:  Called linux-mod_pkg_setup
 *               linux-mod.eclass, line 586:  Called require_configured_kernel
 *              linux-info.eclass, line 275:  Called die
 * The specific snippet of code:
 *   		die "Kernel not configured; no .config found in ${KV_OUT_DIR}"
 * 
 * If you need support, post the output of 'emerge --info =x11-drivers/nvidia-drivers-256.35',
 * the complete build log and the output of 'emerge -pqv =x11-drivers/nvidia-drivers-256.35'.
 * The complete build log is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-256.35/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-256.35/temp/die.env'.
 * S: '/var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work/'

>>> Failed to emerge x11-drivers/nvidia-drivers-256.35

 * Messages for package x11-drivers/nvidia-drivers-256.35:

 * Unable to find kernel sources at /usr/src/linux
 * Unable to calculate Linux Kernel version for build, attempting to use running version

 * Messages for package x11-drivers/nvidia-drivers-256.35:

 * Could not find a usable .config in the kernel source directory.
 * Please ensure that /usr/src/linux-2.6.35-4807-g4a386c3 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-256.35 failed:
 *   Kernel not configured; no .config found in /lib/modules/2.6.35-4807-g4a386c3
 * 
 * Call stack:
 *                      ebuild.sh, line  48:  Called pkg_setup
 *   nvidia-drivers-256.35.ebuild, line 187:  Called linux-mod_pkg_setup
 *               linux-mod.eclass, line 586:  Called require_configured_kernel
 *              linux-info.eclass, line 275:  Called die
 * The specific snippet of code:
 *   		die "Kernel not configured; no .config found in ${KV_OUT_DIR}"
 * 
 * If you need support, post the output of 'emerge --info =x11-drivers/nvidia-drivers-256.35',
 * the complete build log and the output of 'emerge -pqv =x11-drivers/nvidia-drivers-256.35'.
 * The complete build log is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-256.35/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-256.35/temp/die.env'.
 * S: '/var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work/'
 * 
 * The following package has failed to build or install:
 * 
 *  ('ebuild', '/', 'x11-drivers/nvidia-drivers-256.35', 'merge')
 * 
/usr/src/linux-2.6.35-4807-g4a386c3> 
Comment 3 Alessandro Guido 2010-08-07 22:05:49 UTC
I should add this:

/usr/src> ls -l */.config
-rw-r--r-- 1 iro iro 54728 Aug  7 14:00 linux-2.6.35-4807-g4a386c3/.config
-rw-r--r-- 1 iro iro 49447 Aug  2 10:43 linux-2.6.35/.config
Comment 4 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2010-08-08 00:33:10 UTC
Please include this output as well:
(assuming /usr/src/linux is a symlink)
# cd /usr/src
# ln -s linux-2.6.34-7097-gf4b87de linux
# emerge -1v nvidia-drivers
Comment 5 Alessandro Guido 2010-08-08 12:55:51 UTC
(In reply to comment #4)
> Please include this output as well:
> (assuming /usr/src/linux is a symlink)
> # cd /usr/src
> # ln -s linux-2.6.34-7097-gf4b87de linux
> # emerge -1v nvidia-drivers
> 

I didn't have any /usr/src/linux link, I let the eclass guess from the currently running kernel or I specify it using KERNEL_DIR if I need to use a different one.

This is the output:

~> uname -r
2.6.35

~> cd /usr/src/

/usr/src> ln -s linux-2.6.35-4807-g4a386c3 linux

/usr/src> ls -l linux
lrwxrwxrwx 1 root root 26 Aug  8 14:48 linux -> linux-2.6.35-4807-g4a386c3

/usr/src> emerge -1v nvidia-drivers


These are the packages that would be merged, in order:

Calculating dependencies  ... done!
[ebuild   R   ] x11-drivers/nvidia-drivers-256.35  USE="-acpi -custom-cflags -gtk (-multilib)" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB


>>> Verifying ebuild manifests

>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-256.35
 * NVIDIA-Linux-x86-256.35.run RMD160 SHA1 SHA256 size ;-) ...                                                                                                                 [ ok ]
 * checking ebuild checksums ;-) ...                                                                                                                                           [ ok ]
 * checking auxfile checksums ;-) ...                                                                                                                                          [ ok ]
 * checking miscfile checksums ;-) ...                                                                                                                                         [ ok ]
 * CPV:  x11-drivers/nvidia-drivers-256.35
 * REPO: gentoo
 * USE:  elibc_glibc kernel_linux userland_GNU x86
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux
 * Found kernel object directory:
 *     /lib/modules/2.6.35/build
 * Found sources for kernel version:
 *     2.6.35
 * Checking for MTRR support ...                                                                                                                                                [ ok ]
>>> Unpacking source...
>>> Unpacking NVIDIA-Linux-x86-256.35.run to /var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work
^C

Exiting on signal 2








/usr/src> KERNEL_DIR=/usr/src/linux-2.6.35-4807-g4a386c3 emerge -1v nvidia-drivers

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] x11-drivers/nvidia-drivers-256.35  USE="-acpi -custom-cflags -gtk (-multilib)" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB


>>> Verifying ebuild manifests

>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-256.35
 * NVIDIA-Linux-x86-256.35.run RMD160 SHA1 SHA256 size ;-) ...                                                                                                                 [ ok ]
 * checking ebuild checksums ;-) ...                                                                                                                                           [ ok ]
 * checking auxfile checksums ;-) ...                                                                                                                                          [ ok ]
 * checking miscfile checksums ;-) ...                                                                                                                                         [ ok ]
 * CPV:  x11-drivers/nvidia-drivers-256.35
 * REPO: gentoo
 * USE:  elibc_glibc kernel_linux userland_GNU x86
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux-2.6.35-4807-g4a386c3
 * Found kernel object directory:
 *     /lib/modules/2.6.35/build
 * Found sources for kernel version:
 *     2.6.35
 * Checking for MTRR support ...                                                                                                                                                [ ok ]
>>> Unpacking source...
>>> Unpacking NVIDIA-Linux-x86-256.35.run to /var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work
^C

Exiting on signal 2







/usr/src> KBUILD_OUTPUT=/lib/modules/2.6.35-4807-g4a386c3 KERNEL_DIR=/usr/src/linux-2.6.35-4807-g4a386c3 emerge -1v nvidia-drivers

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] x11-drivers/nvidia-drivers-256.35  USE="-acpi -custom-cflags -gtk (-multilib)" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB


>>> Verifying ebuild manifests

>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-256.35
 * NVIDIA-Linux-x86-256.35.run RMD160 SHA1 SHA256 size ;-) ...                                                                                                                 [ ok ]
 * checking ebuild checksums ;-) ...                                                                                                                                           [ ok ]
 * checking auxfile checksums ;-) ...                                                                                                                                          [ ok ]
 * checking miscfile checksums ;-) ...                                                                                                                                         [ ok ]
 * CPV:  x11-drivers/nvidia-drivers-256.35
 * REPO: gentoo
 * USE:  elibc_glibc kernel_linux userland_GNU x86
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux-2.6.35-4807-g4a386c3
 * Found kernel object directory:
 *     /lib/modules/2.6.35-4807-g4a386c3
 * Found sources for kernel version:
 *     2.6.35
 * Could not find a usable .config in the kernel source directory.
 * Please ensure that /usr/src/linux-2.6.35-4807-g4a386c3 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-256.35 failed:
 *   Kernel not configured; no .config found in /lib/modules/2.6.35-4807-g4a386c3
 * 
 * Call stack:
 *                      ebuild.sh, line  48:  Called pkg_setup
 *   nvidia-drivers-256.35.ebuild, line 187:  Called linux-mod_pkg_setup
 *               linux-mod.eclass, line 586:  Called require_configured_kernel
 *              linux-info.eclass, line 275:  Called die
 * The specific snippet of code:
 *   		die "Kernel not configured; no .config found in ${KV_OUT_DIR}"
 * 
 * If you need support, post the output of 'emerge --info =x11-drivers/nvidia-drivers-256.35',
 * the complete build log and the output of 'emerge -pqv =x11-drivers/nvidia-drivers-256.35'.
 * The complete build log is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-256.35/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-256.35/temp/die.env'.
 * S: '/var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work/'
^C

Exiting on signal 2
Comment 6 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2010-08-08 18:29:55 UTC
Does your KBUILD_OUTPUT actually contain a .config? It should.

'cd $KBUILD_OUTPUT && make kernelrelease' should work.'make 
Comment 7 Alessandro Guido 2010-08-08 19:41:56 UTC
(In reply to comment #6)
> Does your KBUILD_OUTPUT actually contain a .config? It should.
> 
> 'cd $KBUILD_OUTPUT && make kernelrelease' should work.'make 
> 

Sorry, I think I've misused KBUILD_OUTPUT up until now.



~> cd /lib/modules/2.6.35-4807-g4a386c3/build

/lib/modules/2.6.35-4807-g4a386c3/build> make kernelrelease
2.6.35-4807-g4a386c3


/lib/modules/2.6.35-4807-g4a386c3/build> KBUILD_OUTPUT=`pwd` emerge -1 nvidia-drivers
Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-256.35
 * NVIDIA-Linux-x86-256.35.run RMD160 SHA1 SHA256 size ;-) ...                                                                                                                 [ ok ]
 * checking ebuild checksums ;-) ...                                                                                                                                           [ ok ]
 * checking auxfile checksums ;-) ...                                                                                                                                          [ ok ]
 * checking miscfile checksums ;-) ...                                                                                                                                         [ ok ]
 * CPV:  x11-drivers/nvidia-drivers-256.35
 * REPO: gentoo
 * USE:  elibc_glibc kernel_linux userland_GNU x86
 * Determining the location of the kernel source code
 * Unable to find kernel sources at /usr/src/linux
 * Please make sure that /usr/src/linux points at your running kernel, 
 * (or the kernel you wish to build against).
 * Alternatively, set the KERNEL_DIR environment variable to the kernel sources location
 * Unable to calculate Linux Kernel version for build, attempting to use running version
 * Found kernel object directory:
 *     /usr/src/linux-2.6.35
 * Found sources for kernel version:
 *     2.6.35
 * Checking for MTRR support ...                                                                                                                                                [ ok ]
>>> Unpacking source...
>>> Unpacking NVIDIA-Linux-x86-256.35.run to /var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work
>>> Source unpacked in /var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work
>>> Preparing source in /var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work ...
 * Applying NVIDIA_glx-defines.patch ...                                                                                                                                        [ ok ]
 * Applying NVIDIA_glx-glheader.patch ...                                                                                                                                       [ ok ]
 * Applying 256.35-unified-arch.patch ...                                                                                                                                       [ ok ]
 * Converting /kernel/Makefile.kbuild to use M= instead of SUBDIRS= ...                                                                                                         [ ok ]
>>> Source prepared.
^C

Exiting on signal 2

 * Messages for package x11-drivers/nvidia-drivers-256.35:

 * Unable to find kernel sources at /usr/src/linux
 * Unable to calculate Linux Kernel version for build, attempting to use running version




/lib/modules/2.6.35-4807-g4a386c3/build> KERNEL_DIR=/usr/src/linux-2.6.35-4807-g4a386c3 emerge -1 nvidia-drivers
Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-256.35
 * NVIDIA-Linux-x86-256.35.run RMD160 SHA1 SHA256 size ;-) ...                                                                                                                 [ ok ]
 * checking ebuild checksums ;-) ...                                                                                                                                           [ ok ]
 * checking auxfile checksums ;-) ...                                                                                                                                          [ ok ]
 * checking miscfile checksums ;-) ...                                                                                                                                         [ ok ]
 * CPV:  x11-drivers/nvidia-drivers-256.35
 * REPO: gentoo
 * USE:  elibc_glibc kernel_linux userland_GNU x86
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux-2.6.35-4807-g4a386c3
 * Found kernel object directory:
 *     /lib/modules/2.6.35/build
 * Found sources for kernel version:
 *     2.6.35
 * Checking for MTRR support ...                                                                                                                                                [ ok ]
>>> Unpacking source...
>>> Unpacking NVIDIA-Linux-x86-256.35.run to /var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work
>>> Source unpacked in /var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work
^C

Exiting on signal 2

 * Messages for package x11-drivers/nvidia-drivers-256.35:

 * Unable to find kernel sources at /usr/src/linux
 * Unable to calculate Linux Kernel version for build, attempting to use running version






>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-256.35
 * NVIDIA-Linux-x86-256.35.run RMD160 SHA1 SHA256 size ;-) ...                                                                                                                 [ ok ]
 * checking ebuild checksums ;-) ...                                                                                                                                           [ ok ]
 * checking auxfile checksums ;-) ...                                                                                                                                          [ ok ]
 * checking miscfile checksums ;-) ...                                                                                                                                         [ ok ]
 * CPV:  x11-drivers/nvidia-drivers-256.35
 * REPO: gentoo
 * USE:  elibc_glibc kernel_linux userland_GNU x86
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux-2.6.35-4807-g4a386c3
 * Found kernel object directory:
 *     /lib/modules/2.6.35-4807-g4a386c3/build
 * Found sources for kernel version:
 *     2.6.35-4807-g4a386c3
 * Checking for MTRR support ...                                                                                                                                                [ ok ]
>>> Unpacking source...
>>> Unpacking NVIDIA-Linux-x86-256.35.run to /var/tmp/portage/x11-drivers/nvidia-drivers-256.35/work
^C

Exiting on signal 2
Comment 8 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2010-08-08 20:19:56 UTC
Err, something in comment #7 wasn't right. You show only 2 emerge invocations, but 3 sets of output.

I do agree with your assessment about the problem w/ KV_LOCAL being missing from the path however.

nick:
I've CC'd you here since I took your patch for the KV_LOCAL calculation.

The root problem here is that if the user does NOT specify the KBUILD_OUTPUT, but one was in use (and KBUILD_OUTPUT != KERNEL_DIR), the default OUTPUT_DIR is wrong, as it's missing KV_LOCAL, and can't include KV_LOCAL until we know it.
Comment 9 Alessandro Guido 2010-08-08 21:19:33 UTC
(In reply to comment #8)
> Err, something in comment #7 wasn't right. You show only 2 emerge invocations,
> but 3 sets of output.

Yes, sorry. It was the output of

/lib/modules/2.6.35-4807-g4a386c3/build> KBUILD_OUTPUT=`pwd` KERNEL_DIR=/usr/src/linux-2.6.35-4807-g4a386c3 emerge -1 nvidia-drivers
Comment 10 Nick Bowler 2010-08-09 14:27:28 UTC
(In reply to comment #8)
> nick: I've CC'd you here since I took your patch for the KV_LOCAL
> calculation.
> 
> The root problem here is that if the user does NOT specify the KBUILD_OUTPUT,
> but one was in use (and KBUILD_OUTPUT != KERNEL_DIR), the default OUTPUT_DIR
> is wrong, as it's missing KV_LOCAL, and can't include KV_LOCAL until we know
> it.

So I think the "fix" in this case is just to default OUTPUT_DIR to the source
directory, which will then bail immediately with an error message due to the
tree being unprepared.  I'll look into doing this later tonight, probably
coupled with adding some extra checks that were discussed earlier.

The current behaviour is that the eclass tries to auto-detect the output dir by
looking in /lib/modules/$VERSION/build.  Unfortunately, this doomed to failure
since it is impossible to know the version number before we know the output
directory (there is a comment in the eclass to this effect, but it tries
anyway).  This problem is exacerbated by the fact that *every* recent-ish git
kernel user (i.e. not using release kernels) is using localversions.

Unfortunately, we can't reliably determine whether the detected output
directory is wrong, because it might be perfectly valid!  For example, one
might build two different kernels from the same source tree with two different
output directories, configurations and local versions.

The good news is that if one is *not* using KBUILD_OUTPUT, then defaulting
OUTPUT_DIR to the source directory is the right thing to do.  On the other
hand, if the user *is* using KBUILD_OUTPUT, then the source directory is
required to be pristine, and this can be detected easily.

The moral here is if you use KBUILD_OUTPUT (or make O=...) when building
kernels, you *must* also set KBUILD_OUTPUT when running emerge (or set it in
make.conf).

(In reply to comment #1)
> I suggest using "make kernelrelease" in $KV_DIR to get the right version, and
> use /lib/modules/$kernelrelease/build for KV_OUT_DIR if KBUILD_OUTPUT is not
> specified.

Unfortunately, this doesn't actually work: 'make kernelrelease' doesn't
necessarily produce the right answer when run from the source directory on an
unconfigured kernel, and in latest git it even writes to the directory (not
cool for use in ebuilds).
Comment 11 Mike Pagano gentoo-dev 2021-08-26 22:18:08 UTC
This bug is 11 years old. If someone wants to submit new patches for this feature please do so by sending them to the gentoo-dev mailing list as a start