Skip to contentSkip to conversation

add basic b4 config file

PATCH Superseded Quentin Schulz 5 participants 9 messages Feb 3, 2025 – Feb 5, 2025

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover add basic b4 config file

This adds very basic support for using b4 in OE-Core. This essentially just automatically adds the proper mailing list when running b4 prep --auto-to-cc.

This also adds the b4 wrapper script that poky will need to use in order to identify which mailing list a patch needs to be sent to and do some additional per-patch checks that aren't necessary when running from vanilla OE-Core.

Once this is merged, poky will need to merge OE-Core into itself and override with its own .b4-config that makes use of that script.

---
Changes in v2:
- add mention to first patch that running patchtest for b4 prep --check
is what we're eventually aiming for,
- add poky b4 wrapper script (it used to be in the patch series for
poky, c.f. https://lore.kernel.org/poky/[email protected]/T/#m95d6aa25cc42352416da477cf07d7b3cbd671231
- poky b4 wrapper script properly identifies patches with files modified
in both OE-Core and other repos part of poky,
- poky b4 wrapper script pretty prints when there's more than one
project modified by a script, instead of lazily printing a Python
list,
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Quentin Schulz (2):
add basic b4 config file
scripts: add b4-wrapper for poky

 .b4-config                 |   3 +
 scripts/b4-wrapper-poky.py | 170 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 173 insertions(+)

---
base-commit: 30ea609d3357fb3de911f2f6a5e6856c151b976a
change-id: 20250117-b4-support-10de313f53b7

Best regards,

Signature · 1 line
Quentin Schulz <[email protected]>
#1 lore raw

PATCH v2 1/2 add basic b4 config file

From: Quentin Schulz <[email protected]>

b4[1] is a very nice tool for mail-based contribution. A config[2] file exists to set up a few defaults. We can use it to set the Cc recipients to always add, in our case the mailing list.

Because we do not have anything to check for now, disable needs-checking so patches can be sent without running b4 prep --check. The mid-term/long-term plan is to use patchtest locally.

Because we do not have any auto-to-cc support (and the implicit one using scripts/get_maintainer.pl cannot work for us), also disable needs-auto-to-cc so patches can be sent without running b4 prep --auto-to-cc.

[1] https://pypi.org/project/b4/
[2] https://b4.docs.kernel.org/en/latest/config.html

---
 .b4-config | 3 +++
 1 file changed, 3 insertions(+)
.b4-config new file +3 -0
new file mode 100644
index 0000000000000000000000000000000000000000..8ec5ddd91e1da05f27a53ff6f3d7351317461859
@@ -0,0 +1,3 @@
+[b4]
+  send-series-cc = [email protected]
+  prep-pre-flight-checks = disable-needs-auto-to-cc, disable-needs-checking
Signature · 1 line
2.48.1
#2 lore raw

Patchtest results for [PATCH v2 1/2] add basic b4 config file

Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information:

---
Testing patch /home/patchtest/share/mboxes/v2-1-2-add-basic-b4-config-file.patch

FAIL: test shortlog format: Commit shortlog (first line of commit message) should follow the format "<target>: <summary>" (test_mbox.TestMbox.test_shortlog_format)

PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: pretest src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.pretest_src_uri_left_files)
SKIP: test CVE check ignore: No modified recipes or older target branch, skipping test (test_metadata.TestMetadata.test_cve_check_ignore)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum modified not mentioned: No modified recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.test_src_uri_left_files)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!

#3 lore raw
In reply to Quentin Schulz

Hi all,

Quoted 29 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

b4[1] is a very nice tool for mail-based contribution. A config[2] file exists to set up a few defaults. We can use it to set the Cc recipients to always add, in our case the mailing list.

Because we do not have anything to check for now, disable needs-checking so patches can be sent without running b4 prep --check. The mid-term/long-term plan is to use patchtest locally.

