oe.path.canonicalize() is used to canonicalize paths (i.e., remove symbolic links and "..", and make them absolute). It takes a string with paths separated by commas, and returns the canonicalized path in the same format.
Signed-off-by: Peter Kjellerstedt <peter.kjellerst...@axis.com> --- meta/lib/oe/path.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py index 082972457b..504342e267 100644 --- a/meta/lib/oe/path.py +++ b/meta/lib/oe/path.py @@ -320,3 +320,15 @@ def which_wild(pathname, path=None, mode=os.F_OK, *, reverse=False, candidates=F return files +def canonicalize(paths, sep=','): + """Given a string with paths (separated by commas by default), expand + each path using os.path.realpath() and return the resulting paths as a + string (separated using the same separator a the original string). + """ + # Ignore paths containing "$" as they are assumed to be unexpanded bitbake + # variables. Normally they would be ignored, e.g., when passing the paths + # through the shell they would expand to empty strings. However, when they + # are passed through os.path.realpath(), it will cause them to be prefixed + # with the absolute path to the current directory and thus not be empty + # anymore. + return sep.join(os.path.realpath(path) for path in (paths or '').split(sep) if "$" not in path)
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#145138): https://lists.openembedded.org/g/openembedded-core/message/145138 Mute This Topic: https://lists.openembedded.org/mt/78640450/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-