Gentoo Archives: gentoo-dev

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-dev@l.g.o
Cc: Sergei Trofimovich <slyfox@g.o>, kernel@g.o
Subject: [gentoo-dev] [PATCH] kernel-2.eclass: avoid lexicographical compare on versions, bug #705246
Date: Fri, 22 May 2020 19:13:43
Message-Id: 20200522191333.1689849-1-slyfox@gentoo.org
1 Originally found in bug #705240 as:
2
3 ```
4 if [[ ... || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then
5 ```
6
7 '>' are string comparisons. They are benign so far, but
8 will start failing on linux-10 :)
9
10 Let's be consistent and use version comparison.
11
12 CC: kernel@g.o
13 Closes: https://bugs.gentoo.org/705246
14 Signed-off-by: Sergei Trofimovich <slyfox@g.o>
15 ---
16 eclass/kernel-2.eclass | 8 ++++----
17 1 file changed, 4 insertions(+), 4 deletions(-)
18
19 diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
20 index 07af8d8ab2c..d69182045c5 100644
21 --- a/eclass/kernel-2.eclass
22 +++ b/eclass/kernel-2.eclass
23 @@ -1015,7 +1015,7 @@ postinst_sources() {
24 # K_SECURITY_UNSUPPORTED=deblob
25
26 # if we are to forcably symlink, delete it if it already exists first.
27 - if [[ ${K_SYMLINK} > 0 ]]; then
28 + if [[ ${K_SYMLINK} -gt 0 ]]; then
29 [[ -h ${EROOT}usr/src/linux ]] && { rm "${EROOT}"usr/src/linux || die; }
30 MAKELINK=1
31 fi
32 @@ -1078,7 +1078,7 @@ postinst_sources() {
33 KV_PATCH=$(ver_cut 3 ${OKV})
34 if [[ "$(tc-arch)" = "sparc" ]]; then
35 if [[ $(gcc-major-version) -lt 4 && $(gcc-minor-version) -lt 4 ]]; then
36 - if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.24 ]] ; then
37 + if [[ ${KV_MAJOR} -ge 3 || ver_test ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} -gt 2.6.24 ]] ; then
38 echo
39 elog "NOTE: Since 2.6.25 the kernel Makefile has changed in a way that"
40 elog "you now need to do"
41 @@ -1272,7 +1272,7 @@ unipatch() {
42 # do not apply fbcondecor patch to sparc/sparc64 as it breaks boot
43 # bug #272676
44 if [[ "$(tc-arch)" = "sparc" || "$(tc-arch)" = "sparc64" ]]; then
45 - if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then
46 + if [[ ${KV_MAJOR} -ge 3 || ver_test ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} -gt 2.6.28 ]]; then
47 if [[ ! -z ${K_WANT_GENPATCHES} ]] ; then
48 UNIPATCH_DROP="${UNIPATCH_DROP} *_fbcondecor*.patch"
49 echo
50 @@ -1521,7 +1521,7 @@ kernel-2_src_unpack() {
51 # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
52 # only do this for kernel < 2.6.27 since this file does not exist in later
53 # kernels
54 - if [[ -n ${KV_MINOR} && ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]] ; then
55 + if [[ -n ${KV_MINOR} && ver_test ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} -lt 2.6.27 ]] ; then
56 sed -i \
57 -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
58 "${S}"/arch/ppc/Makefile
59 --
60 2.26.2

Replies