Because we do not have any auto-to-cc support (and the implicit one using scripts/get_maintainer.pl cannot work for us), also disable needs-auto-to-cc so patches can be sent without running b4 prep --auto-to-cc.

[1] https://pypi.org/project/b4/
[2] https://b4.docs.kernel.org/en/latest/config.html

---
  .b4-config | 3 +++
  1 file changed, 3 insertions(+)
.b4-config new file +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..8ec5ddd91e1da05f27a53ff6f3d7351317461859

.b4-config line 2

Quoted 2 lines
.b4-config new file +2 -0
@@ -0,0 +1,3 @@
+[b4]
+  send-series-cc = [email protected]

Messed up here and should be send-series-to instead according to our README.md. Same remark applies to all other b4 patches sent to YP/OE. I'll leave a few more days for feedback and send a new version to tackle that oversight.

Cheers,
Quentin

#4 lore raw
Quoted 26 lines · Quentin Schulz via lists.openembedded.org

Hi all,

Quoted 23 lines · Quentin Schulz

From: Quentin Schulz <[email protected]>

b4[1] is a very nice tool for mail-based contribution. A config[2] file exists to set up a few defaults. We can use it to set the Cc recipients to always add, in our case the mailing list.

Because we do not have anything to check for now, disable needs-checking so patches can be sent without running b4 prep --check. The mid-term/long-term plan is to use patchtest locally.

Because we do not have any auto-to-cc support (and the implicit one using scripts/get_maintainer.pl cannot work for us), also disable needs-auto-to-cc so patches can be sent without running b4 prep --auto-to-cc.

[1] https://pypi.org/project/b4/
[2] https://b4.docs.kernel.org/en/latest/config.html

---
  .b4-config | 3 +++

  1 file changed, 3 insertions(+)
Quoted 13 lines

.b4-config line 2

Quoted 8 lines
.b4-config new file +2 -0
new file mode 100644
index 0000000000000000000000000000000000000000..8ec5ddd91e1da05f27a53ff6f3d7351317461859
@@ -0,0 +1,3 @@
+[b4]
+  send-series-cc = [email protected]

Messed up here and should be send-series-to instead according to our README.md. Same remark applies to all other b4 patches sent to YP/OE. I'll leave a few more days for feedback and send a new version to tackle that oversight.

I merged the script and was about to look at the config files (which need a little more work by tweaking combo-layer) but I'll hold off given the issue. I think we're ready to merge them...

Cheers,

Richard

#5 lore raw

PATCH v2 2/2 scripts: add b4-wrapper for poky

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

poky is a combo-layer containing BitBake, OpenEmbedded-Core and Yocto Documentation source code into one big repo. It is not uncommon to have people develop patches for either of those projects from a poky git repo.
However, it is unlikely those patches are to be sent to the poky mailing list as very few files contained in the poky git repo actually are poky-specific. So we need a way to identify to which mailing list a patch is destined to be sent.
Additionally, because the source code in openembedded-core is merged/imported at the root of the git repo of poky, its .b4-config introduced in the previous commit will be used if not overridden (which will be done in a separate commit specific to the poky git repo). We need to provide a different .b4-config in poky.

Therefore, this wrapper is used to identify automatically which mailing list a patch series needs to be sent to (via b4 prep --auto-to-cc) and does some additional checks (via b4 prep --check) such as making sure a patch doesn't modify two different projects at the same time or that multiple projects are modified by different patches in the same patch series.

This wrapper script is meant to be used by poky's .b4-config. Ideally the b4 prep --check part could be offloaded to patchtest once it supports running on source different from OE-Core.

---
 scripts/b4-wrapper-poky.py | 170 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 170 insertions(+)
