Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 662772 - linux-info.eclass regression: kernel CONFIG_LOCALVERSION not respected if kernel has been built outside source tree
Summary: linux-info.eclass regression: kernel CONFIG_LOCALVERSION not respected if ker...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL:
Whiteboard:
Keywords:
: 666890 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-08-04 10:21 UTC by Nico R.
Modified: 2018-10-22 06:18 UTC (History)
8 users (show)

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


Attachments
Fix linux-info's KV_FULL when both KBUILD_OUTPUT and LOCALVERSION are specified (linux-info-kbuild_output-localversion-fix.patch,689 bytes, patch)
2018-09-17 07:40 UTC, Michael Moon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nico R. 2018-08-04 10:21:51 UTC
Commit https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=50078fbbb3966773401c1fc59838c1e5952c1318 (the fix for bug 460996) causes a regression:

if KBUILD_OUTPUT is not KERNEL_DIR, i.e. if you have built your kernel in a separate directory, KV_LOCAL is not populated properly: the CONFIG_LOCALVERSION is not read as it should be.

Reason is that the ebuild tries to extract KV_LOCAL from "${KV_DIR}"/include/config/kernel.release – but ${KV_DIR} points to the kernel *sources*. The ebuild used to take the local version from "${KV_OUTDIR}"/include/config/kernel.release – which has been working fine. (In fact, I did not understand why the patch was committed at all, as I’m *now* seeing exactly the behavior described in bug 460996 comment 0.)

The code in question starts at line 551 in linux-info.eclass as of commit 50078fbbb3966773401c1fc59838c1e5952c1318. The comment “Grab the kernel release from the output directory.” is now simply wrong. The kernel release is grabbed from the kernel *source* directory.

Maybe the documentation for get_version <https://devmanual.gentoo.org/eclass-reference/linux-info.eclass/> needs an update, too? It talks about KERNEL_DIR and KV_LOCAL; but KV_LOCAL can not be obtained from KERNEL_DIR, it needs KBUILD_OUTPUT. So either say that it uses KERNEL_DIR *and* KBUILD_OUTPUT or make the code behave as documented. I am not sure what is intended.


Steps to reproduce:
* create a separate kernel build dir and cd there,
* point KBUILD_OUTPUT to it (in /etc/portage/make.conf),
* configure the kernel in it (make -C /usr/src/linux O="$PWD" oldconfig),
* build the kernel in the separate directory (make [all]) (in theory, you do not even need a full build),
* install a out-of-kernel-tree kernel module from the portage tree.

(The kernel build directory can belong to and building can be done as a non-root user, as long as portage can read the data when emerging the module package, can be achieved by umask 022 or so.)

Result:
module ends up in /lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}, ${KV_LOCAL} is empty (but should not be).

Result with the previous linux-info.eclass: works as expected, ${KV_LOCAL} is populated properly, installed modules end up in the right directory.
Comment 1 Jonas Stein gentoo-dev 2018-08-08 22:02:37 UTC
confirmed via mail "[gentoo-dev] commit 50078fbbb39667734 for linux-info.eclass"
Comment 2 Michael Moon 2018-09-14 17:08:02 UTC
After extensive discussion in freenode/#gentoo, this bug may affect me.

Since I first installed gentoo in ~2005 with gentoo-sources-2.4, I've always built out-of-tree, with make O=../build-(relevant version) blah

My most recent successful zero-drama update was with gentoo-sources-4.17.9 and nvidia-drivers-396.45 on July 26 (according to genlop)

Today, I installed gentoo-sources-4.17.19 and nvidia-drivers-396.54 using the exact same process I've been using for over a decade, and suddenly modprobe/udev/etc can't find nvidia module on boot.

After manually copying video/ from /lib/modules/4.17.19-gentoo to /lib/modules/4.17.19-gentoo-dorellan (dorellan is my hostname and LOCALVERSION), everything works fine.
Comment 3 Michael Moon 2018-09-17 07:40:46 UTC
Created attachment 547070 [details, diff]
Fix linux-info's KV_FULL when both KBUILD_OUTPUT and LOCALVERSION are specified

This patch fixes the issue for me - linux-info tries to grab $KV_DIR/include/config/kernel.release however this file is placed in the BUILD tree not SOURCE.
Comment 4 Thomas Deutschmann (RETIRED) gentoo-dev 2018-10-02 09:08:07 UTC
*** Bug 666890 has been marked as a duplicate of this bug. ***
Comment 5 Larry the Git Cow gentoo-dev 2018-10-02 09:25:31 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=65d88157ecd490f9f8850f45707c79049e2e3b0f

commit 65d88157ecd490f9f8850f45707c79049e2e3b0f
Author:     Francesco Riosa <vivo75@gmail.com>
AuthorDate: 2018-10-02 09:23:38 +0000
Commit:     Thomas Deutschmann <whissi@gentoo.org>
CommitDate: 2018-10-02 09:25:21 +0000

    linux-info.eclass: CONFIG_LOCALVERSION for out of source builds
    
    Closes: https://bugs.gentoo.org/662772
    Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>

 eclass/linux-info.eclass | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
Comment 6 nE0sIghT 2018-10-19 16:12:36 UTC
This changes break check_extra_config.

For example virtualbox-modules build is failed with

* 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: app-emulation/virtualbox-modules-5.2.18::gentoo failed (setup phase):
 *   Kernel not configured; no .config found in /usr/src/linux
 * 
 * Call stack:
 *                          ebuild.sh, line 124:  Called pkg_setup
 *   virtualbox-modules-5.2.18.ebuild, line  31:  Called linux-mod_pkg_setup
 *                   linux-mod.eclass, line 586:  Called linux-info_pkg_setup
 *                  linux-info.eclass, line 965:  Called check_extra_config
 *                  linux-info.eclass, line 773:  Called require_configured_kernel
 *                  linux-info.eclass, line 307:  Called die
 * The specific snippet of code:
 *   		die "Kernel not configured; no .config found in ${KV_OUT_DIR}"
Comment 7 Michael Moon 2018-10-22 06:18:39 UTC
Hmm, I specifically tested my patch with virtualbox-modules, but the one committed upstream is different.

nE0sIghT, care to reverse upstream and try mine and see if it works any differently?