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-06-18 11:31:10 +0100
commit1f82ca67131694e2c85aeb15629ceb97e0bb9df4 (patch)
tree27125426ee1b7deff9e1a1e88885fd3b10d5ed8c /bitbake
parentb035b4dcee9122b5dd3799b48e4465e009bbed66 (diff)
downloadpoky-1f82ca67131694e2c85aeb15629ceb97e0bb9df4.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: ffd7ed530a17d22df576d986ac78428a6979e79c) 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 b21fed2669..54f99b1036 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -129,7 +129,7 @@ class GitSM(Git):
129 129
130 url += ';protocol=%s' % proto 130 url += ';protocol=%s' % proto
131 url += ";name=%s" % module 131 url += ";name=%s" % module
132 url += ";subpath=%s" % paths[module] 132 url += ";subpath=%s" % module
133 133
134 ld = d.createCopy() 134 ld = d.createCopy()
135 # Not necessary to set SRC_URI, since we're passing the URI to 135 # Not necessary to set SRC_URI, since we're passing the URI to
@@ -176,7 +176,7 @@ class GitSM(Git):
176 176
177 try: 177 try:
178 newfetch = Fetch([url], d, cache=False) 178 newfetch = Fetch([url], d, cache=False)
179 newfetch.unpack(root=os.path.dirname(os.path.join(repo_conf, 'modules', modpath))) 179 newfetch.unpack(root=os.path.dirname(os.path.join(repo_conf, 'modules', module)))
180 except Exception as e: 180 except Exception as e:
181 logger.error('gitsm: submodule unpack failed: %s %s' % (type(e).__name__, str(e))) 181 logger.error('gitsm: submodule unpack failed: %s %s' % (type(e).__name__, str(e)))
182 raise 182 raise
@@ -191,9 +191,9 @@ class GitSM(Git):
191 191
192 # Ensure the submodule repository is NOT set to bare, since we're checking it out... 192 # Ensure the submodule repository is NOT set to bare, since we're checking it out...
193 try: 193 try:
194 runfetchcmd("%s config core.bare false" % (ud.basecmd), d, quiet=True, workdir=os.path.join(repo_conf, 'modules', modpath)) 194 runfetchcmd("%s config core.bare false" % (ud.basecmd), d, quiet=True, workdir=os.path.join(repo_conf, 'modules', module))
195 except: 195 except:
196 logger.error("Unable to set git config core.bare to false for %s" % os.path.join(repo_conf, 'modules', modpath)) 196 logger.error("Unable to set git config core.bare to false for %s" % os.path.join(repo_conf, 'modules', module))
197 raise 197 raise
198 198
199 Git.unpack(self, ud, destdir, d) 199 Git.unpack(self, ud, destdir, d)
@@ -201,5 +201,7 @@ class GitSM(Git):
201 ret = self.process_submodules(ud, ud.destdir, unpack_submodules, d) 201 ret = self.process_submodules(ud, ud.destdir, unpack_submodules, d)
202 202
203 if not ud.bareclone and ret: 203 if not ud.bareclone and ret:
204 # Run submodule update, this sets up the directories -- without touching the config 204 # All submodules should already be downloaded and configured in the tree. This simply sets
205 # up the configuration and checks out the files. The main project config should remain
206 # unmodified, and no download from the internet should occur.
205 runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir) 207 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 522d2024fa..99508603f1 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -958,6 +958,33 @@ class FetcherNetworkTest(FetcherTest):
958 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/third_party/googletest/config')), msg='Missing submodule config "third_party/googletest/config"') 958 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/third_party/googletest/config')), msg='Missing submodule config "third_party/googletest/config"')
959 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"') 959 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"')
960 960
961 def test_git_submodule_iotedge(self):
962 """ Prevent regression on deeply nested submodules not being checked out properly, even though they were fetched. """
963
964 # This repository also has submodules where the module (name), path and url do not align
965 url = "gitsm://github.com/azure/iotedge.git;protocol=git;rev=d76e0316c6f324345d77c48a83ce836d09392699"
966 fetcher = bb.fetch.Fetch([url], self.d)
967 fetcher.download()
968 # Previous cwd has been deleted
969 os.chdir(os.path.dirname(self.unpackdir))
970 fetcher.unpack(self.unpackdir)
971
972 repo_path = os.path.join(self.tempdir, 'unpacked', 'git')
973
974 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')
975 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')
976 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')
977 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')
978 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')
979 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')
980 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')
981 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')
982 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')
983 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')
984 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')
985 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')
986 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')
987
961class TrustedNetworksTest(FetcherTest): 988class TrustedNetworksTest(FetcherTest):
962 def test_trusted_network(self): 989 def test_trusted_network(self):
963 # Ensure trusted_network returns False when the host IS in the list. 990 # Ensure trusted_network returns False when the host IS in the list.