/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 <[email protected]>
---
 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
 
-- 
2.49.0


Reply via email to