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@gentoo.org>
This commit is contained in:
James Le Cuirot 2025-06-06 11:17:15 +01:00
parent eff2c417dc
commit 4145a2143b
No known key found for this signature in database
GPG Key ID: 1226415D00DD3137

View File

@ -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