commit:     4145a2143b536676dd9372cc0c7e4994eac9203f
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  6 10:17:15 2025 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Mon Jun  9 20:27:51 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4145a214

linux-info.eclass: Fix building modules when /lib/modules is locked down

/lib/modules/*/build is often a symlink. get_version is usually run in
pkg_setup as root, so fully resolve it then in case the unprivileged
user doesn't have permission to do it later.

Closes: https://bugs.gentoo.org/957187
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>

 eclass/linux-info.eclass | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
index a2b38d604b21..6dd3f81a6dfb 100644
--- a/eclass/linux-info.eclass
+++ b/eclass/linux-info.eclass
@@ -574,7 +574,12 @@ get_version() {
                        # We cannot use the local version to find the output 
directory
                        # because that is where it is written to.
                        KV_OUT_DIR+="/lib/modules/${KV_FULL}/build"
-                       [[ -d ${KV_OUT_DIR} ]] && break
+                       # build is often a symlink. This function is usually 
run in
+                       # pkg_setup as root, so fully resolve it now in case the
+                       # unprivileged user doesn't have permission to do it 
later. If we
+                       # don't have permission now, then this will fall back 
to KV_DIR
+                       # below, which is probably where the build symlink 
points to anyway.
+                       KV_OUT_DIR=$(realpath -q -e "${KV_OUT_DIR}") && break
                done
        fi
 

Reply via email to