From 1f82ca67131694e2c85aeb15629ceb97e0bb9df4 Mon Sep 17 00:00:00 2001 From: Mark Hatle Date: Wed, 15 May 2019 07:53:20 -0400 Subject: bitbake: gitsm: Fix a bug where the wrong path was used for the submodule init Because we are trying to avoid network activity and use our own fetcher, the system emulates the behavior of 'git submodule init'. git submodule init uses the .gitmodules file, where typically the module name and path are the same. However, in this case the module name and path (in the tree) were different. i.e.: [submodule "edgelet/hsm-sys/azure-iot-hsm-c/deps/azure-c-shared-utility"] path = edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared url = https://github.com/Azure/azure-c-shared-utility.git Previously the code assumed the 'path' was both the checkout location under .git/modules, as well as the path to extract the components. This proved to be incorrect as the .git/modules path needs to match the submodule 'name'. This causes the components that were fetched to be initialized in the wrong location, which later caused the 'git submodule update' process to skip not properly initialized modules. A test case was added for this specific case to ensure a regression does not appear in the future. (Bitbake rev: ffd7ed530a17d22df576d986ac78428a6979e79c) Signed-off-by: Mark Hatle Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/gitsm.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'bitbake/lib/bb/fetch2/gitsm.py') diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py index b21fed2669..54f99b1036 100644 --- a/bitbake/lib/bb/fetch2/gitsm.py +++ b/bitbake/lib/bb/fetch2/gitsm.py @@ -129,7 +129,7 @@ class GitSM(Git): url += ';protocol=%s' % proto url += ";name=%s" % module - url += ";subpath=%s" % paths[module] + url += ";subpath=%s" % module ld = d.createCopy() # Not necessary to set SRC_URI, since we're passing the URI to @@ -176,7 +176,7 @@ class GitSM(Git): try: newfetch = Fetch([url], d, cache=False) - newfetch.unpack(root=os.path.dirname(os.path.join(repo_conf, 'modules', modpath))) + newfetch.unpack(root=os.path.dirname(os.path.join(repo_conf, 'modules', module))) except Exception as e: logger.error('gitsm: submodule unpack failed: %s %s' % (type(e).__name__, str(e))) raise @@ -191,9 +191,9 @@ class GitSM(Git): # Ensure the submodule repository is NOT set to bare, since we're checking it out... try: - runfetchcmd("%s config core.bare false" % (ud.basecmd), d, quiet=True, workdir=os.path.join(repo_conf, 'modules', modpath)) + runfetchcmd("%s config core.bare false" % (ud.basecmd), d, quiet=True, workdir=os.path.join(repo_conf, 'modules', module)) except: - logger.error("Unable to set git config core.bare to false for %s" % os.path.join(repo_conf, 'modules', modpath)) + logger.error("Unable to set git config core.bare to false for %s" % os.path.join(repo_conf, 'modules', module)) raise Git.unpack(self, ud, destdir, d) @@ -201,5 +201,7 @@ class GitSM(Git): ret = self.process_submodules(ud, ud.destdir, unpack_submodules, d) if not ud.bareclone and ret: - # Run submodule update, this sets up the directories -- without touching the config + # All submodules should already be downloaded and configured in the tree. This simply sets + # up the configuration and checks out the files. The main project config should remain + # unmodified, and no download from the internet should occur. runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir) -- cgit v1.2.3-54-g00ecf