public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: DJ Delorie <dj@redhat.com>, Lukasz Majewski <lukma@denx.de>
Cc: 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
Date: Mon, 5 Jun 2023 17:42:41 -0300	[thread overview]
Message-ID: <a502abc5-f4b2-88a5-1b18-31f867897efe@linaro.org> (raw)
In-Reply-To: <xnr0r27ndq.fsf@greed.delorie.com>



On 26/05/23 19:12, DJ Delorie wrote:
> 
> [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 <lukma@denx.de> 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.

The patch organization sounds good to me, thanks for working on this.

> 
> 
> 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)),

The script untar gz, bz2, and xz files, should it check for the associated
tools as well?

> +    }
> +
>  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)
> 

  parent reply	other threads:[~2023-06-05 20:42 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 [this message]
2023-06-05 21:12                   ` DJ Delorie
2023-09-21 21:44                   ` DJ Delorie
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=a502abc5-f4b2-88a5-1b18-31f867897efe@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=dj@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=lukma@denx.de \
    --cc=schwab@linux-m68k.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).