<div dir="ltr">Sorry, I missed the new test when copying this from a poky checkout to a bitbake checkout to generate the patch. I&#39;ll send the test as a follow-up.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 9 Mar 2020 at 13:43, Paul Barker &lt;<a href="mailto:pbarker@konsulko.com">pbarker@konsulko.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">When a shallow mirror tarball is used to satisfy a gitsm URI it needs to<br>
be unpacked temporarily so that the .gitmodules file can be examined.<br>
<br>
Signed-off-by: Paul Barker &lt;<a href="mailto:pbarker@konsulko.com" target="_blank">pbarker@konsulko.com</a>&gt;<br>
---<br>
 lib/bb/fetch2/gitsm.py | 21 ++++++++++++++++-----<br>
 1 file changed, 16 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py<br>
index aa121cbe..e7083001 100644<br>
--- a/lib/bb/fetch2/gitsm.py<br>
+++ b/lib/bb/fetch2/gitsm.py<br>
@@ -20,6 +20,8 @@ NOTE: Switching a SRC_URI from &quot;git://&quot; to &quot;gitsm://&quot; requires a clean of your r<br>
 import os<br>
 import bb<br>
 import copy<br>
+import shutil<br>
+import tempfile<br>
 from   bb.fetch2.git import Git<br>
 from   bb.fetch2 import runfetchcmd<br>
 from   bb.fetch2 import logger<br>
@@ -130,7 +132,7 @@ class GitSM(Git):<br>
             ld.setVar(&#39;SRCPV&#39;, d.getVar(&#39;SRCPV&#39;))<br>
             ld.setVar(&#39;SRCREV_FORMAT&#39;, module)<br>
<br>
-            function(ud, url, module, paths[module], ld)<br>
+            function(ud, url, module, paths[module], workdir, ld)<br>
<br>
         return submodules != []<br>
<br>
@@ -152,7 +154,7 @@ class GitSM(Git):<br>
         return False<br>
<br>
     def download(self, ud, d):<br>
-        def download_submodule(ud, url, module, modpath, d):<br>
+        def download_submodule(ud, url, module, modpath, workdir, d):<br>
             url += &quot;;bareclone=1;nobranch=1&quot;<br>
<br>
             # Is the following still needed?<br>
@@ -163,16 +165,25 @@ class GitSM(Git):<br>
                 newfetch.download()<br>
                 # Drop a nugget to add each of the srcrevs we&#39;ve fetched (used by need_update)<br>
                 runfetchcmd(&quot;%s config --add bitbake.srcrev %s&quot; % \<br>
-                            (ud.basecmd, ud.revisions[ud.names[0]]), d, workdir=ud.clonedir)<br>
+                            (ud.basecmd, ud.revisions[ud.names[0]]), d, workdir=workdir)<br>
             except Exception as e:<br>
                 logger.error(&#39;gitsm: submodule download failed: %s %s&#39; % (type(e).__name__, str(e)))<br>
                 raise<br>
<br>
         Git.download(self, ud, d)<br>
-        self.process_submodules(ud, ud.clonedir, download_submodule, d)<br>
+<br>
+        # If we&#39;re using a shallow mirror tarball it needs to be unpacked<br>
+        # temporarily so that we can examine the .gitmodules file<br>
+        if ud.shallow and os.path.exists(ud.fullshallow) and self.need_update(ud, d):<br>
+            tmpdir = tempfile.mkdtemp(dir=d.getVar(&quot;DL_DIR&quot;))<br>
+            runfetchcmd(&quot;tar -xzf %s&quot; % ud.fullshallow, d, workdir=tmpdir)<br>
+            self.process_submodules(ud, tmpdir, download_submodule, d)<br>
+            shutil.rmtree(tmpdir)<br>
+        else:<br>
+            self.process_submodules(ud, ud.clonedir, download_submodule, d)<br>
<br>
     def unpack(self, ud, destdir, d):<br>
-        def unpack_submodules(ud, url, module, modpath, d):<br>
+        def unpack_submodules(ud, url, module, modpath, workdir, d):<br>
             url += &quot;;bareclone=1;nobranch=1&quot;<br>
<br>
             # Figure out where we clone over the bare submodules...<br>
-- <br>
2.20.1<br>
<br>
</blockquote></div>