Message ID | CAL-AFs1GQ+TFJwSax6s2CoVbqBou=BzcJNGYcNFvpffyCpziwQ@mail.gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | feat: don't use sub-processes to filter FIXME variables and | expand |
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 <michael.krasnyk=gmail.com@lists.yoctoproject.org> wrote: > > From a75040b2a197c0ddb55a047dcc0d834606ddf284 Mon Sep 17 00:00:00 2001 > From: Michael Krasnyk <michael.krasnyk@gmail.com> > 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: poky+owner@lists.yoctoproject.org > Unsubscribe: https://lists.yoctoproject.org/g/poky/unsub [alex.kanavin@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
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
From a75040b2a197c0ddb55a047dcc0d834606ddf284 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk <michael.krasnyk@gmail.com> 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(-) + 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):