Skip to contentSkip to conversation

configure: Escape non-numbers in version_ge()

PATCH In review Philippe Mathieu-Daudé 2 participants 3 messages Feb 2, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: Escape non-numbers in version_ge()

On Red Hat based distributions, the configure script emits various warnings:

  # ./configure
  Using './build' as the directory for build output
  ./configure: line 212: test: 2-15: integer expression expected
  ./configure: line 213: test: 2-15: integer expression expected
  ./configure: line 212: test: el8: integer expression expected
  ./configure: line 213: test: el8: integer expression expected

This is produced by the gdb version check introduced in commit b1863ccc957 ("configure: gate our use of GDB to 8.3.1 or above"):

    gdb_version=$($gdb_bin --version | head -n 1)
    if version_ge ${gdb_version##* } 8.3.1; then
        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
    fi

Because on RHEL/Fedora the minor version is not a plain number:

  $ gdb --version | head -n 1
  GNU gdb (GDB) Fedora 9.1-7.fc32
  $ gdb --version | head -n 1
  GNU gdb (GDB) Red Hat Enterprise Linux 8.2-15.el8

Fix by only using the leading numbers, stripping the rest.

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
index e85d6baf8f8..21f6530a812 100755
@@ -205,7 +205,7 @@ version_ge () {
         local_first=${2-0}
         # 'shift 2' if $2 is set, or 'shift' if $2 is not set
         shift ${2:+2}
-        local_ver1=$*
+        local_ver1=$(echo $* | sed -E 's/(^[0-9]+).*/\1/')
         set x $local_ver2
         # the second argument finished, the first must be greater or equal
         test $# = 1 && return 0
Signature · 1 line
2.26.2
#1 lore raw
Quoted 38 lines · Philippe Mathieu-Daudé

On Red Hat based distributions, the configure script emits various warnings:

  # ./configure
  Using './build' as the directory for build output
  ./configure: line 212: test: 2-15: integer expression expected
  ./configure: line 213: test: 2-15: integer expression expected
  ./configure: line 212: test: el8: integer expression expected
  ./configure: line 213: test: el8: integer expression expected

This is produced by the gdb version check introduced in commit b1863ccc957 ("configure: gate our use of GDB to 8.3.1 or above"):

    gdb_version=$($gdb_bin --version | head -n 1)
    if version_ge ${gdb_version##* } 8.3.1; then
        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
    fi

Because on RHEL/Fedora the minor version is not a plain number:

  $ gdb --version | head -n 1
  GNU gdb (GDB) Fedora 9.1-7.fc32
  $ gdb --version | head -n 1
  GNU gdb (GDB) Red Hat Enterprise Linux 8.2-15.el8

Fix by only using the leading numbers, stripping the rest.

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +0 -0
index e85d6baf8f8..21f6530a812 100755

configure version_ge () { · line 211

Quoted 8 lines
configure +1 -1
@@ -205,7 +205,7 @@ version_ge () {
         local_first=${2-0}
         # 'shift 2' if $2 is set, or 'shift' if $2 is not set
         shift ${2:+2}
-        local_ver1=$*
+        local_ver1=$(echo $* | sed -E 's/(^[0-9]+).*/\1/')
         set x $local_ver2
         # the second argument finished, the first must be greater or equal
         test $# = 1 && return 0

I already have a fix that was posted in:

Subject: [PATCH v2 7/8] configure: make version_ge more tolerant of shady version input
Date: Fri, 22 Jan 2021 18:18:53 +0000
Message-Id: <[email protected]>

About to feature in the pre-PR series I'm about to post.

Signature · 1 line
Alex Bennée
#2 lore raw
Quoted 52 lines · Alex Bennée
Quoted 38 lines · Philippe Mathieu-Daudé

On Red Hat based distributions, the configure script emits various warnings:

  # ./configure
  Using './build' as the directory for build output
  ./configure: line 212: test: 2-15: integer expression expected
  ./configure: line 213: test: 2-15: integer expression expected
  ./configure: line 212: test: el8: integer expression expected
  ./configure: line 213: test: el8: integer expression expected

This is produced by the gdb version check introduced in commit b1863ccc957 ("configure: gate our use of GDB to 8.3.1 or above"):

    gdb_version=$($gdb_bin --version | head -n 1)
    if version_ge ${gdb_version##* } 8.3.1; then
        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
    fi

Because on RHEL/Fedora the minor version is not a plain number:

  $ gdb --version | head -n 1
  GNU gdb (GDB) Fedora 9.1-7.fc32
  $ gdb --version | head -n 1
  GNU gdb (GDB) Red Hat Enterprise Linux 8.2-15.el8

Fix by only using the leading numbers, stripping the rest.

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +0 -0
index e85d6baf8f8..21f6530a812 100755

configure version_ge () { · line 211

Quoted 8 lines
configure +1 -1
@@ -205,7 +205,7 @@ version_ge () {
         local_first=${2-0}
         # 'shift 2' if $2 is set, or 'shift' if $2 is not set
         shift ${2:+2}
-        local_ver1=$*
+        local_ver1=$(echo $* | sed -E 's/(^[0-9]+).*/\1/')
         set x $local_ver2
         # the second argument finished, the first must be greater or equal
         test $# = 1 && return 0

I already have a fix that was posted in:

Quoted 5 lines

Subject: [PATCH v2 7/8] configure: make version_ge more tolerant of shady version input
Date: Fri, 22 Jan 2021 18:18:53 +0000
Message-Id: <[email protected]>

About to feature in the pre-PR series I'm about to post.

Oh I missed it.

Thanks,

Phil.