fetch/gitsm: avoid live submodule fetching during unpack()
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.
Rev3 changes:
- Really fix the shallow-clone issue claimed to be addressed in rev2.
Rev2 changes:
- Fixed a failure when unpacking a shallow cloned mirror repository.
[YOCTO #12739]
--- lib/bb/fetch2/gitsm.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
lib/bb/fetch2/gitsm.py +27 -1
@@ -132,4 +132,30 @@ 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) + + updateflags = "" + + # Copy over the submodules' fetched histories too. + if ud.bareclone: + repo_conf = ud.destdir + else: + repo_conf = os.path.join(ud.destdir, '.git') + + if os.path.exists(ud.clonedir): + # This is not a copy unpacked from a shallow mirror clone. So + # the manual intervention to populate the .git/modules done + # in clone_shallow_local() won't have been done yet. + runfetchcmd("cp -pr %s %s" % (os.path.join(ud.clonedir, 'modules'), repo_conf), d) + updateflags += " --no-fetch" + elif os.path.exists(os.path.join(repo_conf, 'modules')): + # Unpacked from a shallow mirror clone. Manual population of + # .git/modules is already done. + updateflags += " --no-fetch" + else: + # This isn't fatal; git-submodule will just fetch it + # during do_unpack(). + bb.error("submodule history not retrieved during do_fetch()") + + # Careful not to hit the network during unpacking; all history should already + # be fetched. + runfetchcmd(ud.basecmd + " submodule update --init --recursive %s" % updateflags, d, workdir=ud.destdir)
Signature · 1 line
2.13.6
Quoted 17 lines
-----Original Message-----
From: [email protected] [mailto:bitbake- [email protected]] On Behalf Of Matt Hoosier
Sent: den 11 maj 2018 21:27
To: [email protected]
Subject: [bitbake-devel] [PATCH] fetch/gitsm: avoid live submodule fetching duringunpack()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.
Quoted 7 lines
Rev3 changes:
- Really fix the shallow-clone issue claimed to be addressed in rev2.
Rev2 changes:
- Fixed a failure when unpacking a shallow cloned mirror repository.
The Rev2 and Rev3 changes information should go below the --- below as it should not be part of the commit message as it relates to the patch submission process rather than the actual change. If any of it is relevant for the commit message, then the commit message should be changed as well.
Quoted 44 lines
[YOCTO #12739]
Signed-off-by Matt Hoosier <[email protected]>--- lib/bb/fetch2/gitsm.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)lib/bb/fetch2/gitsm.py +27
-2@@ -132,4 +132,30 @@ 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) + + updateflags = "" + + # Copy over the submodules' fetched histories too. + if ud.bareclone: + repo_conf = ud.destdir + else: + repo_conf = os.path.join(ud.destdir, '.git') + + if os.path.exists(ud.clonedir): + # This is not a copy unpacked from a shallow mirror clone. So + # the manual intervention to populate the .git/modules done + # in clone_shallow_local() won't have been done yet. + runfetchcmd("cp -pr %s %s" % (os.path.join(ud.clonedir, 'modules'), repo_conf), d) + updateflags += " --no-fetch" + elif os.path.exists(os.path.join(repo_conf, 'modules')): + # Unpacked from a shallow mirror clone. Manual population of + # .git/modules is already done. + updateflags += " --no-fetch" + else: + # This isn't fatal; git-submodule will just fetch it + # during do_unpack(). + bb.error("submodule history not retrieved during do_fetch()") + + # Careful not to hit the network during unpacking; all history should already + # be fetched. + runfetchcmd(ud.basecmd + " submodule update --init --recursive %s" % updateflags, d, workdir=ud.destdir) --
Quoted 1 line
2.13.6
//Peter
Quoted 23 lines · Peter Kjellerstedt
Quoted 23 lines
-----Original Message-----
From: [email protected] [mailto:bitbake- [email protected]] On Behalf Of Matt Hoosier
Sent: den 11 maj 2018 21:27
To: [email protected]
Subject: [bitbake-devel] [PATCH] fetch/gitsm: avoid live submodule fetching duringunpack()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.Rev3 changes:
- Really fix the shallow-clone issue claimed to be addressed in rev2.
Rev2 changes:
Quoted 8 lines
Quoted 1 line
- Fixed a failure when unpacking a shallow cloned mirror repository.
The Rev2 and Rev3 changes information should go below the --- below as it should not be part of the commit message as it relates to the patch submission process rather than the actual change. If any of it is relevant for the commit message, then the commit message should be changed as well.
Thanks; done. Resubmitted (as v4) to the list.
Quoted 59 lines
Quoted 13 lines
[YOCTO #12739]
Signed-off-by Matt Hoosier <[email protected]>--- lib/bb/fetch2/gitsm.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)lib/bb/fetch2/gitsm.py +0
-0lib/bb/fetch2/gitsm.py class GitSM(Git): · line 134
Quoted 3 lines
lib/bb/fetch2/gitsm.py +0
-0@@ -132,4 +132,30 @@ class GitSM(Git): if self.uses_submodules(ud, d, ud.destdir): runfetchcmd(ud.basecmd + " checkout " +ud.revisions[ud.names[0]], d, workdir=ud.destdir)
lib/bb/fetch2/gitsm.py class GitSM(Git): · line 135
Quoted 1 line
lib/bb/fetch2/gitsm.py +0
-1- runfetchcmd(ud.basecmd + " submodule update --init--recursive", d, workdir=ud.destdir)
lib/bb/fetch2/gitsm.py class GitSM(Git):
Quoted 11 lines
lib/bb/fetch2/gitsm.py +11
-0+ + updateflags = "" + + # Copy over the submodules' fetched histories too. + if ud.bareclone: + repo_conf = ud.destdir + else: + repo_conf = os.path.join(ud.destdir, '.git') + + if os.path.exists(ud.clonedir): + # This is not a copy unpacked from a shallow mirrorclone. So
lib/bb/fetch2/gitsm.py class GitSM(Git): · line 146
Quoted 1 line
lib/bb/fetch2/gitsm.py +1
-0+ # the manual intervention to populate the .git/modulesdone
lib/bb/fetch2/gitsm.py class GitSM(Git): · line 148
Quoted 2 lines
lib/bb/fetch2/gitsm.py +2
-0+ # in clone_shallow_local() won't have been done yet. + runfetchcmd("cp -pr %s %s" % (os.path.join(ud.clonedir,'modules'),
repo_conf), d)lib/bb/fetch2/gitsm.py class GitSM(Git):
Quoted 3 lines
lib/bb/fetch2/gitsm.py +3
-0+ updateflags += " --no-fetch" + elif os.path.exists(os.path.join(repo_conf, 'modules')): + # Unpacked from a shallow mirror clone. Manualpopulation of
lib/bb/fetch2/gitsm.py class GitSM(Git):
Quoted 6 lines
lib/bb/fetch2/gitsm.py +6
-0+ # .git/modules is already done. + updateflags += " --no-fetch" + else: + # This isn't fatal; git-submodule will just fetch it + # during do_unpack(). + bb.error("submodule history not retrieved during
do_fetch()")lib/bb/fetch2/gitsm.py class GitSM(Git): · line 159
Quoted 2 lines
lib/bb/fetch2/gitsm.py +2
-0+ + # Careful not to hit the network during unpacking; allhistory should already
lib/bb/fetch2/gitsm.py class GitSM(Git): · line 161
Quoted 2 lines
lib/bb/fetch2/gitsm.py +2
-0+ # be fetched. + runfetchcmd(ud.basecmd + " submodule update --init--recursive %s" % updateflags, d, workdir=ud.destdir)
Quoted 2 lines
--
2.13.6//Peter