[PATCH] Bitbake: use LAYERDIR_RE when setting BBFILE_PATTERN_x

0 views
Skip to first unread message

Schwarz, Konrad

unread,
Jan 13, 2026, 4:27:39 AM (2 days ago) Jan 13
to isar-...@googlegroups.com, Schwarz, Konrad
From: Konrad Schwarz <konrad....@siemens.com>

The `BBFILE_PATTERN_x` variables are regular expressions.
Hence, regular expression special characters such as `.`
need to be protected if intended to be used literally.

Bitbake facilitates this by automatically poviding a variant of the
`LAYERDIR` variable, `LAYERDIR_RE`, in which all regex special characters
are escaped (and are thus interpreted as ordinary characters).
`LAYERDIR_RE` should be used instead of `LAYERDIR` in the value
of `BBFILE_PATTERN_x`.

The Bitbake User Manual consistenly uses `LAYERDIR_RE` when assigning
to `BBFILE_PATTERN_x`. see Chapters 7 [1], "Variables Glossary",
and 9.4 [2], "The Hello World Example".

[1]: https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-ref-variables.html#
[2]: https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-hello.html#the-hello-world-example

Note that this is a systematic mistake. Although
this patch addressse Isar, projects based on Isar
are likely to contain this mistake in their own layer configurations.

`BBFILE_PATTERN_x`/`LAYERDIR_RE` are the only
such pair in Bitbake documented in the user's manual;
the problem should not extend to other variable uses.

Signed-off-by: Konrad Schwarz <konrad....@siemens.com>
---
bitbake/lib/layerindexlib/tests/testdata/layer1/conf/layer.conf | 2 +-
bitbake/lib/layerindexlib/tests/testdata/layer2/conf/layer.conf | 2 +-
bitbake/lib/layerindexlib/tests/testdata/layer3/conf/layer.conf | 2 +-
bitbake/lib/layerindexlib/tests/testdata/layer4/conf/layer.conf | 2 +-
meta-isar/conf/layer.conf | 2 +-
meta-test/conf/layer.conf | 2 +-
meta/conf/layer.conf | 2 +-
testsuite/cibuilder.py | 2 +-
8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/bitbake/lib/layerindexlib/tests/testdata/layer1/conf/layer.conf b/bitbake/lib/layerindexlib/tests/testdata/layer1/conf/layer.conf
index 966d5319..c7a372d7 100644
--- a/bitbake/lib/layerindexlib/tests/testdata/layer1/conf/layer.conf
+++ b/bitbake/lib/layerindexlib/tests/testdata/layer1/conf/layer.conf
@@ -4,7 +4,7 @@ BBPATH .= ":${LAYERDIR}"
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb"

BBFILE_COLLECTIONS += "core"
-BBFILE_PATTERN_core = "^${LAYERDIR}/"
+BBFILE_PATTERN_core = "^${LAYERDIR_RE}/"
BBFILE_PRIORITY_core = "5"

LAYERSERIES_CORENAMES = "sumo"
diff --git a/bitbake/lib/layerindexlib/tests/testdata/layer2/conf/layer.conf b/bitbake/lib/layerindexlib/tests/testdata/layer2/conf/layer.conf
index 7569d1c2..dc9d36a6 100644
--- a/bitbake/lib/layerindexlib/tests/testdata/layer2/conf/layer.conf
+++ b/bitbake/lib/layerindexlib/tests/testdata/layer2/conf/layer.conf
@@ -6,7 +6,7 @@ BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "networking-layer"
-BBFILE_PATTERN_networking-layer := "^${LAYERDIR}/"
+BBFILE_PATTERN_networking-layer := "^${LAYERDIR_RE}/"
BBFILE_PRIORITY_networking-layer = "5"

# This should only be incremented on significant changes that will
diff --git a/bitbake/lib/layerindexlib/tests/testdata/layer3/conf/layer.conf b/bitbake/lib/layerindexlib/tests/testdata/layer3/conf/layer.conf
index 7089071f..54ddee90 100644
--- a/bitbake/lib/layerindexlib/tests/testdata/layer3/conf/layer.conf
+++ b/bitbake/lib/layerindexlib/tests/testdata/layer3/conf/layer.conf
@@ -5,7 +5,7 @@ BBPATH .= ":${LAYERDIR}"
BBFILES += "${LAYERDIR}/recipes*/*/*.bb ${LAYERDIR}/recipes*/*/*.bbappend"

BBFILE_COLLECTIONS += "meta-python"
-BBFILE_PATTERN_meta-python := "^${LAYERDIR}/"
+BBFILE_PATTERN_meta-python := "^${LAYERDIR_RE}/"
BBFILE_PRIORITY_meta-python = "7"

# This should only be incremented on significant changes that will
diff --git a/bitbake/lib/layerindexlib/tests/testdata/layer4/conf/layer.conf b/bitbake/lib/layerindexlib/tests/testdata/layer4/conf/layer.conf
index 6649ee02..4646c234 100644
--- a/bitbake/lib/layerindexlib/tests/testdata/layer4/conf/layer.conf
+++ b/bitbake/lib/layerindexlib/tests/testdata/layer4/conf/layer.conf
@@ -5,7 +5,7 @@ BBPATH .= ":${LAYERDIR}"
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "openembedded-layer"
-BBFILE_PATTERN_openembedded-layer := "^${LAYERDIR}/"
+BBFILE_PATTERN_openembedded-layer := "^${LAYERDIR_RE}/"

# Define the priority for recipes (.bb files) from this layer,
# choosing carefully how this layer interacts with all of the
diff --git a/meta-isar/conf/layer.conf b/meta-isar/conf/layer.conf
index 2209b18b..577f47b5 100644
--- a/meta-isar/conf/layer.conf
+++ b/meta-isar/conf/layer.conf
@@ -8,7 +8,7 @@ BBPATH .= ":${LAYERDIR}"
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "isar"
-BBFILE_PATTERN_isar = "^${LAYERDIR}/"
+BBFILE_PATTERN_isar = "^${LAYERDIR_RE}/"
BBFILE_PRIORITY_isar = "5"

# This should only be incremented on significant changes that will
diff --git a/meta-test/conf/layer.conf b/meta-test/conf/layer.conf
index 0f15119d..425e9251 100644
--- a/meta-test/conf/layer.conf
+++ b/meta-test/conf/layer.conf
@@ -8,7 +8,7 @@ BBPATH .= ":${LAYERDIR}"
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "test"
-BBFILE_PATTERN_test = "^${LAYERDIR}/"
+BBFILE_PATTERN_test = "^${LAYERDIR_RE}/"
BBFILE_PRIORITY_test = "10"

# This should only be incremented on significant changes that will
diff --git a/meta/conf/layer.conf b/meta/conf/layer.conf
index 15f01233..69225172 100644
--- a/meta/conf/layer.conf
+++ b/meta/conf/layer.conf
@@ -8,7 +8,7 @@ BBPATH .= ":${LAYERDIR}"
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "core"
-BBFILE_PATTERN_core = "^${LAYERDIR}/"
+BBFILE_PATTERN_core = "^${LAYERDIR_RE}/"
BBFILE_PRIORITY_core = "5"

LAYERSERIES_CORENAMES = "v0.6 next"
diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index 366f6a1f..80f9362e 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -362,7 +362,7 @@ class CIBuilder(Test):
'BBPATH .= ":${LAYERDIR}"\n'
'BBFILES += "${LAYERDIR}/recipes-*/*/*.bbappend"\n'
'BBFILE_COLLECTIONS += "tmp"\n'
- 'BBFILE_PATTERN_tmp = "^${LAYERDIR}/"\n'
+ 'BBFILE_PATTERN_tmp = "^${LAYERDIR_RE}/"\n'
'BBFILE_PRIORITY_tmp = "5"\n'
'LAYERVERSION_tmp = "1"\n'
'LAYERSERIES_COMPAT_tmp = "v0.6"\n'
--
2.39.5

MOESSBAUER, Felix

unread,
Jan 13, 2026, 7:06:03 AM (2 days ago) Jan 13
to Schwarz, Konrad, isar-...@googlegroups.com
On Mon, 2026-01-12 at 16:06 +0000, 'Schwarz, Konrad' via isar-users
wrote:
> From: Konrad Schwarz <konrad....@siemens.com>
>
> The `BBFILE_PATTERN_x` variables are regular expressions.
> Hence, regular expression special characters such as `.`
> need to be protected if intended to be used literally.

Good catch! While it is quite unlikely that users run into the bug
(e.g. by having meta.foo and meta-foo), it still should be fixed.

Reviewed-by: Felix Moessbauer <felix.mo...@siemens.com>

Felix
> --
> You received this message because you are subscribed to the Google Groups "isar-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/isar-users/20260112160613.40413-1-konrad.schwarz%40siemens.com.

--
Siemens AG
Linux Expert Center
Friedrich-Ludwig-Bauer-Str. 3
85748 Garching, Germany

Reply all
Reply to author
Forward
0 new messages