Gentoo Archives: gentoo-dev

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