[PATCH] ci: Check for necessary Debian packages when running build-many-glibcs.py
Adhemerval Zanella
adhemerval.zanella@linaro.org
Tue Nov 9 13:43:15 GMT 2021
On 09/11/2021 10:39, Lukasz Majewski wrote:
> Hi Adhemerval,
>
>> On 08/11/2021 16:44, Lukasz Majewski wrote:
>>> Hi Adhemerval,
>>>
>>>> On 08/11/2021 13:59, Joseph Myers wrote:
>>>>> On Mon, 8 Nov 2021, Lukasz Majewski wrote:
>>>>>
>>>>>> The same approach (with using the 'distro' python module) can be
>>>>>> applied to Fedora or Suse.
>>>>>
>>>>> That module isn't part of the Python standard library. I don't
>>>>> think we should introduce a dependency on it; rather, any use of
>>>>> it should be appropriately conditional, so the code still runs
>>>>> (without these checks) if the module is unavailable (importing
>>>>> produces an ImportError).
>>>>>
>>>>> In particular, even if the OS Python installation includes that
>>>>> module, the script should work with a separately built copy of
>>>>> Python without any such modules from the OS.
>>>>
>>>> Maybe add a check without tying to any distribution (tool -v and
>>>> some version parsing).
>>>
>>> This would require some extra, work but then we would avoid 'distro'
>>> module as the dependency.
>>
>> I think the work required is that hard, something like:
>>
>> --
>> import shutil
>> import subprocess
>>
>> def get_version(progname):
>> out = subprocess.run([progname, '--version'],
>> stdout=subprocess.PIPE, check=True, universal_newlines=True).stdout
>> return [int(x) for x in
>> out.splitlines()[0].split()[-1].split('.')]
>>
>> def get_version_awk(progname):
>> out = subprocess.run([progname, '--version'],
>> stdout=subprocess.PIPE, check=True, universal_newlines=True).stdout
>> version =
>> out.splitlines()[0].split()[2].replace(',','').split('.') return
>> [int(x) for x in version]
>>
>> def check_version(ver, req):
>> for v, r in zip(ver, req):
>> if v >= r:
>> return True
>> return False
>>
>> def version_str(ver):
>> return '.'.join([str (x) for x in version])
>>
>>
>> TOOLS={ 'make' : (get_version, (4,0)),
>> 'makeinfo' : (get_version, (4,7)),
>> 'awk' : (get_version_awk, (3,1,2)),
>> 'bison' : (get_version, (2,7)),
>> 'sed' : (get_version, (3,2)),
>> 'flex' : (get_version, (2,6,0)),
>> 'git' : (get_version, (2,32)),
>> 'patch' : (get_version, (2,7,0)),
>> 'tar' : (get_version, (1,3,4))}
>>
>> for k, v in TOOLS.items():
>> version = v[0](k)
>> ok = 'ok' if check_version (version, v[1]) else 'old'
>> print('{:9}: {:3} (obtained=\"{}\" required=\"{}\")'.format(k, ok,
>> version_str(version), version_str(v[1])))
>> --
>
> Yes, I think that this approach is the most exhaustive one, so we would
> also check the version of required tools.
>
> LGTM :-)
Also, please double check the required version (for instance 'git' and
'patch'). You will also need to add 'perl' and it similar to 'awk',
it emits the version in a GNU manner.
More information about the Libc-alpha
mailing list