scripts/b4-wrapper-poky.py new file +170 -0
new file mode 100755
index 0000000000000000000000000000000000000000..4fb9c08dc9d63bc2cbf28526e51ef9228648d11f
@@ -0,0 +1,170 @@
+#!/usr/bin/env python3
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+# This script is to be called by b4:
+# - through the b4.prep-perpatch-check-cmd with "prep-perpatch-check-cmd" as
+#   first argument,
+# - through b4.send-auto-cc-cmd with "send-auto-cc-cmd" as first argument,
+#
+# When prep-perpatch-check-cmd is passsed:
+#
+#  This checks that a patch makes changes to at most one project in the poky
+#  combo repo (that is, out of yocto-docs, bitbake, openembedded-core combined
+#  into poky and the poky-specific files).
+#
+#  Printing something to stdout in this file will result in b4 prep --check fail
+#  for the currently parsed patch.
+#
+#  It checks that all patches in the series make changes to at most one project.
+#
+# When send-auto-cc-cmd is passed:
+#
+#  This returns the list of Cc recipients for a patch.
+#
+# This script takes as stdin a patch.
+
+import pathlib
+import re
+import subprocess
+import sys
+
+cmd = sys.argv[1]
+
+patch = sys.stdin.readlines()
+
+# Subject field is used to identify the last patch as this script is called for
+# each patch. We edit the same file in a series by using the References field
+# unique identifier to check which projects are modified by earlier patches in
+# the series. To avoid cluttering the disk, the last patch in the list removes
+# that shared file.
+re_subject = re.compile(r'^Subject:.*\[.*PATCH.*\s(\d+)/\1')
+re_ref = re.compile(r'^References: <(.*)>$')
+
+subject = None
+ref = None
+
+if subprocess.call(["which", "lsdiff"], stdout=subprocess.DEVNULL) != 0:
+    print("lsdiff missing from host, please install patchutils")
+    sys.exit(-1)
+
+try:
+    one_patch_series = False
+    for line in patch:
+        subject = re_subject.match(line)
+        if subject:
+            # Handle [PATCH 1/1]
+            if subject.group(1) == 1:
+                one_patch_series = True
+            break
+        if re.match(r'^Subject: .*\[.*PATCH[^/]*\]', line):
+            # Single patch is named [PATCH] but if there are prefix, it could be
+            # [PATCH prefix], so handle everything that doesn't have a /
+            # character which is used as separator between current patch number
+            # and total patch number
+            one_patch_series = True
+            break
+
+    if cmd == "prep-perpatch-check-cmd" and not one_patch_series:
+        for line in patch:
+            ref = re_ref.match(line)
+            if ref:
+                break
+
+        if not ref:
+            print("Failed to find ref to cover letter (References:)...")
+            sys.exit(-2)
+
+        ref = ref.group(1)
+        series_check = pathlib.Path(f".tmp-{ref}")
+
+    patch = "".join(patch)
+
+    project_paths = {
+            "bitbake": ["bitbake/*"],
+            "yocto-docs": ["documentation/*"],
+            "poky": [
+                "meta-poky/*",
+                "meta-yocto-bsp/*",
+                "README.hardware.md",
+                "README.poky.md",
+                ],
+    }
+
+    if cmd == "send-auto-cc-cmd":
+        # Patches to BitBake documentation should also go to yocto-docs mailing list
+        project_paths["yocto-docs"] += ["bitbake/doc/*"]
+
+    # List of projects touched by this patch
+    projs = []
+
+    # Any file not matched by any path in project_paths means it is from
+    # OE-Core.
+    # When matching some path in project_paths, remove the matched files from
+    # that list.
+    files_left = subprocess.check_output(["lsdiff", "--strip-match=1", "--strip=1"],
+                                         input=patch, text=True)
+    files_left = set(files_left)
+
+    for proj, proj_paths in project_paths.items():
+        lsdiff_args = [f"--include={path}" for path in proj_paths]
+        files = subprocess.check_output(["lsdiff", "--strip-match=1", "--strip=1"] + lsdiff_args,
+                                        input=patch, text=True)
+        if len(files):
+            files_left = files_left - set(files)
+            projs.append(proj)
+            continue
+
+        # Handle patches made with --no-prefix
+        files = subprocess.check_output(["lsdiff"] + lsdiff_args,
+                                        input=patch, text=True)
+        if len(files):
+            files_left = files_left - set(files)
+            projs.append(proj)
+
+    # Catch-all for everything not poky-specific or in bitbake/yocto-docs
+    if len(files_left):
+        projs.append("openembedded-core")
+
+    if cmd == "prep-perpatch-check-cmd":
+        if len(projs) > 1:
+            print(f"Diff spans more than one project ({', '.join(sorted(projs))}), split into multiple commits...")
+            sys.exit(-3)
+
+        # No need to check other patches in the series as there aren't any
+        if one_patch_series:
+            sys.exit(0)
+
+        # This should be replaced once b4 supports prep-perseries-check-cmd (or something similar)
+
+        if series_check.exists():
+            # NOT race-free if b4 decides to parallelize prep-perpatch-check-cmd
+            series_projs = series_check.read_text().split('\n')
+        else:
+            series_projs = []
+
+        series_projs += projs
+        uniq_series_projs = set(series_projs)
+        # NOT race-free, if b4 decides to parallelize prep-perpatch-check-cmd
+        series_check.write_text('\n'.join(uniq_series_projs))
+
+        if len(uniq_series_projs) > 1:
+            print(f"Series spans more than one project ({', '.join(sorted(uniq_series_projs))}), split into multiple series...")
+            sys.exit(-4)
+    else:  # send-auto-cc-cmd
+        ml_projs = {
+            "bitbake": "[email protected]",
+            "yocto-docs": "[email protected]",
+            "poky": "[email protected]",
+            "openembedded-core": "[email protected]",
+        }
+
+        print("\n".join([ml_projs[ml] for ml in projs]))
+
+    sys.exit(0)
+finally:
+    # Last patch in the series, cleanup tmp file
+    if subject and ref and series_check.exists():
+        series_check.unlink()
Signature · 1 line
2.48.1
#6 lore raw
In reply to Quentin Schulz
Quoted 27 lines · Quentin Schulz via lists.openembedded.org

