Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Tue, 14 Sep 2021 23:48:45
Message-Id: 1631663273.4459479bb524f980f77f82e3108e924077048713.floppym@gentoo
1 commit: 4459479bb524f980f77f82e3108e924077048713
2 Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
3 AuthorDate: Mon Sep 13 14:46:57 2021 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Tue Sep 14 23:47:53 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4459479b
7
8 linux-info.eclass: rework get_running_version
9
10 This function may fail if the version cannot be parsed from a Makefile
11 found by following the /lib/modules/${KV_FULL}/{source,build} symlinks.
12 Instead of failing, we should just split KV_FULL as a fallback.
13
14 Also, simplify the existance checks for the kernel Makefile; if we can't
15 find the kernel source directory, there is really no point in checking
16 for the kernel build directory. The latter will probably contain a
17 Makefile with no version information.
18
19 Bug: https://bugs.gentoo.org/811726
20 Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
21
22 eclass/linux-info.eclass | 47 ++++++++++++++++++++---------------------------
23 1 file changed, 20 insertions(+), 27 deletions(-)
24
25 diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
26 index 4e08949a385..97f7b5c06a9 100644
27 --- a/eclass/linux-info.eclass
28 +++ b/eclass/linux-info.eclass
29 @@ -629,34 +629,27 @@ get_running_version() {
30 die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
31 fi
32
33 - KV_FULL=$(uname -r)
34 -
35 - if [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
36 - KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source)
37 - KBUILD_OUTPUT=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build)
38 - unset KV_FULL
39 - get_version
40 - return $?
41 - elif [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile ]]; then
42 - KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source)
43 - unset KV_FULL
44 - get_version
45 - return $?
46 - elif [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
47 - KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build)
48 - unset KV_FULL
49 - get_version
50 - return $?
51 - else
52 - # This handles a variety of weird kernel versions. Make sure to update
53 - # tests/linux-info_get_running_version.sh if you want to change this.
54 - local kv_full=${KV_FULL//[-+_]*}
55 - KV_MAJOR=$(ver_cut 1 ${kv_full})
56 - KV_MINOR=$(ver_cut 2 ${kv_full})
57 - KV_PATCH=$(ver_cut 3 ${kv_full})
58 - KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}"
59 - : ${KV_PATCH:=0}
60 + local kv=$(uname -r)
61 +
62 + if [[ -f ${ROOT%/}/lib/modules/${kv}/source/Makefile ]]; then
63 + KERNEL_DIR=$(readlink -f "${ROOT%/}/lib/modules/${kv}/source")
64 + if [[ -f ${ROOT%/}/lib/modules/${kv}/build/Makefile ]]; then
65 + KBUILD_OUTPUT=$(readlink -f "${ROOT%/}/lib/modules/${kv}/build")
66 + fi
67 + get_version && return 0
68 fi
69 +
70 + KV_FULL=${kv}
71 +
72 + # This handles a variety of weird kernel versions. Make sure to update
73 + # tests/linux-info_get_running_version.sh if you want to change this.
74 + local kv_full=${KV_FULL//[-+_]*}
75 + KV_MAJOR=$(ver_cut 1 ${kv_full})
76 + KV_MINOR=$(ver_cut 2 ${kv_full})
77 + KV_PATCH=$(ver_cut 3 ${kv_full})
78 + KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}"
79 + : ${KV_PATCH:=0}
80 +
81 return 0
82 }