diff mbox series

[10/15] fetch2: gitsm: add parentdir parameter

Message ID 20250902064515.30879-11-stefan.herbrechtsmeier-oss@weidmueller.com
State New
Headers show
Series fetch2: gitsm: rework and simplify | expand

Commit Message

Stefan Herbrechtsmeier Sept. 2, 2025, 6:45 a.m. UTC
From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Add a parentdir parameter to pass the destination directory of the
submodule parent to the submodule.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
---

 lib/bb/fetch2/gitsm.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py
index d013a09d6..c3e7189a0 100644
--- a/lib/bb/fetch2/gitsm.py
+++ b/lib/bb/fetch2/gitsm.py
@@ -127,6 +127,7 @@  class GitSM(Git):
             url += ";bareclone=1"
 
             parentdir = self.destdir(ud, '', d)
+            url += ";parentdir=%s" % parentdir
             gitdir = '' if ud.bareclone else '.git'
             subdir = os.path.join(parentdir, gitdir, 'modules', module)
             url += ";subdir=%s" % subdir
@@ -203,6 +204,9 @@  class GitSM(Git):
             try:
                 newfetch = Fetch([url], d, cache=False)
                 new_ud = newfetch.ud[url]
+                parentdir = new_ud.parm['parentdir']
+                if not os.path.isabs(parentdir):
+                    parentdir = os.path.join(destdir, parentdir)
                 fulldestdir = self.destdir(new_ud, destdir, d)
                 newfetch.unpack(root=destdir)
             except Exception as e:
@@ -212,10 +216,10 @@  class GitSM(Git):
             local_path = newfetch.localpath(url)
 
             # Correct the submodule references to the local download version...
-            runfetchcmd("%(basecmd)s config submodule.%(module)s.url %(url)s" % {'basecmd': ud.basecmd, 'module': module, 'url' : local_path}, d, workdir=subdestdir)
+            runfetchcmd("%(basecmd)s config submodule.%(module)s.url %(url)s" % {'basecmd': ud.basecmd, 'module': module, 'url' : local_path}, d, workdir=parentdir)
 
             if ud.shallow:
-                runfetchcmd("%(basecmd)s config submodule.%(module)s.shallow true" % {'basecmd': ud.basecmd, 'module': module}, d, workdir=subdestdir)
+                runfetchcmd("%(basecmd)s config submodule.%(module)s.shallow true" % {'basecmd': ud.basecmd, 'module': module}, d, workdir=parentdir)
 
             # Ensure the submodule repository is NOT set to bare, since we're checking it out...
             try: