Re: [poky] [PATCH] feat: don't use sub-processes to filter FIXME variables and

Alexander Kanavin <[email protected]>
Newsgroups org.yoctoproject.lists.poky
Message-ID <CANNYZj9dDARjDGLH-6f_h2ANahUGBtEzq-BsiAndVA-jC4=2QA@mail.gmail.com>
Thanks, the correct mailing list for this is openembedded-core.

Alex

On Sat, 19 Oct 2024 at 00:32, Michael Krasnyk via
lists.yoctoproject.org
<[email protected]> wrote:
>
> From a75040b2a197c0ddb55a047dcc0d834606ddf284 Mon Sep 17 00:00:00 2001
> From: Michael Krasnyk <[email protected]>
> Date: Fri, 18 Oct 2024 23:50:12 +0200
> Subject: [PATCH] feat: don't use sub-processes to filter FIXME variables and
>  use only Python
>
> ---
>  meta/classes-global/staging.bbclass | 26 ++++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/meta/classes-global/staging.bbclass b/meta/classes-global/staging.bbclass
> index c0f5e3ebb6..896592fb7e 100644
> --- a/meta/classes-global/staging.bbclass
> +++ b/meta/classes-global/staging.bbclass
> @@ -176,16 +176,26 @@ def staging_copydir(c, target, dest, seendirs):
>          seendirs.add(dest)
>
>  def staging_processfixme(fixme, target, recipesysroot, recipesysrootnative, d):
> -    import subprocess
> -
>      if not fixme:
>          return
> -    cmd = "sed -e 's:^[^/]*/:%s/:g' %s | xargs sed -i -e 's:FIXMESTAGINGDIRTARGET:%s:g; s:FIXMESTAGINGDIRHOST:%s:g'" % (target, " ".join(fixme), recipesysroot, recipesysrootnative)
> -    for fixmevar in ['PSEUDO_SYSROOT', 'HOSTTOOLS_DIR', 'PKGDATA_DIR', 'PSEUDO_LOCALSTATEDIR', 'LOGFIFO']:
> -        fixme_path = d.getVar(fixmevar)
> -        cmd += " -e 's:FIXME_%s:%s:g'" % (fixmevar, fixme_path)
> -    bb.debug(2, cmd)
> -    subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
> +
> +    import re
> +
> +    fixme_vars = {re.escape("FIXME_" + fixmevar): 'd.getVar(fixmevar)' for fixmevar in ['PSEUDO_SYSROOT', 'HOSTTOOLS_DIR', 'PKGDATA_DIR', 'PSEUDO_LOCALSTATEDIR', 'LOGFIFO']}
> +    fixme_path = {"FIXMESTAGINGDIRTARGET": recipesysroot, "FIXMESTAGINGDIRHOST": recipesysrootnative, **fixme_vars}
> +    target_re = re.compile(r"^[^/]*(?=/)")
> +    fixme_re = re.compile("|".join(fixme_path.keys()))
> +    fixme_files = set()
> +    # Read fixme files
> +    for path in fixme:
> +        with open(path) as fixme_file:
> +            fixme_files.update(target_re.sub(target, line.strip()) for line in fixme_file.readlines())
> +    # Fix files in-place
> +    for path in fixme_files:
> +        with open(path, "r+") as fixed_file:
> +            text = fixme_re.sub(lambda m: fixme_path[re.escape(m.group(0))], fixed_file.read())
> +            fixed_file.seek(0)
> +            fixed_file.write(text)
>
>
>  def staging_populate_sysroot_dir(targetsysroot, nativesysroot, native, d):
> --
> 2.39.3 (Apple Git-146)
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#13458): https://lists.yoctoproject.org/g/poky/message/13458
> Mute This Topic: https://lists.yoctoproject.org/mt/109092733/1686489
> Group Owner: [email protected]
> Unsubscribe: https://lists.yoctoproject.org/g/poky/unsub [[email protected]]
> -=-=-=-=-=-=-=-=-=-=-=-
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.