From: DJ Delorie <dj@redhat.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: lukma@denx.de, libc-alpha@sourceware.org
Subject: Re: [PATCH] ci: Check for necessary Debian packages when running build-many-glibcs.py
Date: Thu, 21 Sep 2023 17:44:46 -0400 [thread overview]
Message-ID: <xnpm2b19rl.fsf@greed.delorie.com> (raw)
In-Reply-To: <a502abc5-f4b2-88a5-1b18-31f867897efe@linaro.org>
Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> writes:
> The script untar gz, bz2, and xz files, should it check for the associated
> tools as well?
Added. I reset most of the versions to 0,0 and noted in the commit when
to change them; iirc I actually did some research on the git version so
I left that alone (and as an example).
bzip2 was an outlier; it sends its version info to stderr instead of
stdout, and *still* starts a compression stream... sigh.
I added Lukasz and Adhemerval as co-authors as we all contributed code
to this; let me know if you don't want to be listed.
From b83df8bf9c10154be8b21e6a82fff43fcb8ebb3d Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@redhat.com>
Date: Thu, 21 Sep 2023 17:24:05 -0400
Subject: build-many-glibcs: Check for required system tools
Notes for future devs:
* Add tools as you find they're needed, with version 0,0
* Bump version when you find an old tool that doesn't work
* Don't add a version just because you know it works
Co-authored-by: Lukasz Majewski <lukma@denx.de>
Co-authored-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 57a5c48b16..edea52bbae 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -56,6 +56,26 @@ import sys
import time
import urllib.request
+# This is a list of system utilities that are expected to be available
+# to this script, and, if a non-zero version is included, the minimum
+# version required to work with this sccript.
+def get_list_of_required_tools():
+ global REQUIRED_TOOLS
+ REQUIRED_TOOLS = {
+ 'awk' : (get_version_awk, (0,0,0)),
+ 'bison' : (get_version, (0,0)),
+ 'flex' : (get_version, (0,0,0)),
+ 'git' : (get_version, (1,8,3)),
+ 'make' : (get_version, (4,0)),
+ 'makeinfo' : (get_version, (0,0)),
+ 'patch' : (get_version, (0,0,0)),
+ 'sed' : (get_version, (0,0)),
+ 'tar' : (get_version, (0,0,0)),
+ 'gzip' : (get_version, (0,0)),
+ 'bzip2' : (get_version_bzip2, (0,0,0)),
+ 'xz' : (get_version, (0,0,0)),
+ }
+
try:
subprocess.run
except:
@@ -1871,8 +1891,84 @@ def get_parser():
return parser
+def get_version_common(progname,line,word,delchars,arg1):
+ try:
+ out = subprocess.run([progname, arg1],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.DEVNULL,
+ stdin=subprocess.DEVNULL,
+ check=True, universal_newlines=True)
+ v = out.stdout.splitlines()[line].split()[word]
+ if delchars:
+ v = v.replace(delchars,'')
+ return [int(x) for x in v.split('.')]
+ except:
+ return 'missing';
+
+def get_version_common_stderr(progname,line,word,delchars,arg1):
+ try:
+ out = subprocess.run([progname, arg1],
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.PIPE,
+ stdin=subprocess.DEVNULL,
+ check=True, universal_newlines=True)
+ v = out.stderr.splitlines()[line].split()[word]
+ if delchars:
+ v = v.replace(delchars,'')
+ return [int(x) for x in v.split('.')]
+ except:
+ return 'missing';
+
+def get_version(progname):
+ return get_version_common (progname, 0, -1, None, '--version');
+
+def get_version_awk(progname):
+ return get_version_common (progname, 0, 2, ',', '--version');
+
+def get_version_bzip2(progname):
+ return get_version_common_stderr (progname, 0, 6, ',', '-h');
+
+def check_version(ver, req):
+ for v, r in zip(ver, req):
+ if v > r:
+ return True
+ if v < r:
+ return False
+ return True
+
+def version_str(ver):
+ return '.'.join([str (x) for x in ver])
+
+def check_for_required_tools():
+ get_list_of_required_tools()
+ count_old_tools = 0
+ count_missing_tools = 0
+
+ for k, v in REQUIRED_TOOLS.items():
+ version = v[0](k)
+ if version == 'missing':
+ ok = 'missing'
+ else:
+ ok = 'ok' if check_version (version, v[1]) else 'old'
+ if ok == 'old':
+ if count_old_tools == 0:
+ print("One or more required tools are too old:")
+ count_old_tools = count_old_tools + 1
+ print('{:9}: {:3} (obtained=\"{}\" required=\"{}\")'.format(k, ok,
+ version_str(version), version_str(v[1])))
+ if ok == 'missing':
+ if count_missing_tools == 0:
+ print("One or more required tools are missing:")
+ count_missing_tools = count_missing_tools + 1
+ print('{:9}: {:3} (required=\"{}\")'.format(k, ok,
+ version_str(v[1])))
+
+ if count_old_tools > 0 or count_missing_tools > 0:
+ exit (1);
+
def main(argv):
"""The main entry point."""
+ check_for_required_tools();
parser = get_parser()
opts = parser.parse_args(argv)
topdir = os.path.abspath(opts.topdir)
next prev parent reply other threads:[~2023-09-21 21:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-08 16:52 Lukasz Majewski
2021-11-08 16:59 ` Joseph Myers
2021-11-08 17:06 ` Adhemerval Zanella
2021-11-08 17:15 ` Florian Weimer
2021-11-08 19:44 ` Lukasz Majewski
2021-11-08 20:27 ` Adhemerval Zanella
2021-11-09 13:39 ` Lukasz Majewski
2021-11-09 13:43 ` Adhemerval Zanella
2021-11-09 15:32 ` Lukasz Majewski
2023-05-26 22:12 ` DJ Delorie
2023-05-26 22:34 ` Joseph Myers
2023-05-31 19:54 ` DJ Delorie
2023-05-31 20:18 ` DJ Delorie
2023-06-05 20:42 ` Adhemerval Zanella Netto
2023-06-05 21:12 ` DJ Delorie
2023-09-21 21:44 ` DJ Delorie [this message]
2023-10-09 18:23 ` Adhemerval Zanella Netto
2023-10-09 21:53 ` DJ Delorie
2021-11-08 18:15 ` Lukasz Majewski
2021-11-08 18:31 ` Joseph Myers
2021-11-08 19:51 ` Lukasz Majewski
2021-11-08 21:25 ` Joseph Myers
2021-11-08 17:17 ` Florian Weimer
2021-11-08 18:52 ` Joseph Myers
2021-11-08 19:03 ` Florian Weimer
2021-11-08 18:56 ` Adhemerval Zanella
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=xnpm2b19rl.fsf@greed.delorie.com \
--to=dj@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=lukma@denx.de \
/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).