diff mbox series

[wic,8/9] ksparser.py: search for *inc files

Message ID 20260403183644.2783267-9-twoerner@gmail.com
State New
Headers show
Series standalone wic repository | expand

Commit Message

Trevor Woerner April 3, 2026, 6:36 p.m. UTC
If a *wks file has an "include" directive, try looking for the include
file at the path where the *wks file was found.

NOTE: this commit does not work as-is, but is being provided in order to
      explicitly show a clean transition from oe-core

AI-Generated: codex/gpt-5.4 (high)
Reviewed-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Reviewed-by: Mark Hatle <mark.hatle@kernel.crashing.org>
Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
 src/wic/ksparser.py | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/wic/ksparser.py b/src/wic/ksparser.py
index 4ccd70dc555a..8e5fbfadd81f 100644
--- a/src/wic/ksparser.py
+++ b/src/wic/ksparser.py
@@ -101,6 +101,15 @@  def overheadtype(arg):
 
     return result
 
+def resolve_canned_path(arg, current_confpath=None):
+    if current_confpath:
+        current_dir = os.path.dirname(os.path.abspath(current_confpath))
+        relative_path = os.path.join(current_dir, arg)
+        if os.path.exists(relative_path):
+            return relative_path
+
+    return None
+
 def cannedpathtype(arg):
     """
     Custom type for ArgumentParser
@@ -202,7 +211,7 @@  class KickStart():
         bootloader.add_argument('--source')
 
         include = subparsers.add_parser('include')
-        include.add_argument('path', type=cannedpathtype)
+        include.add_argument('path')
 
         self._parse(parser, confpath)
         if not self.bootloader:
@@ -289,7 +298,12 @@  class KickStart():
                         self.partnum += 1
                         self.partitions.append(Partition(parsed, self.partnum))
                     elif line.startswith('include'):
-                        self._parse(parser, parsed.path)
+                        include_path = resolve_canned_path(parsed.path, confpath)
+                        if not include_path:
+                            err = "%s:%d: argument path: file not found: %s" % \
+                                  (confpath, lineno, parsed.path)
+                            raise KickStartError(err)
+                        self._parse(parser, include_path)
                     elif line.startswith('bootloader'):
                         if not self.bootloader:
                             self.bootloader = parsed