[v2] ci: Check for necessary programs when running build-many-glibcs.py

Message ID 20211108201931.17159-1-lukma@denx.de
State Superseded, archived
Delegated to: DJ Delorie
Headers
Series [v2] ci: Check for necessary programs when running build-many-glibcs.py |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Lukasz Majewski Nov. 8, 2021, 8:19 p.m. UTC
  The build-many-glibc.py can be run on a 'vanila' Debian distribution
(as for example in docker container), which don't have by default
installed some packages (like flex).

This causes build break at late stage of the full build;
../src/scripts/build-many-glibcs.py . checkout --replace-sources &&
../src/scripts/build-many-glibcs.py . host-libraries &&
../src/scripts/build-many-glibcs.py . compilers &&
../src/scripts/build-many-glibcs.py . glibcs

To avoid such situation, this check has been added to inform user
early of required (and missing) essential programs.

Signed-off-by: Lukasz Majewski <lukma@denx.de>

---
Changes for v2:
- Use the shutil.which() to determine if the program is installed.
  The shutil is part of standard Python library (no extra dependencies
  introduced).
---
 scripts/build-many-glibcs.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
  

Patch

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 6046048b75..b76b4e2ff2 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -1852,9 +1852,20 @@  def get_parser():
                         nargs='*')
     return parser
 
+def check_required_programs():
+    # List programs required to run this glibc CI script.
+    required_sw = ['flex', 'bison', 'git', 'makeinfo', 'patch', 'tar']
+    for prog in required_sw:
+        if not shutil.which(prog):
+            print(f"error: Required program: '{prog}' NOT installed!")
+            return False
+
+    return True
 
 def main(argv):
     """The main entry point."""
+    if not check_required_programs():
+        sys.exit(0)
     parser = get_parser()
     opts = parser.parse_args(argv)
     topdir = os.path.abspath(opts.topdir)