This adds very basic support for using b4 in OE-Core. This essentially just automatically adds the proper mailing list when running b4 prep --auto-to-cc.

This also adds the b4 wrapper script that poky will need to use in order to identify which mailing list a patch needs to be sent to and do some additional per-patch checks that aren't necessary when running from vanilla OE-Core.

Once this is merged, poky will need to merge OE-Core into itself and override with its own .b4-config that makes use of that script.

---
Changes in v2:
- add mention to first patch that running patchtest for b4 prep --check
is what we're eventually aiming for,
- add poky b4 wrapper script (it used to be in the patch series for
poky, c.f. https://lore.kernel.org/poky/[email protected]/T/#m95d6aa25cc42352416da477cf07d7b3cbd671231
- poky b4 wrapper script properly identifies patches with files modified
in both OE-Core and other repos part of poky,
- poky b4 wrapper script pretty prints when there's more than one
project modified by a script, instead of lazily printing a Python
list,
- Link to v1: https://lore.kernel.org/r/[email protected]

Quoted 7 lines

---
Quentin Schulz (2):
add basic b4 config file
scripts: add b4-wrapper for poky

 .b4-config                 |   3 +
 scripts/b4-wrapper-poky.py | 170 +++++++++++++++++++++++++++++++++++++++++++++

is there anything specific to poky in this script ? if not then it should not use that in name, it will
make it confusing. In oe-core we do not refer to particular distros if not needed.

Quoted 18 lines
 2 files changed, 173 insertions(+)

---
base-commit: 30ea609d3357fb3de911f2f6a5e6856c151b976a
change-id: 20250117-b4-support-10de313f53b7

Best regards,
--
Quentin Schulz <[email protected]>

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#210655): https://lists.openembedded.org/g/openembedded-core/message/210655
Mute This Topic: https://lists.openembedded.org/mt/110972445/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#7 lore raw

Hi Khem,

Quoted 34 lines · Khem Raj
Quoted 32 lines · Quentin Schulz via lists.openembedded.org

This adds very basic support for using b4 in OE-Core. This essentially just automatically adds the proper mailing list when running b4 prep --auto-to-cc.

This also adds the b4 wrapper script that poky will need to use in order to identify which mailing list a patch needs to be sent to and do some additional per-patch checks that aren't necessary when running from vanilla OE-Core.

Once this is merged, poky will need to merge OE-Core into itself and override with its own .b4-config that makes use of that script.

---
Changes in v2:
- add mention to first patch that running patchtest for b4 prep --check
is what we're eventually aiming for,
- add poky b4 wrapper script (it used to be in the patch series for
poky, c.f. https://lore.kernel.org/poky/[email protected]/T/#m95d6aa25cc42352416da477cf07d7b3cbd671231
- poky b4 wrapper script properly identifies patches with files modified
in both OE-Core and other repos part of poky,
- poky b4 wrapper script pretty prints when there's more than one
project modified by a script, instead of lazily printing a Python
list,
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Quentin Schulz (2):
add basic b4 config file
scripts: add b4-wrapper for poky

Quoted 5 lines
Quoted 2 lines
  .b4-config                 |   3 +
  scripts/b4-wrapper-poky.py | 170 +++++++++++++++++++++++++++++++++++++++++++++

is there anything specific to poky in this script ? if not then it should not use that in name, it will

Yes it is poky specific...

Quoted 3 lines

make it confusing. In oe-core we do not refer to particular distros if not needed.

...git-repo poky specific, not poky distro specific. Do you have something better to suggest than this?

Cheers,
Quentin

#8 lore raw
Quoted 41 lines · Quentin Schulz via lists.openembedded.org
Quoted 34 lines · Khem Raj
Quoted 32 lines · Quentin Schulz via lists.openembedded.org

This adds very basic support for using b4 in OE-Core. This essentially just automatically adds the proper mailing list when running b4 prep --auto-to-cc.

This also adds the b4 wrapper script that poky will need to use in order to identify which mailing list a patch needs to be sent to and do some additional per-patch checks that aren't necessary when running from vanilla OE-Core.

Once this is merged, poky will need to merge OE-Core into itself and override with its own .b4-config that makes use of that script.

---
Changes in v2:
- add mention to first patch that running patchtest for b4 prep --check
   is what we're eventually aiming for,
- add poky b4 wrapper script (it used to be in the patch series for
   poky, c.f. https://lore.kernel.org/poky/[email protected]/T/#m95d6aa25cc42352416da477cf07d7b3cbd671231
- poky b4 wrapper script properly identifies patches with files modified
   in both OE-Core and other repos part of poky,
- poky b4 wrapper script pretty prints when there's more than one
   project modified by a script, instead of lazily printing a Python
   list,
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Quentin Schulz (2):
       add basic b4 config file
       scripts: add b4-wrapper for poky

Quoted 5 lines
Quoted 2 lines

  .b4-config                 |   3 +
  scripts/b4-wrapper-poky.py | 170 +++++++++++++++++++++++++++++++++++++++++++++

is there anything specific to poky in this script ? if not then it should not use that in name, it will

Quoted 8 lines

Yes it is poky specific...

Quoted 3 lines

make it confusing. In oe-core we do not refer to particular distros if not needed.

...git-repo poky specific, not poky distro specific. Do you have something better to suggest than this?

To be clear, we could "bury" this b4 helper script in some other layer/place. I'm a bit reluctant to do it since I think there are things in here which may help anyone else trying to split a repo into multiple different submission locations, even just as a reference implementation. As such I did suggest it go into core, even if that looks slightly unusual.

As Quentin says, we're open to better ideas on naming but I do fairly strongly believe hiding it somewhere else will just confuse things.

Cheers,

Richard