summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2021-09-13 10:46:57 -0400
committerMike Gilbert <floppym@gentoo.org>2021-09-14 19:47:53 -0400
commit4459479bb524f980f77f82e3108e924077048713 (patch)
tree8060c2d711843e33b6feeae971a0889eaabd639a /eclass
parentsys-apps/systemd: backport network fix (diff)
downloadgentoo-4459479bb524f980f77f82e3108e924077048713.tar.gz
gentoo-4459479bb524f980f77f82e3108e924077048713.tar.bz2
gentoo-4459479bb524f980f77f82e3108e924077048713.zip
linux-info.eclass: rework get_running_version
This function may fail if the version cannot be parsed from a Makefile found by following the /lib/modules/${KV_FULL}/{source,build} symlinks. Instead of failing, we should just split KV_FULL as a fallback. Also, simplify the existance checks for the kernel Makefile; if we can't find the kernel source directory, there is really no point in checking for the kernel build directory. The latter will probably contain a Makefile with no version information. Bug: https://bugs.gentoo.org/811726 Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/linux-info.eclass47
1 files changed, 20 insertions, 27 deletions
diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
index 4e08949a3854..97f7b5c06a90 100644
--- a/eclass/linux-info.eclass
+++ b/eclass/linux-info.eclass
@@ -629,34 +629,27 @@ get_running_version() {
die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
fi
- KV_FULL=$(uname -r)
-
- if [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
- KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source)
- KBUILD_OUTPUT=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build)
- unset KV_FULL
- get_version
- return $?
- elif [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile ]]; then
- KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source)
- unset KV_FULL
- get_version
- return $?
- elif [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
- KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build)
- unset KV_FULL
- get_version
- return $?
- else
- # This handles a variety of weird kernel versions. Make sure to update
- # tests/linux-info_get_running_version.sh if you want to change this.
- local kv_full=${KV_FULL//[-+_]*}
- KV_MAJOR=$(ver_cut 1 ${kv_full})
- KV_MINOR=$(ver_cut 2 ${kv_full})
- KV_PATCH=$(ver_cut 3 ${kv_full})
- KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}"
- : ${KV_PATCH:=0}
+ local kv=$(uname -r)
+
+ if [[ -f ${ROOT%/}/lib/modules/${kv}/source/Makefile ]]; then
+ KERNEL_DIR=$(readlink -f "${ROOT%/}/lib/modules/${kv}/source")
+ if [[ -f ${ROOT%/}/lib/modules/${kv}/build/Makefile ]]; then
+ KBUILD_OUTPUT=$(readlink -f "${ROOT%/}/lib/modules/${kv}/build")
+ fi
+ get_version && return 0
fi
+
+ KV_FULL=${kv}
+
+ # This handles a variety of weird kernel versions. Make sure to update
+ # tests/linux-info_get_running_version.sh if you want to change this.
+ local kv_full=${KV_FULL//[-+_]*}
+ KV_MAJOR=$(ver_cut 1 ${kv_full})
+ KV_MINOR=$(ver_cut 2 ${kv_full})
+ KV_PATCH=$(ver_cut 3 ${kv_full})
+ KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}"
+ : ${KV_PATCH:=0}
+
return 0
}