The documentation states that includes with an absolute path are
supported. However, the check was implemented incorrectly as it assumed
an absolute path starts with ':' (os.path.pathsep) instead of '/'
(os.path.sep). As nobody ever complained about this, we just drop
support for including files via an absolute path.
Fixes: 34dd07e76 ("added initial implementation of a include handler")
Reported-by: Keyvan Hardani <
keyvan....@ieee.org>
Note, that the diff is strangely mangled. The patch actually removes
the "if include.startswith(os.path.pathsep):" which always was False
and unindents the else block below.
docs/userguide/project-configuration.rst | 10 ++-----
kas/includehandler.py | 36 +++++++++++-------------
2 files changed, 19 insertions(+), 27 deletions(-)
diff --git a/docs/userguide/project-configuration.rst b/docs/userguide/project-configuration.rst
index bbb107d70..8a6162fbd 100644
--- a/docs/userguide/project-configuration.rst
+++ b/docs/userguide/project-configuration.rst
@@ -87,13 +87,9 @@ repository/layer like this:
- bsp.yml
- product.yml
-The paths to the files in the include list are either absolute, if they start
-with a `/`, or relative.
-
-If the path is relative and the configuration file is inside a repository,
-then path is relative to the repositories base directory. If the
-configuration file is not in a repository, then the path is relative to the
-parent directory of the file.
+If the configuration file is inside a repository, then path is relative to
+the repositories base directory. If the configuration file is not in a
+repository, then the path is relative to the parent directory of the file.
Including configuration files from other repos
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/kas/includehandler.py b/kas/includehandler.py
index 8a8b05cfc..804271d09 100644
--- a/kas/includehandler.py
+++ b/kas/includehandler.py
@@ -282,27 +282,23 @@ class IncludeHandler:
for include in header.get('includes', []):
if isinstance(include, str):
- includefile = ''
- if include.startswith(os.path.pathsep):
- includefile = include
- else:
- includefile = os.path.abspath(
- os.path.join(repo_path, include))
- if not os.path.exists(includefile):
- alternate = os.path.abspath(
- os.path.join(
- os.path.dirname(current_config.filename),
- include
- )
+ includefile = os.path.abspath(
+ os.path.join(repo_path, include))
+ if not os.path.exists(includefile):
+ alternate = os.path.abspath(
+ os.path.join(
+ os.path.dirname(current_config.filename),
+ include
)
- if os.path.exists(alternate):
- logging.warning(
- 'Falling back to file-relative addressing '
- 'of local include "%s"', include)
- logging.warning(
- 'Update your layer to repo-relative '
- 'addressing to avoid this warning')
- includefile = alternate
+ )
+ if os.path.exists(alternate):
+ logging.warning(
+ 'Falling back to file-relative addressing '
+ 'of local include "%s"', include)
+ logging.warning(
+ 'Update your layer to repo-relative '
+ 'addressing to avoid this warning')
+ includefile = alternate
(cfg, rep) = _internal_include_handler(
includefile,
repo_path,
--
2.53.0