Skip to contentSkip to conversation

fetch/gitsm: avoid live submodule fetching during unpack()

PATCH In review Matt Hoosier 1 participant 2 messages May 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch/gitsm: avoid live submodule fetching during unpack()

Although the submodules' histories have been fetched during the do_fetch() phase, the mechanics used to clone the workdir copy of the repo haven't been transferring the actual .git/modules directory from the repo fetched into downloads/ during the fetch task.

Fix that, and for good measure also explicitly tell Git to avoid hitting the network during do_unpack() of the submodules.

Rev2 changes:

- Fixed a failure when unpacking a shallow cloned mirror repository.

[YOCTO #12739]

---
 lib/bb/fetch2/gitsm.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
lib/bb/fetch2/gitsm.py +11 -1
index 0aff1008..1f3fc443 100644
@@ -132,4 +132,14 @@ class GitSM(Git):
 
         if self.uses_submodules(ud, d, ud.destdir):
             runfetchcmd(ud.basecmd + " checkout " + ud.revisions[ud.names[0]], d, workdir=ud.destdir)
-            runfetchcmd(ud.basecmd + " submodule update --init --recursive", d, workdir=ud.destdir)
+
+            # Copy over the submodules' fetched histories too.
+            if ud.bareclone:
+                repo_conf = ud.destdir
+            else:
+                repo_conf = os.path.join(ud.destdir, '.git')
+            runfetchcmd("cp -pr %s %s" % (os.path.join(ud.clonedir, 'modules'), repo_conf), d)
+
+            # Careful not to hit the network during unpacking; all history should already
+            # be fetched.
+            runfetchcmd(ud.basecmd + " submodule update --init --recursive --no-fetch", d, workdir=ud.destdir)
Signature · 1 line
2.13.6
#1 lore raw

I had a snafu when prepping the submission of this revision. Ignore it; I've submitted rev3 now:
http://lists.openembedded.org/pipermail/bitbake-devel/2018-May/009325.html.

Quoted 49 lines · Matt Hoosier

Although the submodules' histories have been fetched during the do_fetch() phase, the mechanics used to clone the workdir copy of the repo haven't been transferring the actual .git/modules directory from the repo fetched into downloads/ during the fetch task.

Fix that, and for good measure also explicitly tell Git to avoid hitting the network during do_unpack() of the submodules.

Rev2 changes:

- Fixed a failure when unpacking a shallow cloned mirror repository.

[YOCTO #12739]

---
 lib/bb/fetch2/gitsm.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
lib/bb/fetch2/gitsm.py +7 -2
index 0aff1008..1f3fc443 100644
@@ -132,4 +132,14 @@ class GitSM(Git):
 
         if self.uses_submodules(ud, d, ud.destdir):
             runfetchcmd(ud.basecmd + " checkout " +
 ud.revisions[ud.names[0]], d, workdir=ud.destdir)
-            runfetchcmd(ud.basecmd + " submodule update --init
--recursive", d, workdir=ud.destdir)
+
+            # Copy over the submodules' fetched histories too.
+            if ud.bareclone:
+                repo_conf = ud.destdir
+            else:
+                repo_conf = os.path.join(ud.destdir, '.git')
+            runfetchcmd("cp -pr %s %s" % (os.path.join(ud.clonedir,

'modules'), repo_conf), d)

lib/bb/fetch2/gitsm.py +2 -0
+
+            # Careful not to hit the network during unpacking; all

history should already

lib/bb/fetch2/gitsm.py +2 -2
+            # be fetched.
+            runfetchcmd(ud.basecmd + " submodule update --init
--recursive --no-fetch", d, workdir=ud.destdir)
--

2.13.6