From: Zk47T <zizuzacker@gmail.com>
To: bitbake-devel@lists.openembedded.org
Cc: Zk47T <zizuzacker@gmail.com>
Subject: [PATCH] bitbake: Resolve symlink duplicates in layer paths
Date: Fri, 3 Apr 2026 22:33:27 +0700 [thread overview]
Message-ID: <20260403153327.64044-1-zizuzacker@gmail.com> (raw)
When BBLAYERS contains two paths pointing to the same directory via
symlinks, bitbake incorrectly reports duplicated BBFILE_COLLECTIONS.
Use os.path.realpath() to resolve symlinks before comparing layer
paths, and emit a warning instead of a fatal error.
Fixes [YOCTO #15591]
Signed-off-by: Zk47T <zizuzacker@gmail.com>
---
bitbake/lib/bb/cookerdata.py | 14 ++++++++++++++
bitbake/lib/bb/utils.py | 3 +++
bitbake/lib/bblayers/action.py | 2 +-
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
index 0649e40995..823da5f4c4 100644
--- a/bitbake/lib/bb/cookerdata.py
+++ b/bitbake/lib/bb/cookerdata.py
@@ -370,6 +370,20 @@ class CookerDataBuilder(object):
data = bb.data.createCopy(data)
approved = bb.utils.approved_variables()
+ # Resolve symlinks in layer paths so that layers referenced
+ # via different paths (e.g. symlinks) are not treated as
+ # duplicates (see Bug 15591)
+ resolved_layers = []
+ seen_real = set()
+ for layer in layers:
+ real = os.path.realpath(layer)
+ if real not in seen_real:
+ seen_real.add(real)
+ resolved_layers.append(layer)
+ else:
+ parselog.warning("Ignoring duplicate layer entry %s (resolves to %s which is already in BBLAYERS)", layer, real)
+ layers = resolved_layers
+
# Check whether present layer directories exist
for layer in layers:
if not os.path.isdir(layer):
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 1b4fb93a30..1972c9864a 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -1441,6 +1441,9 @@ def edit_bblayers_conf(bblayers_conf, add, remove, edit_cb=None):
pth = remove_trailing_sep(pth)
if 'HOME' in approved and '~' in pth:
pth = os.path.expanduser(pth)
+ # Resolve symlinks for real paths, but not for glob patterns
+ if '*' not in pth and '?' not in pth:
+ pth = os.path.realpath(pth)
return pth
def layerlist_param(value):
diff --git a/bitbake/lib/bblayers/action.py b/bitbake/lib/bblayers/action.py
index a8f2699335..11cca74eb3 100644
--- a/bitbake/lib/bblayers/action.py
+++ b/bitbake/lib/bblayers/action.py
@@ -26,7 +26,7 @@ def plugin_init(plugins):
class ActionPlugin(LayerPlugin):
def do_add_layer(self, args):
"""Add one or more layers to bblayers.conf."""
- layerdirs = [os.path.abspath(ldir) for ldir in args.layerdir]
+ layerdirs = [os.path.realpath(ldir) for ldir in args.layerdir]
for layerdir in layerdirs:
if not os.path.exists(layerdir):
--
2.34.1
next reply other threads:[~2026-04-03 15:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 15:33 Zk47T [this message]
2026-04-04 20:58 ` [bitbake-devel] [PATCH] bitbake: Resolve symlink duplicates in layer paths Richard Purdie
2026-04-05 5:29 ` Zk47T
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260403153327.64044-1-zizuzacker@gmail.com \
--to=zizuzacker@gmail.com \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox