summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2019-03-12 18:46:26 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-03-24 16:42:22 +0000
commitf2da187f9456852d9e57f2c10c0ac84bba800a8f (patch)
tree06f07f0f59db3a8a82789482560d990cb3a1ad94
parent5de832c54f8f7eda0706cc6f51c8a6d7804856a2 (diff)
downloadpoky-f2da187f9456852d9e57f2c10c0ac84bba800a8f.tar.gz
bitbake: gitsmy.py: Fix unpack of submodules of submodules
If the submodule is in a subdirectory, it needs to have that structure preserved. This means the unpack path needs to be in the 'dirname' of the final path -- since the unpack directory name is specified in the URI. Additional specific test cases were added to ensure this is working properly based on two recent error reports. (Bitbake rev: acca06d060e49b2441562b4dc94416af9ab8187e) Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 8c8ecec2a722bc2885e2648d41ac8df07bdf660d) Signed-off-by: Scott Murray <scott.murray@konsulko.com> Signed-off-by: Armin Kuster <akuster@mvista.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/fetch2/gitsm.py9
-rw-r--r--bitbake/lib/bb/tests/fetch.py26
2 files changed, 32 insertions, 3 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index faffb4c77e..f45546b49b 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -176,12 +176,11 @@ 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.join(repo_conf, 'modules')) 179 newfetch.unpack(root=os.path.dirname(os.path.join(repo_conf, 'modules', modpath)))
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
183 183
184 newfetch = Fetch([url], d, cache=False)
185 local_path = newfetch.localpath(url) 184 local_path = newfetch.localpath(url)
186 185
187 # Correct the submodule references to the local download version... 186 # Correct the submodule references to the local download version...
@@ -191,7 +190,11 @@ class GitSM(Git):
191 runfetchcmd("%(basecmd)s config submodule.%(module)s.shallow true" % {'basecmd': ud.basecmd, 'module': module}, d, workdir=ud.destdir) 190 runfetchcmd("%(basecmd)s config submodule.%(module)s.shallow true" % {'basecmd': ud.basecmd, 'module': module}, d, workdir=ud.destdir)
192 191
193 # 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...
194 runfetchcmd("%s config core.bare false" % (ud.basecmd), d, quiet=True, workdir=os.path.join(repo_conf, 'modules', modpath)) 193 try:
194 runfetchcmd("%s config core.bare false" % (ud.basecmd), d, quiet=True, workdir=os.path.join(repo_conf, 'modules', modpath))
195 except:
196 logger.error("Unable to set git config core.bare to false for %s" % os.path.join(repo_conf, 'modules', modpath))
197 raise
195 198
196 Git.unpack(self, ud, destdir, d) 199 Git.unpack(self, ud, destdir, d)
197 200
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index de3b0ce7bb..e9ad807677 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -912,6 +912,32 @@ class FetcherNetworkTest(FetcherTest):
912 if os.path.exists(os.path.join(repo_path, 'bitbake-gitsm-test1')): 912 if os.path.exists(os.path.join(repo_path, 'bitbake-gitsm-test1')):
913 self.assertTrue(os.path.exists(os.path.join(repo_path, 'bitbake-gitsm-test1', 'bitbake')), msg='submodule of submodule missing') 913 self.assertTrue(os.path.exists(os.path.join(repo_path, 'bitbake-gitsm-test1', 'bitbake')), msg='submodule of submodule missing')
914 914
915 # The following external repositories have show failures in fetch and unpack operations
916 # We want to avoid regressions!
917 url = "gitsm://github.com/bus1/dbus-broker;protocol=git;rev=fc874afa0992d0c75ec25acb43d344679f0ee7d2"
918 fetcher = bb.fetch.Fetch([url], self.d)
919 fetcher.download()
920 # Previous cwd has been deleted
921 os.chdir(os.path.dirname(self.unpackdir))
922 fetcher.unpack(self.unpackdir)
923
924 repo_path = os.path.join(self.tempdir, 'unpacked', 'git')
925 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/subprojects/c-dvar/config')), msg='Missing submodule config "subprojects/c-dvar"')
926 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/subprojects/c-list/config')), msg='Missing submodule config "subprojects/c-list"')
927 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/subprojects/c-rbtree/config')), msg='Missing submodule config "subprojects/c-rbtree"')
928 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/subprojects/c-sundry/config')), msg='Missing submodule config "subprojects/c-sundry"')
929 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/subprojects/c-utf8/config')), msg='Missing submodule config "subprojects/c-utf8"')
930
931 url = "gitsm://github.com/CLIUtils/CLI11;protocol=git;rev=bd4dc911847d0cde7a6b41dfa626a85aab213baf"
932 fetcher = bb.fetch.Fetch([url], self.d)
933 fetcher.download()
934 # Previous cwd has been deleted
935 os.chdir(os.path.dirname(self.unpackdir))
936 fetcher.unpack(self.unpackdir)
937 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/googletest/config')), msg='Missing submodule config "extern/googletest"')
938 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/json/config')), msg='Missing submodule config "extern/json"')
939 self.assertTrue(os.path.exists(os.path.join(repo_path, '.git/modules/extern/sanitizers/config')), msg='Missing submodule config "extern/sanitizers"')
940
915class TrustedNetworksTest(FetcherTest): 941class TrustedNetworksTest(FetcherTest):
916 def test_trusted_network(self): 942 def test_trusted_network(self):
917 # Ensure trusted_network returns False when the host IS in the list. 943 # Ensure trusted_network returns False when the host IS in the list.