Skip to contentSkip to conversation

fetch2/gitsm: Fix when repository change submodules

PATCH In review Felipe F. Tonello 2 participants 3 messages Feb 3, 2016 – Jul 24, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch2/gitsm: Fix when repository change submodules

This fix a problem when checking out a commit that changes the submodules previously checkout.

Example:
Recipe uses branch A and then it updates to use branch B, but branch B has different submodules dependencies then what branch A previously had.

---
 lib/bb/fetch2/gitsm.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/fetch2/gitsm.py +1 -1
index 0392e48d1aa0..2ecea7c7ed60 100644
@@ -131,7 +131,7 @@ class GitSM(Git):
         os.chdir(ud.destdir)
         submodules = self.uses_submodules(ud, d)
         if submodules:
-            runfetchcmd("cp -r " + ud.clonedir + "/modules " + ud.destdir + "/.git/", d)
+            runfetchcmd(ud.basecmd + " checkout " + ud.revisions[ud.names[0]], d)
             runfetchcmd(ud.basecmd + " submodule init", d)
             runfetchcmd(ud.basecmd + " submodule update", d)
 
Signature · 1 line
2.7.0
#1 lore raw
Quoted 9 lines · Felipe F. Tonello

This fix a problem when checking out a commit that changes the submodules previously checkout.

Example:
Recipe uses branch A and then it updates to use branch B, but branch B has different submodules dependencies then what branch A previously had.

This completely broke the gitsm fetcher behavior. It no longer uses the previously fetched submodules from DL_DIR at all, instead the submodule update is re-cloning them from upstream in do_unpack, violating our conventions. Git checkout isn’t going to magically copy the existing fetched submodules from DL_DIR.

Signature · 4 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics
#2 lore raw
Quoted 10 lines · Christopher Larson
Quoted 7 lines · Felipe F. Tonello

This fix a problem when checking out a commit that changes the submodules previously checkout.

Example:
Recipe uses branch A and then it updates to use branch B, but branch B has different submodules dependencies then what branch A previously had.

Quoted 9 lines
Quoted 2 lines

This completely broke the gitsm fetcher behavior. It no longer uses the previously fetched submodules from DL_DIR at all, instead the submodule update is re-cloning them from upstream in do_unpack, violating our conventions. Git checkout isn’t going to magically copy the existing fetched submodules from DL_DIR.

Apologies for the harsh tone here, but clearly we should fix this differently. https://bugzilla.yoctoproject.org/show_bug.cgi?id=11830 has been opened for this. It’ll be difficult to add a good unit test to catch this problem without using either a VM or containers to physically cut network connectivity. I’m going to propose a future bitbake enhancement to use namespaces to prevent network connectivity from non-fetch tasks.

Signature · 4 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics