All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trevor Woerner <twoerner@gmail.com>
To: yocto-patches@lists.yoctoproject.org
Subject: [wic][PATCH 3/4] oe/path: canonicalize('') should return '' rather than the cwd
Date: Thu,  9 Jul 2026 16:52:26 -0400	[thread overview]
Message-ID: <20260709205227.3470712-4-twoerner@gmail.com> (raw)
In-Reply-To: <20260709205227.3470712-1-twoerner@gmail.com>

canonicalize() splits its input on the separator and, for every token
that does not contain an unexpanded bitbake variable, appends
os.path.realpath(path). It never guarded against an empty token, and
os.path.realpath('') returns the current working directory. So
canonicalize('') and canonicalize(None) produced the cwd instead of an
empty result, and a stray separator such as 'a,,b' injected a spurious
cwd entry between the real paths.

Skip empty tokens alongside the '$' tokens the loop already skips, so
empty input canonicalizes to '' and redundant separators no longer
introduce phantom cwd entries.

AI-Generated: codex/claude-opus 4.8 (xhigh)
Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
 src/wic/oe/path.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/wic/oe/path.py b/src/wic/oe/path.py
index 13c52b363694..95bb9648fab6 100644
--- a/src/wic/oe/path.py
+++ b/src/wic/oe/path.py
@@ -355,7 +355,11 @@ def canonicalize(paths, sep=','):
     # prefixes in sting compares later on, where the slashes then are important.
     canonical_paths = []
     for path in (paths or '').split(sep):
-        if '$' not in path:
+        # Skip empty tokens as well as unexpanded bitbake variables: an
+        # empty path would otherwise reach os.path.realpath(''), which
+        # returns the current working directory, so canonicalize('') or
+        # canonicalize(None) would wrongly produce the cwd instead of ''.
+        if path and '$' not in path:
             trailing_slash = path.endswith('/') and '/' or ''
             canonical_paths.append(os.path.realpath(path) + trailing_slash)
 
-- 
2.50.0.173.g8b6f19ccfc3a



  parent reply	other threads:[~2026-07-09 20:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 20:52 [wic][PATCH 0/4] oe/path: three fixes plus unit coverage Trevor Woerner
2026-07-09 20:52 ` [wic][PATCH 1/4] oe/path: fix bare `false` NameError in __realpath's isdir guard Trevor Woerner
2026-07-09 20:52 ` [wic][PATCH 2/4] oe/path: don't glob-expand the destination in symlink(force=True) Trevor Woerner
2026-07-09 20:52 ` Trevor Woerner [this message]
2026-07-09 20:52 ` [wic][PATCH 4/4] tests/unit/test_oe_path: cover oe/path's own path logic Trevor Woerner

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=20260709205227.3470712-4-twoerner@gmail.com \
    --to=twoerner@gmail.com \
    --cc=yocto-patches@lists.yoctoproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.