From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9F94A3858C5F for ; Fri, 26 May 2023 22:12:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F94A3858C5F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685139175; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=rWUYx4y6RqrI0muWkVivxHxkX0mgZkUfbPXW0RMoRWU=; b=ImP8MtwKAgMWxA7QyA/tLZqcmGo1SeSzOUvRXibpY7CyQWBaciaRjSrl4kfvuZyH5QXO0V ZTl9njp4tjIpojW+jyDuH/BJ/3jArlHjcP/DyLIeTh0ycv6MLaJrN4i9KN1E3v0G3+UnL/ VnT/kH9jaGuXDQNjOqk+zKey+WEvj3Q= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-81-5M-QahC9PpSGYChuLoCcdg-1; Fri, 26 May 2023 18:12:52 -0400 X-MC-Unique: 5M-QahC9PpSGYChuLoCcdg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0095B1C05AAA; Fri, 26 May 2023 22:12:52 +0000 (UTC) Received: from greed.delorie.com (unknown [10.22.9.251]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E8712029F6D; Fri, 26 May 2023 22:12:51 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.15.2/8.15.2) with ESMTP id 34QMCniT3709480; Fri, 26 May 2023 18:12:49 -0400 From: DJ Delorie To: Lukasz Majewski Cc: adhemerval.zanella@linaro.org, fweimer@redhat.com, libc-alpha@sourceware.org, schwab@linux-m68k.org, joseph@codesourcery.com Subject: Re: [PATCH] ci: Check for necessary Debian packages when running build-many-glibcs.py In-Reply-To: <20211109163206.326676dc@ktm> Date: Fri, 26 May 2023 18:12:49 -0400 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: [working my way through old patches ;-] https://patchwork.sourceware.org/project/glibc/patch/20211108165255.15600-1-lukma@denx.de/ https://patchwork.sourceware.org/project/glibc/patch/20211108201931.17159-1-lukma@denx.de/ Lukasz Majewski writes: > I thought that the above code is so different from mine, that you would > like to prepare patch for it? How about something like this? I filled out Adhemerval's sample code with some error checking, added some user messages, and ended up with the attached. I split it up so that the *list* of required tools is at the beginning of the file (easily findable) but the *code* to handle it is near the end. I also thought of adding two more columns to the required_tools table, one with common RPM package names, and one with common DEB package names. This would purely be for convenience, although I assume most bmg users know how to find which package an executable is in. Might be trickier for libraries, if we add "required libraries" to the list later. I also considered moving the minimum-version list to the beginning, to make it easier to find, but decided that should be separate. diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py index 95726c4a29..0f35c62b7a 100755 --- a/scripts/build-many-glibcs.py +++ b/scripts/build-many-glibcs.py @@ -56,6 +56,20 @@ import sys import time import urllib.request +def get_list_of_required_tools(): + global REQUIRED_TOOLS + REQUIRED_TOOLS = { + 'awk' : (get_version_awk, (3,1,2)), + 'bison' : (get_version, (2,7)), + 'flex' : (get_version, (2,6,0)), + 'git' : (get_version, (2,32)), + 'make' : (get_version, (4,0)), + 'makeinfo' : (get_version, (4,7)), + 'patch' : (get_version, (2,7,0)), + 'sed' : (get_version, (3,2)), + 'tar' : (get_version, (1,3,4)), + } + try: subprocess.run except: @@ -1865,8 +1879,66 @@ def get_parser(): return parser +def get_version_common(progname,line,word,delchars): + try: + out = subprocess.run([progname, '--version'], + stdout=subprocess.PIPE, + stderr=subprocess.DEVNULL, + check=True, universal_newlines=True).stdout + v = out.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); + +def get_version_awk(progname): + return get_version_common (progname, 0, 2, ','); + +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)