summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2019-05-15 07:53:20 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-05-16 09:17:15 +0100
commit7a73a435e086df39b0a241250bed35c29e0e5a00 (patch)
treee35bcf933871a31f430ac51039b66880c12cef20 /bitbake
parentd3abad15046e4e5d8aeefa529e6e101ed4e95137 (diff)
downloadpoky-7a73a435e086df39b0a241250bed35c29e0e5a00.tar.gz
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: fd27ab60d33553dba13de39394edaaac04e446b3) Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/gitsm.py12
-rw-r--r--bitbake/lib/bb/tests/fetch.py27
2 files changed, 34 insertions, 5 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index 1f03ba7a0d..c622771d21 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -117,7 +117,7 @@ class GitSM(Git):
117 117
118 url += ';protocol=%s' % proto 118 url += ';protocol=%s' % proto
119 url += ";name=%s" % module 119 url += ";name=%s" % module
120 url += ";subpath=%s" % paths[module] 120 url += ";subpath=%s" % module
121 121
122 ld = d.createCopy() 122 ld = d.createCopy()
123 # Not necessary to set SRC_URI, since we're passing the URI to 123 # Not necessary to set SRC_URI, since we're passing the URI to
@@ -184,7 +184,7 @@ class GitSM(Git):
184 184
185 try: 185 try:
186 newfetch = Fetch([url], d, cache=False) 186 newfetch = Fetch([url], d, cache=False)
187 newfetch.unpack(root=os.path.dirname(os.path.join(repo_conf, 'modules', modpath))) 187 newfetch.unpack(root=os.path.dirname(os.path.join(repo_conf, 'modules', module)))
188 except Exception as e: 188 except Exception as e:
189 logger.error('gitsm: submodule unpack failed: %s %s' % (type(e).__name__, str(e))) 189 logger.error('gitsm: submodule unpack failed: %s %s' % (type(e).__name__, str(e)))
190 raise 190 raise
@@ -199,9 +199,9 @@ class GitSM(Git):
199 199
200 # Ensure the submodule repository is NOT set to bare, since we're checking it out... 200 # Ensure the submodule repository is NOT set to bare, since we're checking it out...
201 try: 201 try:
202 runfetchcmd("%s config core.bare false" % (ud.basecmd), d, quiet=True, workdir=os.path.join(repo_conf, 'modules', modpath)) 202 runfetchcmd("%s config core.bare false" % (ud.basecmd), d, quiet=True, workdir=os.path.join(repo_conf, 'modules', module))
203 except: 203 except:
204 logger.error("Unable to set git config core.bare to false for %s" % os.path.join(repo_conf, 'modules', modpath)) 204 logger.error("Unable to set git config core.bare to false for %s" % os.path.join(repo_conf, 'modules', module))
205 raise 205 raise
206 206
207 Git.unpack(self, ud, destdir, d) 207 Git.unpack(self, ud, destdir, d)
@@ -209,5 +209,7 @@ class GitSM(Git):
209 ret = self.process_submodules(ud, ud.destdir, unpack_submodules, d) 209 ret = self.process_submodules(ud, ud.destdir, unpack_submodules, d)
210 210
211 if not ud.bareclone and ret: 211 if not ud.bareclone and ret:
212 # Run submodule update, this sets up the directories -- without touching the config 212 # All submodules should already be downloaded and configured in the tree. This simply sets
213 # up the configuration and checks out the files. The main project config should remain
214 # unmodified, and no download from the internet should occur.
213 runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir) 215 runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir)
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 97656dff63..6bdf0416d7 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -964,6 +964,33 @@ class FetcherNetworkTest(FetcherTest):
964 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/third_party/googletest/config')), msg='Missing submodule config "third_party/googletest/config"') 964 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/third_party/googletest/config')), msg='Missing submodule config "third_party/googletest/config"')
965 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/third_party/HdrHistogram_c/config')), msg='Missing submodule config "third_party/HdrHistogram_c/config"') 965 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/third_party/HdrHistogram_c/config')), msg='Missing submodule config "third_party/HdrHistogram_c/config"')
966 966
967 def test_git_submodule_iotedge(self):
968 """ Prevent regression on deeply nested submodules not being checked out properly, even though they were fetched. """
969
970 # This repository also has submodules where the module (name), path and url do not align
971 url = "gitsm://github.com/azure/iotedge.git;protocol=git;rev=d76e0316c6f324345d77c48a83ce836d09392699"
972 fetcher = bb.fetch.Fetch([url], self.d)
973 fetcher.download()
974 # Previous cwd has been deleted
975 os.chdir(os.path.dirname(self.unpackdir))
976 fetcher.unpack(self.unpackdir)
977
978 repo_path = os.path.join(self.tempdir, 'unpacked', 'git')
979
980 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/README.md')), msg='Missing submodule checkout')
981 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/ctest/README.md')), msg='Missing submodule checkout')
982 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/testrunner/readme.md')), msg='Missing submodule checkout')
983 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/umock-c/readme.md')), msg='Missing submodule checkout')
984 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/umock-c/deps/ctest/README.md')), msg='Missing submodule checkout')
985 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared/testtools/umock-c/deps/testrunner/readme.md')), msg='Missing submodule checkout')
986 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/README.md')), msg='Missing submodule checkout')
987 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/README.md')), msg='Missing submodule checkout')
988 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/ctest/README.md')), msg='Missing submodule checkout')
989 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/testrunner/readme.md')), msg='Missing submodule checkout')
990 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/readme.md')), msg='Missing submodule checkout')
991 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/ctest/README.md')), msg='Missing submodule checkout')
992 self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/testrunner/readme.md')), msg='Missing submodule checkout')
993
967class TrustedNetworksTest(FetcherTest): 994class TrustedNetworksTest(FetcherTest):
968 def test_trusted_network(self): 995 def test_trusted_network(self):
969 # Ensure trusted_network returns False when the host IS in the list. 996 # Ensure trusted_network returns False when the host IS in the list.