Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 1/3] gitsm.py: use download cache for git submodules too
@ 2017-09-06 11:08 Mikko Rapeli
  2017-09-06 11:08 ` [PATCH 2/3] gitsm.py: support BB_NO_NETWORK during do_unpack Mikko Rapeli
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Mikko Rapeli @ 2017-09-06 11:08 UTC (permalink / raw)
  To: openembedded-core

Currently download caches for recipes using gitsm are filled also with
the submodule repositories but when the git submodule tree is reused from
cache, only the base repository is cloned. After a source URL rewrite,
'git submodule update --init --recursive' is called in the tree
which downloads the needed submodules from upstream URL's.
This wastes bandwidth since download cache already had the needed
commits for the submodule repositories.

With this change, also the submodule repositories are copied to the
work space from download cache and the download from upstream can
be avoided. Using plain 'cp -a' since git cloning doesn't work for the
submodule directories.

Note that using BB_NO_NETWORK does not stop the submodule downloads
from 'git submodule update --init --recursive'. Thus tested by
breaking access to remote repository via /etc/hosts line like:

127.0.0.1       localhost github.com

Signed-off-by: Mikko Rapeli <mikko.rapeli@bmw.de>
---
 bitbake/lib/bb/fetch2/gitsm.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index 0aff100..20a9c40 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -131,5 +131,13 @@ class GitSM(Git):
         Git.unpack(self, ud, destdir, d)
 
         if self.uses_submodules(ud, d, ud.destdir):
+            # Copy also submodule trees from download cache instead of
+            # downloading again from the upstream repository.
+            # For some reason git does not clone them.
+            clone_modules = os.path.join(ud.clonedir, "modules")
+            if os.path.exists(clone_modules):
+                dest_modules = os.path.join(ud.destdir, ".git")
+                runfetchcmd("cp -a " + clone_modules + " " + dest_modules, d)
+
             runfetchcmd(ud.basecmd + " checkout " + ud.revisions[ud.names[0]], d, workdir=ud.destdir)
             runfetchcmd(ud.basecmd + " submodule update --init --recursive", d, workdir=ud.destdir)
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-09-06 12:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-06 11:08 [PATCH 1/3] gitsm.py: use download cache for git submodules too Mikko Rapeli
2017-09-06 11:08 ` [PATCH 2/3] gitsm.py: support BB_NO_NETWORK during do_unpack Mikko Rapeli
2017-09-06 11:08 ` [PATCH 3/3] cve-check-tool: change BB_NO_NETWORK error to a warning Mikko Rapeli
2017-09-06 11:34 ` ✗ patchtest: failure for "gitsm.py: use download cache f..." and 2 more Patchwork
2017-09-06 12:14   ` Mikko.Rapeli
2017-09-06 12:22     ` Mikko.Rapeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox