public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Fangrui Song <maskray@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] build-many-glibcs: relax version check to allow non-digit characters
Date: Wed, 31 Jan 2024 23:46:24 +0000 (GMT)	[thread overview]
Message-ID: <20240131234624.AE4ED3858297@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0d70accc06a9cbb9b13004116f5fa8b1f41a7150

commit 0d70accc06a9cbb9b13004116f5fa8b1f41a7150
Author: Fangrui Song <maskray@google.com>
Date:   Wed Jan 31 15:46:23 2024 -0800

    build-many-glibcs: relax version check to allow non-digit characters
    
    A version string may contain non-digit characters, commonly found in
    built-from-VCS tools, e.g.
    ```
    git version 2.39.GIT
    git version 2.43.0.493.gbc7ee2e5e1
    ```
    
    `int()` will raise a ValueError, leading to a spurious 'missing'.
    
    Reviewed-by: DJ Delorie <dj@redhat.com>

Diff:
---
 scripts/build-many-glibcs.py | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 784c80d132..84418e8de1 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -1888,7 +1888,7 @@ def get_parser():
     return parser
 
 
-def get_version_common(progname,line,word,delchars,arg1):
+def get_version_common(progname,line,word,arg1):
     try:
         out = subprocess.run([progname, arg1],
                              stdout=subprocess.PIPE,
@@ -1896,13 +1896,12 @@ def get_version_common(progname,line,word,delchars,arg1):
                              stdin=subprocess.DEVNULL,
                              check=True, universal_newlines=True)
         v = out.stdout.splitlines()[line].split()[word]
-        if delchars:
-            v = v.replace(delchars,'')
+        v = re.match(r'[0-9]+(.[0-9]+)*', v).group()
         return [int(x) for x in v.split('.')]
     except:
         return 'missing';
 
-def get_version_common_stderr(progname,line,word,delchars,arg1):
+def get_version_common_stderr(progname,line,word,arg1):
     try:
         out = subprocess.run([progname, arg1],
                              stdout=subprocess.DEVNULL,
@@ -1910,20 +1909,19 @@ def get_version_common_stderr(progname,line,word,delchars,arg1):
                              stdin=subprocess.DEVNULL,
                              check=True, universal_newlines=True)
         v = out.stderr.splitlines()[line].split()[word]
-        if delchars:
-            v = v.replace(delchars,'')
+        v = re.match(r'[0-9]+(.[0-9]+)*', v).group()
         return [int(x) for x in v.split('.')]
     except:
         return 'missing';
 
 def get_version(progname):
-    return get_version_common (progname, 0, -1, None, '--version');
+    return get_version_common(progname, 0, -1, '--version');
 
 def get_version_awk(progname):
-    return get_version_common (progname, 0, 2, ',', '--version');
+    return get_version_common(progname, 0, 2, '--version');
 
 def get_version_bzip2(progname):
-    return get_version_common_stderr (progname, 0, 6, ',', '-h');
+    return get_version_common_stderr(progname, 0, 6, '-h');
 
 def check_version(ver, req):
     for v, r in zip(ver, req):

                 reply	other threads:[~2024-01-31 23:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240131234624.AE4ED3858297@sourceware.org \
    --to=maskray@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).